ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running average - that old chestnut!

Solved!
Go to solution

Hi all. I have been searching the forum for examples of a boxcar average but can't find anything that suits.

Let's say I have a continuous stream of data coming in at the left and a wire to a waveform chart at the right. I haven't done a vi because it's that simple. I don't know how many data points there will be.

All I want is a black box to insert in the wire that will give me a running average of n points, probably around 5. I don't want the source or the indicator to be inside any loop.

Nearly all of the examples have either a number generator and display inside a loop, or a fixed length array of data points to work on. I just want the data stream coming in, averaged as it goes, and going out. I'm sure it can't be too difficult.

Thanks for any help.

Andy.

0 Kudos
Message 1 of 8
(4,318 Views)

Use "mean ptbypt" with a value of 5.

0 Kudos
Message 2 of 8
(4,317 Views)

@altenbach wrote:

Use "mean ptbypt" with a value of 5.


Spoiler
You KNOW it is a simple question if Christian's reply would fit in a tweet.

 

 

Smiley Wink

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 8
(4,308 Views)

Actually, mean ptbypt seems to require at least LabVIEW full, but it would be trivial to create a subvi that does the same.

0 Kudos
Message 4 of 8
(4,295 Views)

Thank you for that quick reply.

 

I'm afraid to say I fed you a bum steer, or I didn't explain it properly. The data is coming in packets in the form of a 1D array, of n length, (n is unknown) so I guess I would have to use "Array Size" and then step through it in a loop of n iterations?

Cheers

0 Kudos
Message 5 of 8
(4,274 Views)
Solution
Accepted by topic author ASH2020

Just place mean ptbypt (and chart) inside an autoindexing for loop. No need to get the size.

0 Kudos
Message 6 of 8
(4,268 Views)

I'm using Labview full and it works. Excellent.

0 Kudos
Message 7 of 8
(4,267 Views)

Thanks altenbach. Much appreciated.

Cheers

Andy

0 Kudos
Message 8 of 8
(4,264 Views)