8.3 A/D Conversion Formulas

The 16-bit value returned by the A/D converter is always a twos complement number ranging from -32768 to 32767, regardless of the input range. This is because the input range of the A/D is fixed at 10V. The input signal is actually magnified and shifted to match this range before it reaches the A/D. For example, for an input range of 0-10V, the signal is first shifted down by 5V to 5V and then amplified by 2 to become 10V. Therefore, two different formulas are needed to convert the A/D value back to a voltage, one for bipolar ranges, and one for unipolar ranges.

Tables showing the correlation between A/D code and input voltage are shown on the following page.

For Bipolar Input Ranges

FS = full-scale voltage (e.g. 5V for 5V range)

If using a 16-bit signed integer in C: Input voltage = (A/D code / 32768) x FS

Example: 5V range selected, A/D code = 17762 (Hex 4560) Input voltage = (17762 / 32768) x 5V = +2.7103V

Example: 5V range selected, A/D code = -15008 (Hex C560) Input voltage = (-15008 / 32768) x 5V = -2.2900V

If using a 32-bit signed integer in C, or unsigned or floating value in C or Basic:

Input voltage = (A/D code / 32768) x FS

If input voltage >= FS then input voltage = input voltage - 2 x FS

Example: 5V range selected, A/D code = 17762 (Hex 4560) Input voltage = (17762 / 32768) x 5V = +2.7103V

Example: 5V range selected, A/D code = 50528 (Hex C560)

Input voltage = (50528 / 32768) x 5V = +7.7100V

Since 7.7100V >= 5V, we must subtract:

Input voltage = 7.7100V - 2 x 5V = -2.2900V

For Unipolar Input Ranges

FS = full-scale voltage (e.g. 10 for 0 - 10V range)

Input voltage = ((A/D code + 32768) / 65536) x FS

Example: 0 - 10V range selected, A/D code = 17762 (Hex 4560)

Input voltage = ((17762 + 32768) / 65536) x 10V = +7.7103V Note that this is simply the result for the 5V range shifted up by 5V

Last updated