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:
- The actual voltage "Range" of the Analog Input
- The amplifier "Gain" used on the Analog Input
- The "Resolution" of the ADC data
- The "Format" of the ADC data
- The "Arithmetic" of the computer program performing the conversion
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:- -10v to +10v, which is a Range of 20v
- -5v to +5v, which is a Range of 10v
- -2.5 to + 2.5, which is a Range of 5v
- 0v to +10v, which is a Range to 10v
- 0v to +5v, which is a Range of 5v
- 0v to +2.5v, which is a Range of 2.5v
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:- 8 bit
- 12 bit
- 16 bit
Format of the DAC Data:
The format of the DAC Data is again set by the hardware. There are basically two different formats available:- Binary
- 0000 is assigned the minimum value (0 if Unipolar, -Max if Bipolar)
- FFFF is assigned the maximum value (+Max in Unipolar or Bipolar
modes)
- Two's Complement
- The most-significant-bit is the "Sign" bit of the number
- msb = 0, then number is not-negative (zero or positive)
- msb = 1, then number is negative
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:- Signed (Two's Complement Representation)
- 7FFFh = +32767
- 0000h = 0
- 8000h = -32768
- Unsigned (Binary or Offset Binary Representation)
- 7FFFh = 65535
- 8000h = 32768
- 0000h = 0
The "Arithmetic" of your software really should match the ADC Data format as follows:
- If Data Format is Two's Complement
- then use "Signed" Arithmetic
- If Data Format is Binary
- then use "Unsigned" Arithmetic
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:
- Bipolar vs. Unipolar Analog Input
- 2's Complement vs. Binary ADC Data
- Signed vs. Unsigned Arithmetic
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.
- B2S, Bipolar Input, 2's Complement, Sign Arithmetic
- UBU, Unipolar Input, Binary, Unsigned Arithmetic
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 |