LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Average a limited number of array data

Solved!
Go to solution

hi. I am a Labview beginner.

I am receiving signals from two channels through DAQ equipment and calculating the time difference (dt) in real time. I want to collect 6 values (dt) received like this and average them to show them.
I want to collect 6 values, show the average, initialize, collect 6 values again, and repeat.

Could you possibly help me?

thank you.

0 Kudos
Message 1 of 6
(760 Views)

I don't like your block diagram.

It's ugly.

Zigzag wires everywhere.

You're supposed to care about the quality of your work.

 

Anyway, attached is an averager that I made a long time ago.

0 Kudos
Message 2 of 6
(738 Views)

This seems to be a continuation of your earlier thread (It would really help to keep everything in one place, or at least provide a link for context since the earlier thread is marked as solved!).

 

So from a set of two averaged arrays you get a singe scalar (dt) that you want to average over six iteration of you while loop, then start over. The easiest would be to use "Mean ptbypt" with a history of 6 and you will get continually the average of the last six points.

 

altenbach_0-1705678792489.png

 

 

From a pure programming point of view, your array handling attempt is pure Rube Goldberg. Appending a scalar to an empty array will just give you an array with one point and that array will never grow. For that you need to keep the array in a shift register as we already do in the inner loop.

 

You could also use an inner FOR loop with six iterations, autoindex the dt at the output tunnel , and take the average there. There are many possibilities.

 

 

 

0 Kudos
Message 3 of 6
(724 Views)
Solution
Accepted by topic author hurang

Here are some simplified ideas how to eliminate all that duplicate code...

0 Kudos
Message 4 of 6
(703 Views)

I ran my block diagram with reference to your code, and if I set the window size to 10, it shows a value similar to the average before all 10 values are received. I wonder why.

0 Kudos
Message 5 of 6
(647 Views)

The ptbypt Mean will average the data received so far until 10 points are available.

0 Kudos
Message 6 of 6
(635 Views)