From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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)

Solved!
Go to solution

Hello

How to make labview program to get average value of 200 reading from multimeter (I using using loop) to read voltage from mulmeter  but I like to get average value of all of 200 reding how can I do that?

 

Thanks

Wee

0 Kudos
Message 1 of 26
(51,354 Views)

Hi Wee, 

 

If you don't need a running average,

1) index the output of the loop to create an array of numbers.

2) Pass the Array through the Add Array Elements function (Numeric palette)

3) Divide the result by the 200 (or use the iteration count of the loop +1 as the divisor to allow you to change the number of loops you run).

 

If you need a running average I recommend you queue the data into a second loop and calcuate the average there as the calculation will slow down your acquisition time.

You can build an array of the elements you have acquired so far and do the above process as often as you want.

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 2 of 26
(51,348 Views)

I would use a For loop to do this calculation.

Wire a control, set to 200 and allows for varability, to the Loop Count input of the For loop.

Make the reading from the multimeter in the For loop.

Use a Shift Register, initialize it to zero and make sure it is large enough to store the whole sum, and Add the current multimeter reading to the sum of all the previous readings.

When the loop exits divide the result by the Control that is wired to the Loop Counter.

This method saves memory instead of using an array and Add array elements.

 

Message 3 of 26
(51,344 Views)

WillD wrote:

I would use a For loop to do this calculation.

Wire a control, set to 200 and allows for varability, to the Loop Count input of the For loop.

Make the reading from the multimeter in the For loop.

Use a Shift Register, initialize it to zero and make sure it is large enough to store the whole sum, and Add the current multimeter reading to the sum of all the previous readings.

When the loop exits divide the result by the Control that is wired to the Loop Counter.

This method saves memory instead of using an array and Add array elements.

 


 

Pointer for you Will.

 

Unless you need the data inside the actual loop, Indexing out of a For loop is far more efficient than initialising a SR and passing the data round each time.

Initialise array for a while loop, but never for a FOR loop unless you need all the data inside for a calculation - it's less efficient.

 

(Incidently I was thinking of a using FOR loop when I wrote my reply - I neglected to mention it as I assumed it was a given due to the number of iterations being known and it not being a requirement to run in a Real Time environment.)

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 4 of 26
(51,339 Views)
Solution
Accepted by topic author weerapol

Thanks for the pointer James, however I believe I was misunderstood.

I have attached a snippet for clarification as I never described the usage of an array.

 

 

200SaAvg.png

Message 5 of 26
(51,326 Views)
Nice idea as it allows you to do the running average inside the loop without the overhead of an array if you use I+1 as the divisor.
CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 6 of 26
(51,310 Views)

Another idea with less programming - take advantage of the "free" array that comes with a Chart - i.e. the  History Data.

 

1) Wire your DMM data to a Chart. (You can set the chart to invisible if you don't plan on using it in the GUI).

2) Set the Chart History Length to 200 (right click on the chart, click on Chart History Length...)

3) On the block diagram, use the History Data Property Node, wire it to Mean.vi, and you're done.

 

Easiest running average ever.

 

Message Edited by Broken Arrow on 04-07-2010 11:36 AM
Richard






Message 7 of 26
(51,306 Views)

Hello,

Could you be more specific with the chart function, I can't seem to find it anywhere in labview. Thanks.

0 Kudos
Message 8 of 26
(51,211 Views)

Front panel controls palette under Graph.

 

 

Chart.PNG

 

- tbob

Inventor of the WORM Global
Message 9 of 26
(51,199 Views)

csbvs wrote:

Hello,

Could you be more specific with the chart function, I can't seem to find it anywhere in labview. Thanks.


 

There is no "chart function", just a chart indicator. Place it on the front panel - location shown by tbob above. Then, from the block diagram, right click on the indicator to create the property node - see attached picture. My example also shows the use of Mean.vi, located Mathmatics > Probability & Statistics. I hope this answers yourquestions.
Richard






0 Kudos
Message 10 of 26
(51,174 Views)