Scientific Solutions ® Inc.

On-Line Reference:

Math Equations to Determine Data for a Required DAC 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 Output is a hardware setting.  It determines the minimum and maximum analog voltage that the DAC can output.  Typical Ranges are:
Analog Output Ranges that allow "only positive" signals are called Unipolar.
Analog Output Ranges that allow "both positive and negative" signals are called Bipolar

Some cards have a fixed Analog Output Range, while other cards can be set for several different Range settings.  You need to know the Analog Output Range of your card so you can properly calculate the data need for a particular Analog Output voltage.


Resolution:

The "Resolution" of the DAC data is the number of bits used to represent the data.  Typical DAC data resolutions are:
Note that "Resolution" of the "DAC Data" may be different than the actual resolution of the Digital-to-Analog Converter.  For example, Scientific Solutions LabPac32 library "always" requires DAC Data as a 16 bit value, even if the actual hardware is 8-bit or 12-bit resolution.  LabPac does this so the calculation of DAC data (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 DAC 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 Digital-to-Analog converter in order to calculate the proper DAC Data.


Format of the DAC Data:

The format of the DAC 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 DAC Data Format in order to calculate the proper DAC Data.  Note that if you are using the Scientific Solutions LabPac32 library, the Analog Output functions want the data to be 16-bit Two's Complement format.  Although some hardware is designed for Binary data while some is designed for Two's Complement data, the LabPac32 library always requires 16-bit Two's Complement data so you can migrate from one product to the other without having to change your software because of DAC Data format differences.


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 8-bit data and the Range is -5v to +5v, you would still use the equation in the first table.  Your (2 ^ resolution) value would be 2 ^ 8 =256, and your Range would be 10v.

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 Output, 2's complement, Signed Arithmetic
Bipolar
Analog Output
Equation:

(Volt) * POWER(2,res)
-------------------------
Range
Signed
Arithmetic
value
+9.99964824
7FFF
32767
+7.5
6000
24576
+5.0
4000
16384
+2.5
2000
8192
+ 0.000305176
0001
1
0
0000
0
-0.000305176
FFFF
-1
-2.5
E000
-8192
-5.0
C000
-16384
-7.5
A000
-24576
-10.0
8000
-32768


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