Index Through DAQmx Read Data in LabWindows™/CVI™

Updated Jun 21, 2018

Reported In

Software

  • LabWindows/CVI

Driver

  • NI-DAQmx

Programming Language

  • C
  • C++

Issue Details

I am reading data from my DAQmx device in my LabWindows/CVI program. I am outputting the data to a graph, but I also want to index through the data and access individual values to write to the user interface. How do I do this?

Solution

Data from the DAQmx Read functions in LabWindows/CVI can be written to a pointer. For example, the LabWindows/CVI example named ContAcq-IntClk stores the data in a 64 bit floating point pointer named gData. Here are some snippets of the declaration of the pointer and the relevant DAQmx read: 
 

static float64        *gData=NULL;
DAQmxReadAnalogF64(taskHandle,nSamples,10.0,DAQmx_Val_GroupByScanNumber,gData,nSamples*gNumChannels,&numRead,NULL)


To access the individual values in this case, you simply index through the memory, starting at the pointer memory location. For the above example, the data read from the DAQmx device is placed starting in memory at the memory location of gData. To get an element at a specific index in the data returned, you can access it in C languages in the following way: 

*(gData + index)

Where index is the zero-indexed location of the element you would like to access in the read values, and gData is the name of your pointer to the DAQmx data. 
 

You can then use SetCtrlAttribute or SetCtrlVal to set the value of your user interface objects to the value of the element you accessed. 

Additional Information

If you read multiple channels of data, the information is interleaved in the read array.

WAS THIS ARTICLE HELPFUL?

Not Helpful