LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading analog channels with DAQmxReadAnalogF64

I have a PCI - 6250 under CentOS 6. I am tying to read 9 Analog input channels ( 1 m acquisition time, voltage between 4.5 and 5.1 volts):

 

float minVolt=4.4;
        float maxVolt=5.1;
        float daqTimeInterval = 10.0;

DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai1:9","tube",DAQmx_Val_RSE,minVolt,maxVolt,DAQmx_Val_Volts,NULL));

DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"", 1000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,100000));

and then read it with:

DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,-1, daqTimeInterval,DAQmx_Val_GroupByChannel,data,1000,&tubeCounts,NULL));

Problems:

it doesn't read for the required time interval (here 10 s)

 

The min and max voltage values does not really matter.

 

Question:

 

How can I parse the "data" and "tubeCounts" in order to obtain the readings per channel and use them every minute?

 

Is it possble to use the custom virtual channels name (in this example "tube1...")

 

Thanks.

0 Kudos
Message 1 of 2
(2,223 Views)

Hi!

 

When it comes to using the DAQmx API in C, if you haven't already, I think this tutorial would be helpful to get you started:

Using NI-DAQmx in Text Based Programming Environments

Make sure that you include the listed general steps needed for data acquisition programming with DAQmx (Section 1) in your code. 

See section 3 for an example code written in C that includes all these steps.

 

To answer your specific questions:

 

How can I parse the "data" and "tubeCounts" in order to obtain the readings per channel and use them every minute?

 

The data array is an 1D double array. From what I can see, I assume you have defined it with a size of 1000 elements. 

 

DAQmxReadAnalogF64 reads a certain amount of values from the buffer as configured and writes those values to the data array. With the FillMode property of the DAQmxReadAnalogF64 you can specify whether or not the read values shall be interleaved when put into the data array, i.e. if the read values should be ordered in terms of samples or in terms of channels. See Interleaving for a more detailed description of the difference. 

 

 

Once you know how the elements are ordered in the output data array you can use that knowledge to parse the data the way you would like to process it. For instance, rearrange the 1D data array to a 2D array where each column corresponds to the different channel.

 

According to the function description for DAQmxReadAnalogF64, your tubecounts variable will contain the actual number of samples acquired from the read. Thus, you can use this information when you interpret the elements in data.

 

Is it possble to use the custom virtual channels name (in this example "tube1...")?

 

Yes, according to the function description of DAQmxCreateAIVoltageChan you can name the individual virtual channels by separating the names by commas. I.e. "tube1,tube2,tube3, ... etc"

 

I hope this will be of any help for you.

Best regards,

Marcus Bengths

0 Kudos
Message 2 of 2
(2,163 Views)