09-16-2010 11:46 AM
Hi,
regarding running average I'd like to ask for advice. I have an application where I read analog voltages from a DSO6104a oscilloscope. 1000 samples are taken in a 20 ms Iong window in every two seconds. I want to create a running average in a way that the 1000 data points are taken, averaged and the averaged value is displayed in a chart. I tried to do the following:
1, read the 1000 data points with the appropriate VI for that oscilloscope
2. I get the voltage value components and store them into the array
3. I summarise the content of the array
4. divide it by 1000.
This is how I thought it should be but the results are some weird numbers. Can you please advise where it's gone wrong/how to make it better.
Thanks,
Krivan
09-16-2010 12:02 PM
I think I would do it like this.
Or you can use the built in vi like this.
09-16-2010 01:35 PM
Are you doing a running average or an instantaneous average? Two different things. Your code seems to suggest an instantaneous average. If you really want a running average, then you need to decide the "depth" of the running average vs the number of points you are gathering. See, for instance, the "Calculate Running Average" example that ships with LabVIEW. That does it for 4 points, but can easily be adapted for an array, or a larger running average depth.
09-17-2010 05:14 AM
Thanks both of you for the advices!
Ermm...I thought that a running average is basically an instantaneous average...what is the real difference?
What I try to achieve and confused about is that there is an input data stream which is read by the ag6000a single channel VI. It reads 1000 samples in every 2 seconds [wait time in the while loop]. The output of the read VI connects to a waveform chart displaying the actual voltage values but at the same time I would like to average these 1000 data points and put the averaged value into another waveform chart. I think how I've done it - the getComponents+array - is not correct...
How is it possible to average these 1000 data points and display them in every loop sequence?
Thanks,
Krivan
09-17-2010 05:27 AM
You can use the PtByPt Mean function.
Felix
09-17-2010 06:39 AM
The Y elements are already in an array but then you are creating another array from them giving you a 2d array. If all you want is the average and not a running average then there are 2 ways of doing it as previously shown above:
If what you want is a running average then you will need to create a circular buffer to store the amount of data that you want to average. For example you may want an average reading of the last 10 waveform outputs from your oscilloscope. You can create a circular buffer that will hold the previous 10 readings which you can then average.
Regards,
Lucither
09-17-2010 06:39 AM - edited 09-17-2010 06:41 AM
ddddddd
09-17-2010 09:25 AM
@krivan wrote:
Thanks both of you for the advices!
Ermm...I thought that a running average is basically an instantaneous average...what is the real difference?
There is a difference: http://en.wikipedia.org/wiki/Moving_average.
What I try to achieve and confused about is that there is an input data stream which is read by the ag6000a single channel VI. It reads 1000 samples in every 2 seconds [wait time in the while loop]. The output of the read VI connects to a waveform chart displaying the actual voltage values but at the same time I would like to average these 1000 data points and put the averaged value into another waveform chart. I think how I've done it - the getComponents+array - is not correct...
How is it possible to average these 1000 data points and display them in every loop sequence?
You don't show the rest of the code, but (as has been pointed several times) the Mean VI will give you the average of the array you get from the read . You can wire this value directly to a chart. You mentioned charts, so I assume you know the difference between a chart and a graph? If not, please review the help on graphs and charts and look at the examples that ship with LabVIEW.