Searching \ for '16 bit value' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=bit+value
Search entire site for: '16 bit value'.

Truncated match.
PICList Thread
'16 bit value'
1998\02\16@152336 by Andrew Warren

face
flavicon
face
Aaron Hickman <spam_OUTAaron.HickmanTakeThisOuTspamdrexel.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 - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...