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 can I take a take an average of my voltmeter every 10 readings?

Solved!
Go to solution

I would like to be able to take 10 readings of my voltmeter and then take an average of those. I just don't know how you store those 10 readings and then parse them. I suppose I need to build an array but not sure what that would look like. 

80183275e6d456069b106564206a7d53.png

 

This is what I have so far.

0 Kudos
Message 1 of 14
(2,366 Views)

Of course.

 

The easiest way is to add the "Mean Pt by Pt"  function.

 

I don't understand what you are doing with the blue dynamic datatype wire when you are building them into an array of dynamics, and feeding it to a shift register which doesn't seem to go anywhere from the left hand side of the loop.

Message 2 of 14
(2,362 Views)

Well I guess I don't understand the dynamic data data type. I really just want to build one of floats. The shift register is confusing sorry, it is actually the instrument handle for the voltmeter. 

0 Kudos
Message 3 of 14
(2,341 Views)

@crash_override wrote:

Well I guess I don't understand the dynamic data data type. I really just want to build one of floats. The shift register is confusing sorry, it is actually the instrument handle for the voltmeter. 



Ahh yes.  The wires that overlaid each other confused me as to what goes where.

 

As for the dynamic datatype, most people don't understand it.  It was this magic wire NI created that allowed anything to connect to anything, and hid the details underneath.  The problem is that it hid the details so you it is hard to figure out if it is doing what you truly want it to do. 

 

Since you are feeding back and building them into an array, but then doing nothing with that, you might as well get rid of the feedback node and build array.

Message 4 of 14
(2,329 Views)
Solution
Accepted by topic author crash_override

You don't need to store those 10 measurements. Just have a shift register, and keep adding the measurements until you get to 10. Then outside the loop divide by 10 and you have your Average. Like this

 

ShockHouse_0-1592407671871.png

 

Message 5 of 14
(2,328 Views)

I really wished that work but any time I put my read function the values become way too low and ridiculous. I'm not sure why that is!

0 Kudos
Message 6 of 14
(2,294 Views)

@ShockHouse wrote:

You don't need to store those 10 measurements. Just have a shift register, and keep adding the measurements until you get to 10. Then outside the loop divide by 10 and you have your Average. Like this

 

ShockHouse_0-1592407671871.png

 


That's a Rube Goldberg  "pseudo-FOR loop" (fixed number of iterations known before the loop starts).

Have you actually tested this? Shouldn't the shift register be initialized in some way?

Message 7 of 14
(2,283 Views)

@crash_override wrote:

I really wished that work ...


What is "that"?

0 Kudos
Message 8 of 14
(2,281 Views)
Solution
Accepted by topic author crash_override

@altenbach wrote:

@ShockHouse wrote:

You don't need to store those 10 measurements. Just have a shift register, and keep adding the measurements until you get to 10. Then outside the loop divide by 10 and you have your Average. Like this

 

ShockHouse_0-1592407671871.png

 


That's a Rube Goldberg  "pseudo-FOR loop" (fixed number of iterations known before the loop starts).

Have you actually tested this? Shouldn't the shift register be initialized in some way?


You are correct, it was more of a mini example thrown together. If you wanted it to be proper you could just do it like this

ShockHouse_0-1592415814231.png

 

0 Kudos
Message 9 of 14
(2,275 Views)

The code sample shockhouse posted. It would work but for some reason when I try reading the instrument in that loop then the values that it reads go hay wire. Not sure if it's something I'm doing in labview wrong or the device itself and the way it's hooked up.

 
0 Kudos
Message 10 of 14
(2,270 Views)