LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make labview program to get average value of 200 reading from multimeter (by using loop)

Thanks for the response, they were very helpful. I'm fairly new to the labview game:)

I was wondering though if there is a good technique to take a discrete average in labview? Meaning, say I am continuously sampling a signal, I want to average the value of the first twenty samples, then the next twenty, and so on without including any of the previous data points in the subsequent averages. Thanks

Message 11 of 26
(12,629 Views)

One way to do this would be through the use of multiple shift registers.  I've done this in the past.  But it wasn't very neat code, and I don't imagine it's the most efficient way to do things.  It did work though.

 

running average.jpg

 

I didn't initialize the shift register here....you should do that. 

 

Another option would be to use a circular buffer that only stores X number of points.    http://zone.ni.com/devzone/cda/epd/p/id/5883    http://decibel.ni.com/content/docs/DOC-3414

---------------------
Patrick Allen: FunctionalityUnlimited.ca
Message 12 of 26
(12,626 Views)

csbvs wrote:

Thanks for the response, they were very helpful. I'm fairly new to the labview game:)

I was wondering though if there is a good technique to take a discrete average in labview? Meaning, say I am continuously sampling a signal, I want to average the value of the first twenty samples, then the next twenty, and so on without including any of the previous data points in the subsequent averages. Thanks


 

Here is a way to specify how many samples to take the average of.  Once the avg is taken, the array is emptied and another sampling will be gathered until the number of samples is reached, and so on.

 

mean.png  The false case just has a wire from input to output.

 

 

- tbob

Inventor of the WORM Global
Message 13 of 26
(12,613 Views)
The fun starts when you want a running discrete average - i.e. mean of the last 20 samples! Smiley Tongue
CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 14 of 26
(12,581 Views)

 

I wired exactly what you wrote, but it is now giving me an error for bad terminal ?

 

This is my first time using labview 2010 for controller design

 

Any comments are greatly appreciated

 

Thanks,

Message 15 of 26
(11,664 Views)

@sadfasdfsd wrote:

 

I wired exactly what you wrote, but it is now giving me an error for bad terminal ?

 

This is my first time using labview 2010 for controller design

 

Any comments are greatly appreciated

 

Thanks,


Your code is not exactly as mine.  I'm using an array of DBL and you are using the History of the Waveform Chart.  Even the colors are different.  If you read the Details section of the Error List window, you will see that the data types don't match.  The output of Waveform Chart History is not an array of numerics.  You need to extract the array of numeric values from the waveform chart.  There is a funtion in the waveform palette that will extract, T0, dT, and Y from the waveform.  Use the Y output to wire into the Mean function.

 

Also you have a race condition.  Don't use the property node.  It will get read before the waveform chart is updated because there is no data dependency there.  As soon as the code starts, the History will output its value, even before a history if formed.  Your code should have some type of loop to gather data into the waveform chart.  Wire the output of your subtraction funtion to the loop edge and set indexing enabled.  This will produce an array of numbers and you can wire this into the Mean function.  You should look at my code again and study every part of it.

 

- tbob

Inventor of the WORM Global
Message 16 of 26
(11,647 Views)

The other difference is that tbob used the Mean function.

 

Scrambled letters, you used the Mean point by point function.  Since it it does the calculations one point at a time, it only takes a scalar input, thus your error message.

0 Kudos
Message 17 of 26
(11,642 Views)

@Ravens Fan wrote:

The other difference is that tbob used the Mean function.

 

Scrambled letters, you used the Mean point by point function.  Since it it does the calculations one point at a time, it only takes a scalar input, thus your error message.



good catch, RF.  I didn't even notice that myself.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 18 of 26
(11,628 Views)

This worked great.. better than other solutions and a quick fix. I just had to convert the data from waveform chart into double. Thanks Broken_Arrow

0 Kudos
Message 20 of 26
(6,977 Views)