On Nov 30, 2005, at 1:26 AM, 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 It looks to me like everyone is focusing on the decimal input (which ought to be relatively standard) rather than the automatic scaling (which presumably has to happen at assembly time rather than runtime; I don't think there's any way you can derive a scale factor from a single input number...) Essentially you need to input two points that define an equation that gives you input values for A-D values. For your battery example you might have (0,0) and (12, 1023) and for the temperature example you have (0,0) and (40, 1023) (or something like that, if your A-D is 10 bits.) ; the fact that the sensors output 12V and there's HW scaling to 5V is an irrelevant red herring; all you really care about is limits and A-D results. So you'd want macros something like: compute_inputscale macro (admin, inmin, admax, inmax, inscale, outscale) ;; store inscale and outscale based on computations with values. inputnumber macro (inscale) ;; input a number and convert to A-D value based on inscale computed ;; earlier by compute_inscale outputnumber macro (outscale) inscale doesn't have to be a number that you do math with; it can be code generated by the macro, which could give you multiple precision capability. For efficiency, it can be multiple pieces of code that are called depending on the number of decimal places in the input. Am I making any sense, or is it too early in the morning? BillW -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist