LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can loop counters be modified in real time?

I would like to be able to change an incrementing loop counter to decrementing while running. Is it possible? If not, is there another solution?
0 Kudos
Message 1 of 4
(2,904 Views)
All LabVIEW loop counters are incrementing. To change to decrementing you need to know the number that you are decrementing from and then subtract the counter from that. If you want to count up and then count down (or vice versa) in the same loop then you can have a case structure which decides which way to count, but you'll have to precisely define how you want the increment/decrement to work (do you want it to reset, etc.) and subtract off appropriate values. For instance, if the loop has counted up to 100 and you want to start decrementing from 100 to zero then you want to subtract 100 from the index and then subtract this from 100 to get your modified index.

Hope that helps.

John
0 Kudos
Message 2 of 4
(2,904 Views)
Just use a variable in a shift register initialized to your desired starting value, then increment or decrement it for each iteration as needed by your code.

This is much more flexible, negative numbers are allowed, you can even use double precision or complex variables and arbitrary increment values.
Message 3 of 4
(2,904 Views)
Here's a LabView 6.1 example that displays an iteration count down for a For loop and a While loop.
The loop iteration terminal always counts up. You subtract the iteration (+1 since interation starts at 0) from the known number of total loops to get your count down.
0 Kudos
Message 4 of 4
(2,904 Views)