piclist 1998\02\16\152336a >
Thread: 16 bit value
face BY : Andrew Warren email (remove spam text)

Aaron Hickman <spamAaron.HickmanKILLspamspam.....drexel.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.


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

=== Andrew Warren - fastfwdRemoveMEspamix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499
<199802162019.OAA10171@dfw-ix8.ix.netcom.com> 7BIT

In reply to: <01bd3ae6$fe3028a0$0c2d7690@ac12.chemistry.drexel.edu>
See also: www.piclist.com/techref/index.htm?key=bit+value
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) 16 bit value

month overview.

new search...