The ADC of the NI PCI-6052E provides us with the voltages of each
channel digitized in 16 bits. Now a call to the function
DAQ_VScale() with appropriate parameters does the
conversion back to volts for us. But these will be of type
double (8 bytes) instead of short (2 bytes). So
in order to make the .sm files as small as possible, the
2 byte unconverted binary data will be stored, rather than the 8
byte double-precision converted voltages. In order to retrieve the
voltages later, we need to save the conversion factors in a
structure ai_settings which will be stored along with
our data. The members of this structure are
- short Polarity (0 = bipolar, 1 = unipolar)
- short VoltRange (will usually be 10, to signify
-5 V to 5 V in bipolar mode or 0 V to 10 V in unipolar mode)
- long DigitalRange (will be
for
16 bit binary data)
- double Offset (can correct for offset in
binary; this will usually be a value of 0.0)
- short Gain (in case we want to measure
lower voltage range at higher
resolution). Unfortunatly this parameter is expressed as a
fraction of VoltRange. We will usually use a value of 1.
- double GainAdjust (will usually not be used,
i.e., be 1.0)
For unipolar mode, the binary data of type short will be
treated as unsigned short, which makes a type cast
necessary. The general formula used is:
In C++, this formula usually leads to the same result as
a call to DAQ_VScale(). In some cases, however, the
results differ by a number in the order of
or smaller.
The source of this error is as yet unknown (presumably it is due
to some internal rounding effect), but its magnitude is of no
concern to us.
Holger Fleckenstein
2008-07-08