LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sum "n" values and then display average

I have attached a very basic, very simlpe Labview 2011 vi that takes values from a force sensor.   (Yes, I also know that the program name has force mispelled). 

 

The program is recording at 100 hz and displays that value on a graph.   I am also recording the value at that exact frequency as well.

 

I would like to be able to take "n" samples and average them together and display that value.   For instance, while recording and displaying the graph at 100 hz, I would like to take 50 samples at a time and average them and display that value.   This would mean my indicator would change 2 times a second instead of 100 times a second.   I have tried buidling arrays and averaging values, shift registers in a for loop, etc.   I tied mocking all the examples and just couldn't get it to come out right.  It would average the values but would keep displaying at 100 hz.   Any help on this???

 

The average value will basically be used for a quick eye shot calibration before I begin my tests.   Any help is appreciated!

0 Kudos
Message 1 of 6
(3,182 Views)

Why don't you read N samples and simply take the mean of the array?

 

If you want to read only one sample per iteration as you currently do (why?), use Mean ptbypt.

0 Kudos
Message 2 of 6
(3,169 Views)

I tried Mean, but when I hooked my indicator to it on this particular program the indicator still displays at 100hz, not what my mean sample length is.   I would think it would display correctly, but I cannot get it to actually display the sample length average that I want.  

0 Kudos
Message 3 of 6
(3,134 Views)

That makes no sense. If you wire the mean to the output of the DAQmx Read, it will read the mean of all points you acquire and yes, you simply have to set the number of samples to 100.

 

What is the point of the 'co.' and 'sub' controls? The Index Array, For Loop, and Divide by 20 are just silly.

0 Kudos
Message 4 of 6
(3,122 Views)
Actually, that program was where I was trying desperately to get something to work - I did have a bunch of stuff in the "for" loop trying to get something to work. I just went to the lab and used the "mean" and wired it to the DAQmx Read. Guess what - my indicator still displayed at 100 hz instead of 1 hz. I set the sample size to be 100. 100/100 = 1 hz display for the mean indicator. Thoughts on why this isn't working?
0 Kudos
Message 5 of 6
(3,108 Views)

Show us the new code.

 

Nobody can tell 100Hz by looking at the front panel. How did you measure it? Also connect an error indicator to the error wire after the readf operation, but inside the loop. Does it show anything interesting?

0 Kudos
Message 6 of 6
(3,100 Views)