LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

add values to one variable in a loop

Hello,
I have a while loop where I read a counter and get values.
Now I want to add all values to one variable. I think an array won't be good because
the loop can run a long time and an array is limited.
And the end I want to have the sum of all values.
I tried to use shift registers.
But how can I store the value of the first loop-cycle in a variable and on
the second loop-cycle take this stored value and add the new value and so on?

Another problem that is maybe more difficult, is that I need the max and min value
of all values that has been read.
That means I need a variable which stores the current value. Then I have to compare the stored
with the next value and maybe exchange both.

I would be thankful fo
r any hints.

best regards Thomas
0 Kudos
Message 1 of 5
(3,196 Views)
Hi Thomas,
as you stated you should use shift registers.
I attach an example that simulates what you need.
Let me know if it is clear.
Good luck,
Alberto
Message 2 of 5
(3,196 Views)
Attached is a picture of a code that does what you want; it calculates the sum of each value, it finds the minimum and maximum (and average)...and it does not create any arrays.

The value source and the condition to stop the loop is what you need to change...In addition you might want to see preliminary values...if so then add indicators inside the loop.
Message 3 of 5
(3,196 Views)
Hi Alberto,

thanks a lot for your fast answer. That was exactly that what i needed.
I already tried to use shift registers but I doesn't worked so far. There was an error in reasoning.
Thanks.

Regards Thomas
0 Kudos
Message 4 of 5
(3,196 Views)
Hi,

thanks a lot, too.

Regards Thomas
0 Kudos
Message 5 of 5
(3,196 Views)