07-12-2011 05:35 AM
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?
Solved! Go to Solution.
07-12-2011 08:56 AM
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.
07-12-2011 09:13 AM
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.
07-13-2011 10:19 AM
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
07-13-2011 10:30 AM
Try something like this. I can't test it here since I don't have the hardware.
07-13-2011 10:34 AM
i will be able to test it tomorrow. thank you for your help, i'll let you know how it played out