# LabVIEW

cancel
Showing results 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
Message 1 of 5
(2,734 Views)

## Re: Averaging with ni scope

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... 😉
--------------------------------------------------------------------
Message 2 of 5
(2,728 Views)

## Re: Averaging with ni scope

Well then how would i go about taking a running average of a waveform outside of my main while loop?
Mark Mutton
Electrical Engineer
Message 3 of 5
(2,723 Views)

## Re: Averaging with ni scope

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... 😉
--------------------------------------------------------------------
Message 4 of 5
(2,720 Views)

## Re: Averaging with ni scope

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.
This account is no longer active. Contact ShadesOfGray for current posts and information.
Message 5 of 5
(2,709 Views)