LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rolling average of 1D arrays

Solved!
Go to solution

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. 

0 Kudos
Message 1 of 25
(8,756 Views)

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))

0 Kudos
Message 2 of 25
(8,736 Views)

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.  

0 Kudos
Message 3 of 25
(8,691 Views)

Hi depalma,

 

I have not seen a way to use 1D arrays with the mean ptbypt VI

An autoindexing FOR loop will do the trick - as usual…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 25
(8,685 Views)

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.  

0 Kudos
Message 5 of 25
(8,675 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 25
(8,667 Views)

Hi crossrulz,

 

Thanks!  Can you please attach a LV 2014 compatible VI so I can tweak and play with?

 

I greatly appreciate the assistance.  

0 Kudos
Message 7 of 25
(8,657 Views)

Hi depalma,

 

you have to create a FOR loop in the correct location:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 25
(8,642 Views)

@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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 25
(8,615 Views)

@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.

0 Kudos
Message 10 of 25
(8,607 Views)