From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging with ni scope

I am using a NI-PXI-5124 and am trying to take a running average of a signal.  I would like the running average to be independent of the while loop I am using to do all the signal analysis. I tried using the example provided by ni "moving average" but this is dependent upon the operating speed of the while loop. I found a way that i think might work but need a conformation. Attached is a picture of a method i thought might work, but i need to know if the NI Scope Read cluster.vi continuously reads a signal into memory. I am running the for loop inside of my main while loop.
 
Thanks
Mark Mutton
Electrical Engineer
0 Kudos
Message 1 of 5
(3,148 Views)
Actually what you are doing is to calculate the normal average of n measurements.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 5
(3,142 Views)
Well then how would i go about taking a running average of a waveform outside of my main while loop?
Mark Mutton
Electrical Engineer
0 Kudos
Message 3 of 5
(3,137 Views)
Actually I don't know where your main while loop is in relation to the for loop you placed. In addition one can not see from your picture what you originally wanted to do.
 
So it is helpful if you could post the vi and give more information on what you want to achieve.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 4 of 5
(3,134 Views)
You probably want some way to move waveforms efficiently from one loop to another.  The tutorial Managing Large Data Sets in LabVIEW should give you some ideas you can use.  You can then analyze your data in one loop and average in another.  You may want to use the decimation algorithms in the tutorial to speed things up for display.

Another thing to watch out for is that simply averaging your waveforms as you are doing will tend to smear you data over a one sample time width.  This is because the trigger position is more or less randomly distributed in time between two samples.  If this is OK, you can continue as you are.  If not, you can get the exact trigger position from the wfm info cluster of the cluster fetch or the t0 value in the waveform of the waveform fetch, provided you set the timestamp type to relative.  You can then use the resample VIs to shift your waveform in time a subsample amount before doing your averaging.  If your version of LabVIEW does not have the resample VIs, you can use Fourier transforms or Savitzky-Golay filters to do this fairly quickly and easily.  Both techniques are explained in the latest copy of Numerical Recipes in C, by Press et. al.

Good luck.  Let us know if you need more help.
0 Kudos
Message 5 of 5
(3,123 Views)