04-07-2010 10:21 AM
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
04-07-2010 10:38 AM
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
04-07-2010 10:55 AM
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.
04-07-2010 11:05 AM
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.)
04-07-2010 11:16 AM
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.
04-07-2010 11:31 AM
04-07-2010 11:35 AM - edited 04-07-2010 11:36 AM
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.
04-13-2010 04:22 PM
Hello,
Could you be more specific with the chart function, I can't seem to find it anywhere in labview. Thanks.
04-13-2010 05:09 PM
04-14-2010 08:08 AM
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.