LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire middle samples in 200 sample aquisition

Solved!
Go to solution

I have a requirement to average the middle 100 samples of a 200 sample acquisition from an analog port of a USB-6212.

I was able to acquire the 200 samples, however, can someone suggest algorithms to skip the first 50 samples and average the next 100 samples?

Do I collect the 200 samples into an array and do the calculations from the array?  How will that work in a vi?

Thanks in advance for any help.

0 Kudos
Message 1 of 4
(2,211 Views)

Use Array Subset.  Start at 50,  length =100

0 Kudos
Message 2 of 4
(2,206 Views)

If I have a DAQmx Read with Analog Wfm 1Chan NSamp, is that considered an array?

Would I then just use the Array Subset that you mentioned?

Otherwise would I have to use an Insert into Array and then use the  Array Subset?

 

Thanks

0 Kudos
Message 3 of 4
(2,197 Views)
Solution
Accepted by topic author ElectricZ

Being that it is a waveform data type, the array of values (doubles) is stored as a component (Y) of the waveform.  You can use the Get Waveform Components VI to extract this data, and then perform your averaging as mentioned above. 

 

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/get-waveform-components.html

 

Another option, depending on what is required by your application, would be to read the samples as Doubles instead of Waveforms which would remove that extra step.  This is assuming you don't need the timestamp or timing information that the Waveform data type provides.

Message 4 of 4
(2,191 Views)