16 bit value
Andrew Warren email (remove spam text)
Aaron Hickman <drexel.edu> wrote: Aaron.Hickman
> Thanks for the quick reply! Unfortunately, I need to display
> voltage to the nearest mV (ie. 3 decimal places). Can your
> previous method be adjusted to do this?
The easiest way to get mV precision is:
1. Find the absolute value, as I suggested. This will give you
a number in the range [0-32767].
2. Shift it left one position (multiplying it by 2), so Step 4
will be easy.
3. Multiply it by 10000 using your choice of 16-bit x 16-bit
multiplication routines. You'll get a 32-bit result.
4. Divide the result by 65536. This is REAL easy; just discard
the least-significant two bytes from the 4-byte result of
5. You now have abs(ADC) * 10000/32768. Convert it to whatever
format your display wants, put a decimal point between the
third and 4th least-significant digits, and set the sign to
the sign of your original number.
P.S. I'm copying this to the PICLIST.
=== Andrew Warren - ix.netcom.comfastfwd
=== Fast Forward Engineering - Vista, California
In reply to: <firstname.lastname@example.org>
See also: www.piclist.com/techref/index.htm?key=bit+value
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the