Jinx wrote: > What I really want to do is make a universal system so that any > ASCII string can be compared to any sensor voltage, so that the > user receives not only the alert but also a message in appropriate > terms and units Since you're dealing with verbose ASCII strings over a serial port, I'll assume that compute cycles aren't critical. If so, this sounds like a natural application for floating point. That way you don't have to worry about the max range on one end and the min precision on the other. For each A/D channel, you keep two numbers that can be pre-computed at assembly time. These are the scale factor and offset to go from the user values to the A/D reading. Using the same two numbers you do a subtract and a divide to go the other way. The remaining issue is converting a floating point value to its ASCII representation. Again I'm assuming cycles are available, so brute force it. One general routine will be easier to write and maintain, even if it takes a few more cycles. By brute force it, I mean using multiple of 10 scale factors, probably again using floating point because of the unknown range. I use a 24 bit floating point format for this, which leaves 16 bits of precision. That's plenty good enough considering you're ultimately dealing with 10 or 12 bit A/D readings, even allowing a few bits for roundoff errors. As for pre-computing the fixed scale factors and offsets at assembly time, use my preprocessor. It adds floating point as a native data type to MPASM and does the assembly time calculations in the host floating point format. It also includes conversion functions to emit the hex values in MPASM syntax for the resulting values in my PIC 24 bit floating point format. If you're not already using my PIC development environment and relocatable mode and the preprocessor, maybe now's a good time to See the Light and jump in. I won't ask you to drink any grape coolaid. It's really not that hard and in a few weeks you'll wonder how you ever got along with out it. If you do that, I'll send you my 24 bit floating point routines privately. I don't give these away on the web, but I don't mind you using them as long as you don't give them out publicly. ****************************************************************** Embed Inc, Littleton Massachusetts, (978) 742-9014. #1 PIC consultant in 2004 program year. http://www.embedinc.com/products -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist