ssi_logo

9323 Hamilton

Mentor, Ohio 44060 - USA

Tel:+1-440-357-1400

Fax:+1-440-357-1416

Scientific Solutions ® Inc.

On-Line Reference:

Math Equations for Converting ADC Data to Voltage


The math equations used to convert the "raw" data that is provided by the Analog-to-Digital Conversion (ADC) to the actual units you are measuring (normally voltage) depends upon five factors:
  1. The actual voltage "Range" of the Analog Input
  2. The amplifier "Gain" used on the Analog Input
  3. The "Resolution" of the ADC data
  4. The "Format" of the ADC data
  5. The "Arithmetic" of the computer program performing the conversion
We first need to understand each of these factors;


Range:

The voltage "Range" of the Analog Input is a hardware setting.  It determines the maximum voltage that can be connected to the Analog Input.  Typical Ranges are:
Analog Input Ranges that allow "only positive" signals are called Unipolar.
Analog Input Ranges that allow "both positive and negative" signals are called Bipolar

Some cards have a fixed Analog Input Range, while other cards can be set for several different Range settings.  You need to know the Analog Input Range of your card in order to be sure not to exceed the input voltage (which could cause damage to your hardware), and also so you can properly convert the raw ADC data to voltage.


Gain:

The amplifier "Gain" of the Analog Input is another hardware setting.  The Analog Input signal passes thru a "Gain" circuit before it is presented to the Analog-to-Digital converter.  The "Gain" circuit is used to increase the Analog Input signal so as to take advantage of the maximum resolution of the ADC.  Typical Gain settings are:
Some cards have a fixed Gain for all Analog Inputs, while other cards have a programmable gain amplifier that provides a different gain setting on an Analog Input channel-by-channel basis.  You need to know the Gain that is used for each of your Analog Input measurements so as to be sure not to exceed the input voltage and also so you can properly convert the raw ADC data to an actual voltage.


Resolution:

The "Resolution" of the ADC data is the number of bits used to represent the data.  Typical ADC data resolutions are:
Note that "Resolution" of the "ADC Data" may be different than the actual resolution of the Analog-to-Digital Converter.  For example, Scientific Solutions LabPac32 library "always" returns ADC Data as a 16 bit value, even if the actual hardware is 8-bit or 12-bit resolution.  LabPac does this so the conversion of raw data to voltage (the topic of this discussion) uses the same equations independent of the hardware.  The reason Scientific Solutions does this is so if you write your software using LabPac for an older 8-bit card, you can use the same software on a newer 16-bit card without having to rewrite your software with modifications to account for the different ADC resolution.  If you are not using the LabPac32 library but instead are accessing the hardware directly, then the software will have to know the actual resolution of the Analog-to-Digital converter in order to convert from the raw ADC data to voltage.


Format of the ADC Data:

The format of the ADC Data is again set by the hardware.  There are basically two different formats available:
Some cards have a fixed data format, while other cards allow the user to select the format.  It is important to know the ADC Data Format so you can properly convert the raw ADC data to an actual voltage.


Arithmetic of your Software:

The "Arithmetic" of software compliers and interpreters typically depend upon the type of numbers that are used.  There are basically two different number types:
The examples shown are for 16-bit numbers.  Most modern software compilers/interpreters let you specifically define a variable as a "Signed" or "Unsigned" value.  Some older interpreters do not.  It is very important that you understand how values are interpreted as this is absolutely necessary in order to properly convert the raw ADC Data into voltage.  Note that this issue is associated with the particular compiler or interpreter that you are using to write your software and is independent of the hardware or LabPac library calls.

The "Arithmetic" of your software really should match the ADC Data format as follows:
If you are unsure of how your computer handles numbers, then write a test program that takes the value of 7FFFh (for example) and convert it to decimal and print it out.  Compare it to the previous values provided here to determine if the hex value was converted to a "signed" or "unsigned" number.

On to the Equations:

The following tables lists the various equations that you would use.
Some notes to help understand the nomenclature used:

POWER(2 , Res)  = 2 "raised to the power of the ADC Data Resolution"
So, for 16-bit data;
POWER(2 , Res) = POWER(2, 16) = 65536

Range = (+Max Input) - (-Max Input)
So, for Bipolar Input of +10v to -10v
Range = (+Max Input) - (-Max Input)
Range = (+10) - (-10) = 20

The Column "Equation" contains the equation in the heading, and has the "calculated" values in the rest of the column.   Although the tables use 16-bit values and input ranges of either 20v (-10v to +10v) or 10v (0 to +10v), the equations can be used for different resolutions and Ranges.  Just be sure to use the proper equation for your configuration. 

For example, if you have a data acquisition card with:
And your software is using
Then you would still use the equation in the B2S table (Bipolar, 2's complement, Signed).   Your Range would be 10 and POWER(2,res) would be POWER(2,8) which is 256.


Note that when operating in Two's complement that the maximum positive value that can be represented is actually "one LSB less" than the maximum input voltage.  This is a consequence of Two's complement and the fact that the value '0' (although neither positive or negative)  is represented by a number with the most-significant-bit being a zero, thus there is one less positive number than there are negative numbers.

The tables are separated as follows:

Please note that the following two configurations ALWAYS use the same SINGLE equation (no checking the most-significant-bit), and so these are the two recommended settings you should use.
The other settings result if different equations with many depending upon the value of the most-significant-bit.


B2S = Bipolar Input, 2's complement, Signed Arithmetic
Bipolar
Analog Input
2's comp
ADC Data
Signed
Arithmetic
value
Equation:

(ADC Data) * (Range)
-------------------------
(Gain) * POWER(2 , Res)
+10.0
7FFF
32767
9.999694824
+7.5
6000
24576
7.5
+5.0
4000
16384
5.0
+2.5
2000
8192
2.5
+ LSB
0001
1
0.000305176
0
0000
0
0
-LSB
FFFF
-1
-0.000305176
-2.5
E000
-8192
-2.5
-5.0
C000
-16384
-5.0
-7.5
A000
-24576
-7.5
-10.0
8000
-32768
-10.0


B2U = Bipolar Input, 2's complement, Unsigned Arithmetic
Bipolar
Analog Input
2's comp
ADC Data
Unsigned
Arithmetic
value
Equation (when most-significant-bit = 0):

(ADC Data) * (Range)
-------------------------
(Gain) * POWER(2, Res)
+10.0
7FFF
32767
9.999694824
+7.5
6000
24576
7.5
+5.0
4000
16384
5.0
+2.5
2000
8192
2.5
+ LSB
0001
1
0.000305176
0
0000
0
0



Equation (when most-significant-bit = 1):

(ADC Data) * (Range)
-------------------------        -  Range
(Gain) * POWER(2, Res)
-LSB
FFFF
65535
-0.000305176
-2.5
E000
57344
-2.5
-5.0
C000
49152
-5.0
-7.5
A000
40960
-7.5
-10.0
8000
32768
-10.0


BBS = Bipolar Input, Binary, Signed Arithmetic
Bipolar
Analog Input
Binary
ADC Data
Signed
Arithmetic
value
Equation (when most-significant-bit = 1):

(ADC Data) * (Range)
-------------------------        + (Range / 2)
(Gain) * POWER(2, Res)
+10.0
FFFF
-1
9.999694824
+7.5
E000
-8192
7.5
+5.0
C000
-16384
5.0
+2.5
A000
-24576
2.5
+ LSB
8001
-32767
0.000305176
0
8000
-32768
0



Equation (when most-significant-bit=0):

(ADC Data) * (Range)
-------------------------        -  (Range / 2)
(Gain) * POWER(2, Res)
-LSB
7FFF
32767
-0.000305176
-2.5
6000
24576
-2.5
-5.0
4000
16384
-5.0
-7.5
2000
8192
-7.5
-10.0
0000
0
-10.0


BBU = Bipolar Input, Binary, Unsigned Arithmetic
Bipolar
Analog Input
Binary
ADC Data
Unsigned
Arithmetic
value
Equation (when most-significant-bit = 1):

(ADC Data) * (Range)
-------------------------
(Gain) * POWER(2, Res)
+10.0
FFFF
32767
9.999694824
+7.5
E000
24576
7.5
+5.0
C000
16384
5.0
+2.5
A000
8192
2.5
+ LSB
8001
1
0.000305176
0
8000
0
0



Equation (when most-significant-bit = 0):

(ADC Data) * (Range)
-------------------------        -  (Range)
(Gain) * POWER(2, Res)
-LSB
7FFF
65535
-0.000305176
-2.5
6000
57344
-2.5
-5.0
4000
49152
-5.0
-7.5
2000
40960
-7.5
-10.0
0000
32768
-10.0


U2S = Unipolar Input, 2's complement, Signed Arithmetic
Unipolar
Analog Input
2's comp
ADC Data
Signed
Arithmetic
value
Equation:

(ADC Data) * (Range)
-------------------------        + (Range / 2)
(Gain) * POWER(2, Res)
+10.0
7FFF
32767
9.999847412
+7.5
4000
16384
7.5
+5.0
0000
0
5.0
+2.5
C000
-16384
2.5
+ LSB
8001
-32767
0.000152588
0
8000
-32768
0


U2U = Unipolar Input, 2's complement, Unsigned Arithmetic
Unipolar
Analog Input
2's comp
ADC Data
Unsigned
Arithmetic
value
Equation (most-significant-bit = 0):

(ADC Data) * (Range)
-------------------------        + (Range / 2)
(Gain) * POWER(2, Res)
+10.0
7FFF
32767
9.999694824
+7.5
4000
16384
7.5
+5.0
0000
0
5.0



Equation (most-significant-bit = 1):

(ADC Data) * (Range)
-------------------------        - (Range / 2)
(Gain) * POWER(2, Res)
+2.5
C000
49152
2.5
+ LSB
8001
32769
0.000305176
0
8000
32768
0


UBS = Unipolar Input, Binary, Signed Arithmetic
Unipolar
Analog Input
Binary
ADC Data
Signed
Arithmetic
value
Equation (most-significant-bit = 1):

(ADC Data) * (Range)
-------------------------        + Range
(Gain) * POWER(2, Res)
+10.0
FFFF
-1
9.999847412
+7.5
C000
-16384
7.5
+5.0
8000
-32768
5.0



Equation (most-significant-bit = 0):

(ADC Data) * (Range)
-------------------------
(Gain) * POWER(2, Res)
+2.5
4000
16384
2.5
+ LSB
0001
1
0.000152588
0
0000
0
0


UBU = Unipolar Input, Binary, Unsigned Arithmetic
Unipolar
Analog Input
Binary
ADC Data
Unsigned
Arithmetic
value
Equation:

(ADC Data) * (Range)
-------------------------
(Gain) * POWER(2, Res)
+10.0
FFFF
65535
9.999847412
+7.5
C000
49152
7.5
+5.0
8000
32768
5.0
+2.5
4000
16384
2.5
+ LSB
0001
1
0.000152588
0
0000
0
0