Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-Daqmx ReadAnalog and Readbinary

Hi,
I'm starting to use the NI-Daqmx C functions.
I put 5.01V on the input 0. I created a task with a continuous acquisition, I launched my task and I did 2 differents reading. First, I read my data with DAQmxReadAnalogF64 function. I saw my 5.018V. Secondly, I read my data with DAQmxReadBinaryI32 function. I saw 15531.
 
My board is a 6221-37pins(16 bit-bipolar)
If I trie to translate my binary value in voltage value, I find : 15531 / 32768 * 10 = 4.73V  <= ???
 
Thanks for your help
 
Fv1234
0 Kudos
Message 1 of 6
(4,667 Views)
Fv1234,
 
Your 6221 M-Series device is a bit different from older NI Multifunction DAQ devices.  Unlike older devices, the binary data coming off the board is not calibrated.  However the driver will allow you to querry the correct scaling coefficients for calibrating your data.  Here is the information for the DAQmx C Reference Help on this functionality:
 

Analog Input >> General Properties >> Advanced >> Device Scaling Coefficients >> Device Scaling Coefficients

Data Type: float64*
Description: Indicates the coefficients of a polynomial equation that NI-DAQmx uses to scale values from the native format of the device to volts. Each element of the array corresponds to a term of the equation. For example, if index two of the array is 4, the third term of the equation is 4x^2. Scaling coefficients do not account for any custom scales or sensors contained by the channel.
Restrictions: Not Settable


You can get this property using:

  DAQmxGetAIDevScalingCoeff

Get/Set/Reset AI_DevScalingCoeff

int32 __CFUNC DAQmxGetAIDevScalingCoeff(TaskHandle taskHandle, const char channel[], float64 *data, uInt32 arraySizeInSamples);


Purpose

DAQmxGetAIDevScalingCoeff gets the Analog Input >> General Properties >> Advanced >> Device Scaling Coefficients >> Device Scaling Coef... property.

This should allow you to correctly scale your binary data.

Hope this helps,
Dan

Message 2 of 6
(4,659 Views)

Thanks a lot

Fv1234

0 Kudos
Message 3 of 6
(4,643 Views)
Hello everybody,

I have some questions regarding the c function DAQmxGetAIDevScalingCoeff

I am wondering if with M series ADCs the device scaling coefficients are per AI or are they always same for all AIs?
Moreover, which order is the polynomial equation?
I use linear measuring. Can I be sure it is of 1st order?

The C code in the examples http://sine.ni.com/devzone/cda/epd/p/id/1611
holds space for 1000 coefficients.

Thanks in advance
0 Kudos
Message 4 of 6
(4,322 Views)
Hi witchIT,
 
M-Series devices have only one ADC, so in that sense scaling coefficients are per AI.  However, calibration is preformed on every range that your device supports.  This means that if two channels use two different ranges, they will have different calibration constants. 
 
M-Series devices use a 3rd order polynomial equation for calibration and scaling.  I believe you can get this information from the driver by calling DAQmxGetAIDevScalingCoeff and passing NULL into the data parameter.  In this case, instead of returning an error, the function returns the size of the scaling coefficient array.  For my M-Series device it returns 4, which would be correct for a 3rd order polynomial.  I remember reading about this trick somewhere here on the forums, but can't find the thread in which I saw it.
 
Hope this helps,
Dan
0 Kudos
Message 5 of 6
(4,306 Views)
Thanks a lot, Dan! Everything worked as you stated.
0 Kudos
Message 6 of 6
(4,252 Views)