LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Moving average VI

1. If those signals are on the same DAQ card, they will need to be in 1 task.  Which means you will only have 1 DAQmx Read (configured for N Samples, N Channels).  You can use Index Array to separate the waveforms.

 

2. Use a FOR loop and Mean.vi to average the two samples.

 

3. Use Build Array to build up an array of waveforms.  That array can then go to your chart and have all of your plots together.


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
Message 11 of 15
(1,753 Views)

Thank you again. I think we are almost there.

 

My only (perhaps last) concern is that even though I have given the length of average as 180 samples, the average signal starts almost as soon as the real signal.

 

Should not the average signal start only when the 180 samples are collected.

 

The timed loop has 1000 ms time period.

 

Please see the pictures attached.

 

FrontPanel.PNGBlockDiagram.PNG

 

Thank you so much again for your guidance. I cherish your advice a lot.

0 Kudos
Message 12 of 15
(1,735 Views)

Please use block diagram cleanup.  There are too many tangled and backwards waveform wires.

 

Get rid of the constants on index array.  They will give you elements 0, 1, 2, 3, .... by default if unwired.

 

You could put the waveform chart in a case structure so it only updates once 100 iterations have passed.  Or feed it NaN until 100 iterations have passed.  Or you could initialize the point by point with 100 elements of the first data point to fill the buffer.  It all depends on what you want to have happen until the first 100 iterations have passed.

0 Kudos
Message 13 of 15
(1,732 Views)

If you want a running average in real time, use something like this (which averages 5 samples):

ra.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 14 of 15
(1,729 Views)

To add to what RavensFan stated, stop using the From DDT.  It is literally doing nothing for you here.

 

And didn't I tell you to get rid of that Timed Loop?

 

As far as the averaging, that is just how the function works.  It sums up to your desired number of samples and divides by that number of samples.  If you want to ignore them, use a case structure.  It would be easier if you just read the number of samples you want in the average each iteration and then you just have to not update on the first iteration.  Again, do not use a Timed Loop if you do this.


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 15 of 15
(1,722 Views)