LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a single data point from waveform data into a tdms

Hi,

 

I'm trying to record a single data using DAQmx but my tdms files is collecting multiple data points.  

 

The DAQmx task is reading from 2 external probes, so I am using a DAQmx read function set to Analog, 2D DBL, NChan, NSamp.  So the output of this is a 2D array of waveform data.  

 

The DAQmx task "Draw 2" has 2 channels it is reading from.

 

Then I use "index array" to select the channel I want to save into my tdms file (index 0 in this case).

 

The index array function converts the 2D array into a 1D array.,  I pass this into a "build array" so I can concentrate all my davices into one data wire to pass to my tdms.  

 

When I run the program the tdms is giving me multiple data points from the device that I indexed, and when I watch the program exectute in my Block Diagram I can see that the Build Array is outputting hundreds of data points when I want it to output only 6 point (1 from each input channel).

 

My question is: How can I make the "build array" pass only one data point from the device I chose using "index array"?

 

I'm attaching a screenshot of the MainVI with the DAQmx read, index array, and build array functions circled.  

 

I'm also attaching the Main VI (called "DS Flux 3-cell") 

Download All
0 Kudos
Message 1 of 3
(2,999 Views)

 

First, unless you have the Draw2 configured differently in NI MAX, the task will acquire samples until the buffer fills on each loop.  This is why you are seeing multiple samples per channel each loop.

 

Here is the VI with the # of samples set to 1.  By default, it is -1, which is as many samples as it can until the buffer fills.

 

samples per channel.PNG

 

Option A)

 

If you want to take just one sample for each loop, you need to change the Sample count or change DAQmx Read.vi to Analog> Multiple Channel > Single Sample> 1D array or 1d Waveform.  Then if you wanted the datapoint from a single channel, the index array would give a single data point.

 

single sample.PNG

 

Currently you are getting the channel row, which provides all the samples aquired until the buffer filled.  The output from the index array is a 1D array at this point (which is on your VI currently)

 

Option B)

 

If you want to keep the code mostly as you have it, then just add in the additional parameter of the column where you want a single data point.  The output from the index array is then a single data point.

 

index array.PNG

 

 

 

Kenny

Message 2 of 3
(2,979 Views)

Hi Kenny,

 

Thank you for the help!  I went with option B because I have a subVI that needs the data from both devices in the form of a 2D array.  

What a quick fix!

 

0 Kudos
Message 3 of 3
(2,969 Views)