LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Average of DAQ Assistant that Automatically Records Data At Specified Time Intervals

I wrote a program that reads data from a DAQ Assistant, calculates the moving average, and then writes the data to an Excel file for 5 minutes every hour. The problem is that the sample rate in the written data is far less than the requested sample rate in the DAQ Assistant (1 Hz recorded vs. 100 Hz requested). This issue is related to the 'for' loop that calculates the running average because the program doesn't have this issue when the running average calculation is removed. Why does the 'for' loop take 1 s to output a value?

 

Is there a more efficient way of calculating this moving average? I cannot use mean ptbypt because I only have the base version of LabVIEW.

 

Thank you very much for your help.

Download All
0 Kudos
Message 1 of 5
(3,943 Views)

Hi Sean,

 

This issue is related to the 'for' loop that calculates the running average because the program doesn't have this issue when the running average calculation is removed.

Well, it's more related to your use of ExpressVi and DDT wires…

By converting a DDT wire to an array of samples you lose the timing information. When converting back to DDT the default timing of 1Hz is applied!

 

Recommendation: get rid of ExpressVIs. Or apply the correct timing information…

 

On your VI: why do you convert the DDT to an 1D array while processing just the first sample with your FOR loop?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,925 Views)

Thank you for the reply. I changed the ExpressVi to DAQmx and it seems to work.

 

I did run into one issue, the data coming out of the 'for' loop is in a 1D array format. I think this should be a 1x1 array because it's a for loop of 1. Please correct me if I'm wrong. I simply used the Index Array block to extract that value and convert it to DBL format. Is there a better way to do this?

 

Also, does anyone have a suggestion on setting up the running average in such a way that you could easily change the number of values that are averaged? Obviously this value effects the responsiveness and noise of the signal, so it would be better to tune this number. In its current form, changing the number of values in the average is quite cumbersome.

0 Kudos
Message 3 of 5
(3,903 Views)

Search for Mean Pt by Pt.vi.  It has an input to define the number of samples to average together.

 

For your initial question, you can get rid of the input of zero on the Index Array as it would start at the 0 index by default.  But you can get rid of the index array completely if you change the tunnel from auto-indexing to "last value".

0 Kudos
Message 4 of 5
(3,895 Views)

Thank you for suggesting that change to the Tunnel Mode. I switched the output of the 'for' loop to Last Value and that eliminated the need for the Index Array block - much cleaner.

 

I'm currently looking at the Mean ptbypt code for inspiration. I'll update this thread if I figure out a running average function with an easily variable number of points.

 

I've also attached the most recent version of my code for those who are interested.

0 Kudos
Message 5 of 5
(3,879 Views)