01-07-2016 09:51 PM
Hi everyone!
I am new to the fourms here and am having some difficulty writing a VI which allows me to compute a rolling average of a continuously sampled waveform (1D array).
Here is my situation: I am trying to write a VI that duplicates the AVERAGE mode of a Tektronix o-scope. For example, I can run the scope in sample mode, then tell it to average 4 scans and it displays an average waveform. I beleive this works by using a running summation average for the first three scans, then when it gets to the fourth, it changes to exponential averaging for the fourth. Then I think it repeats, but I am not sure. Here is a webpage from Tektronix: http://www.tek.com/support/faqs/how-does-scope-calculate-average-when-you-are-ave-mode
I have been trying this for a few weeks to no avail. Here is a VI I wrote which I thought was correct but it appears to be doing a simple smooth of the continuous rather than duplicating the o-scope's average function. I will gladly take any suggestions. Thanks in advance.
Solved! Go to Solution.
01-07-2016 10:58 PM
Maybe you could just use mean ptbypt?
(It just averages the last four point. Look at the code inside, maybe you can modify it so it is more similar to the tektronix averager. I hanve't studies your link yet))
01-08-2016 07:01 AM
Hi altenbach,
Thanks for the suggestion. Mean ptbypt will not work for this application, as my input data is a 1D array and not a double precision number. I have not seen a way to use 1D arrays with the mean ptbypt VI. If you know a way, please let me know. My LV coding skills are not great, so example VI's would certainly be helpful.
Let me know if/when you take a look at the link I sent. I will keep chugging on it and I will post a VI when I am comfortable. Thanks for all the help - I am very appreciative.
01-08-2016 07:12 AM
01-08-2016 07:26 AM
Hi Gerd,
Thanks for the suggestion but I do not think I follow. When I enable indexing on the for loop, I cannot wire the 1D array as input. I have included a picture of this. I think my understanding of the loop indexing is a little shaky.
Any help (and possibly an example VI) is greatly appreciated.
01-08-2016 07:33 AM - edited 01-08-2016 07:33 AM
I think this is closer to what you actually want. You need to store your last X samples in an array and then use a FOR loop to do the averages on the columns. I have not fully tested this code and it won't really work until you have all of the history you want, but it should at least get you started.
01-08-2016 07:35 AM
Hi crossrulz,
Thanks! Can you please attach a LV 2014 compatible VI so I can tweak and play with?
I greatly appreciate the assistance.
01-08-2016 08:09 AM
01-08-2016 10:31 AM
@jdepalma wrote:
Hi crossrulz,
Thanks! Can you please attach a LV 2014 compatible VI so I can tweak and play with?
I greatly appreciate the assistance.
Here you go
01-08-2016 10:46 AM
@GerdW wrote:
you have to create a FOR loop in the correct location:
This is not the same. He acquires entire 1D arrays and wants to do a rolling average in the second (time) dimension. Ths means we need to keep a 2D array of the last few traces in the shift register as in Tim's code.