LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What happens to the while loop iteration counter if it runs unchecked?

I want to use the iteration counter to initialise a value on the first loop of a while statement. ie i = 0, x = 100. Fine. The application I am building will be left to run for weeks or months on end without stopping (hopefully :¬)). What happens to the iteration counter in this situation? Does it reset to 0 or what? I don't want it reinitialising any values while the loop is running other than when it starts.

I set up a while loop to try to figure out what happens and the iteration counter stops at 2147483648 which is 2^31 - 1.

Any help would be appreciated,

Thanks,

Niel.
0 Kudos
Message 1 of 6
(4,141 Views)
I believe the iteration counter stops after it reaches its max value but the WHILE loop continues. If you plan to use the iteration counter beyond its max, you'll need to reset it.
0 Kudos
Message 2 of 6
(4,141 Views)
Thanks to all who posted answers,

Niel.
0 Kudos
Message 6 of 6
(4,141 Views)
The iteration counter is an I32 so that agrees with the number you saw. Most of my acquisition loops were in the 10's of msec range so I never saw the problem (never had anything run for a couple of years continuously). If it's a concern, you may have to come up with a different scheme for initialization. A state machine architecture comes to mind as one alternative.
Message 3 of 6
(4,141 Views)
It might be something you already looked at, but perhaps it's an option to perform the initialization outside (before) the while loop. That way it will be initialized correctly only once, no matter what the iteration counter does.

Of course if you need the counter for other purposes than initialization you might have the same problem...

Note that a lot of the timer functions also overflow after a certain time (I believe 24 or 48 days?) so be careful running very long loops (but you already knew that probably).
0 Kudos
Message 4 of 6
(4,141 Views)
As long as the value is not counter related, why don't you wire it to the loop?
0 Kudos
Message 5 of 6
(4,141 Views)