www.piclist.com/techref/index.htm?key=bit+value

Aaron Hickman <spamAaron.HickmanspamBeGonespamdrexel.edu> wrote:

> 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?

Hi, Aaron.

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

Step 3.

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.

-Andy

P.S. I'm copying this to the PICLIST.

=== Andrew Warren - spamfastfwdix.netcom.com

=== Fast Forward Engineering - Vista, California

=== http://www.geocities.com/SiliconValley/2499

In reply to: <01bd3ae6$fe3028a0$0c2d7690@ac12.chemistry.drexel.edu>

See also: www.piclist.com/techref/index.htm?key=bit+value