annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

for sum

Résolu !
Accéder à la 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 Compliments
Message 1 sur 6
2 862 Visites

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 Compliments
Message 2 sur 6
2 822 Visites

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 Compliments
Message 3 sur 6
2 812 Visites

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 Compliments
Message 4 sur 6
2 784 Visites
Solution
Accepté par l'auteur du sujet Gixxerash

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

 

Message 5 sur 6
2 780 Visites

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

0 Compliments
Message 6 sur 6
2 777 Visites