When you set the DAQmx Read.vi
in Raw Data 1D array mode, you will get an array of integers. Pay special attention to the relationship of resolution and integers of the device when converting binary values to scaled values. Suppose your DAQ device has a resolution of 16 bits. You should set the DAQmx Read.vi
in Raw 1D U16 or Raw 1D I16 mode, or you will lose effective bits. When the reading is greater than 32767(2^15-1) in U16 mode, it means that the voltage is negative and this value is complementary code. You can convert it to a signed integer by subtracting 65536. For example, 65534 in U16 is -2 in I16. Keep in mind that Unscaled Raw Data can differ between different series of DAQ cards.
M Series and X Series
For M Series and X Series devices, the acquired raw data will be uncalibrated and unscaled. However, the calibration information and the scaling information is combined by the driver and available through the AI.DeviceScalingCoeff property of a DAQmx Channel Property Node. This property is selected by clicking Properties » Analog Input » General Properties » Advanced » Device Scaling Coefficients. The data returned by this property is an array. Each element of the array is a coefficient of a third order polynomial which can be utilized to find a calibrated and scaled voltage: f(X)=a*X^0+a*X^1+a*X^2+a*X^3 (where a[i] is an array element).
For the E Series board, the acquired raw data will be calibrated on the hardware, just not scaled. The scaling information is available through the above mentioned property node. The property node will only return an array of 2 elements. This implies that the scaling of the E Series device can be represented as a first order polynomial: f(x)=aX^0+aX^1.
You will notice that a will always be zero for an E Series device. This also implies that a is the E Series' range/resolution. Manually Convert Binary Data to Unscaled Data
Given the resolution of your board and measurement range, the formula below shows how to manually convert acquired binary data to unscaled data (units of volts):
Voltage Reading = (binary reading/2^bit)*(Vmax-Vmin)
Manually Convert Binary Data to Scaled Data
- If your voltage range is bipolar (+/- 5V), then the reading is the signed (I16) representation within the range of -32768 to 32767 for the binary reading returned.
(i.e. Vmax = 5V, Vmin = -5V, bit = 16, binary reading = -8192, voltage reading = -1.25V)
- If your voltage range is unipolar (0-10V), then the reading is the unsigned (U16) representation within the range of 0 to 65535 for the binary reading returned.
(i.e. Vmax = 10V, Vmin =0V, bit = 16, binary reading = 8192, voltage reading = 1.25V)
Using the Device Scaling Coefficient property node, you can convert the binary data to scaled data using a setup similar to the one below.