LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

for sum

Solved!
Go to solution

Hello,

I'm having a problem trying to sum 200 elements that i read in a for loop, to later obtain the medium value. the value that i am reading is a temeperature, but it oscilates and i need to obtain a medium value so the pid regulator doesn't get "confused" by the oscilations.

can anyone please help me?

0 Kudos
Message 1 of 6
(2,741 Views)

What is your DAQ assistant configured to capture? One sample? 3000? If it's one sample then you should be converting the dynamic data to a number inside the loop, and then simply wire that out of the loop and let auto-indexing automatically create the array for you. Then just use the Mean VI to get the average.

 

You're using a shift register, which will also work, but in this case you have to initialize the shift register, otherwise the next time it runs within your program the shift register will retain the last value it had during the last iteration of the loop.

0 Kudos
Message 2 of 6
(2,701 Views)

Summing the elements in the loop will avoid the need for the array. It looks like you intended to do it that way, but then you'll have to add the new value to the sum. Currently you're adding 0 to the current measurement at each iteration.

Initialize a shift register with 0, add the current measurement at each iteration. Outside the loop divide by the number of samples.

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

yes it's getting one sample at a time.how do i convert the dinamic data to a numeric value? in case you have the time, please modify the attached VI directly. thank you

0 Kudos
Message 4 of 6
(2,663 Views)
Solution
Accepted by topic author Gixxerash

Try something like this. I can't test it here since I don't have the hardware.

 

Message 5 of 6
(2,659 Views)

i will be able to test it tomorrow. thank you for your help, i'll let you know how it played out

0 Kudos
Message 6 of 6
(2,656 Views)