Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the device internal scale value using DAQmx class for Visual C++

I need to save my data in raw format (unsigned 16bit) using the CNiDAQmxAnalogUnscaledReader::ReadUInt16Async() for compatibility with other users' applications. So I need the attach the gain and offset values for that channel in the header file for converting the raw values to voltage values. Does anyone know where to obtain these two values from the DAQmx class? I am using the PXI-6254/Measurement Studio 7.1/Visual Studio.Net. Thanks.
0 Kudos
Message 1 of 4
(3,541 Views)

Hi,

I think that the GetAI_Gain function is what you are looking for in terms of obtaining the gains.  As for the offset values, I am assuming that you are implement a scale either in MAX or in your code for these. If this is the case, then you can manually enter in the value.  If this is not the case,  take a look at the Get Write_Offset function and see if this is what you are looking for. More information about these functions is available in the NI-DAQmx C Reference Help.  I hope this helps.

Regards,

Hal L.

0 Kudos
Message 2 of 4
(3,523 Views)

Check out this example for how to use the C++ DAQmx API for writing raw data out to a file. The example shows writing the data and how to read it back.

I hope this helps

Bilal Durrani
NI
0 Kudos
Message 3 of 4
(3,516 Views)
I may have confused others by calling the scaling factor as gain/offset.  What I am looking for is the scaling factor used by the DAQmx library to output the 16-bit data in voltage values.   I think I may have found out how  to calculate the conversion now: Since my DAQ a/d is a 16-bit converter, the scale factor to converting raw to voltage data will be:

voltage data =  raw_data_count * 2*vRange/2^16.

vRange is the input range for that channel at the time the data is taken.  I tried it a couple of time with different vRanges and it seems to work.

There is a Gain data member in the DAQmx AIChannels class but it it for user specified gain value not the device's internal value.  I can't find an equivalent GetAI_Gain() in the C++ side of the DAQmx development library though.

I'll check out the compact file examples to see if anything there I can use.  Thanks for the help!
0 Kudos
Message 4 of 4
(3,508 Views)