From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

maximum while loop iteration

Hello,
         I have a doubt regarding while loop,  suppose if we run a while loop continuously after its maximum no. of iteration whether it will hang/stop or it will roll back from the starting zero. For this I had tested a while loop, when it reaches the maximum I32 value it got hang. But in the NI site they have provided information given below....
 
Problem: I am using a While or For loop in LabVIEW, and I was wondering what happens once I exceed the maximum loop iteration count (2147483647). Does the loop stop execution? Does the count roll over?

Solution: The loop count will rail at the maximum I32 value (2147483647), yet the loop will continue iterating. If you have an application that nears the maximum loop iteration count, you need not worry about the loop execution terminating. However, the count will no longer be accurate after it rails at the maximum value listed above.
 
                But actually this is not happening. when it reaches the maximum value the program hangs and its not going to the next iteration.  Is any way to refresh the while loop to afresh from its initial zero value.
 
Labview Lovers
0 Kudos
Message 1 of 5
(5,792 Views)
In what version did you test it?
Can you publish the test code?
0 Kudos
Message 2 of 5
(5,781 Views)

I would have to agree that it functions correctly in every version I saw and that we would need to see an actual VI as an example.

Note that if you want to create your own counter, you can simply use a 64 bit integer and increment it in each iteration using a shift register.


___________________
Try to take over the world!
0 Kudos
Message 3 of 5
(5,773 Views)
Also, do you actually get close to the limit? Running a loop at 100Hz should take about 8 months before reaching that limit. Your loops should definitely have some kind of wait if they are going to be running for a long time to allow the OS to better manage the CPU consumption.

___________________
Try to take over the world!
0 Kudos
Message 4 of 5
(5,765 Views)
My simple test shown that after reaching the maximum the loop count will stay at maximum value and loop will be continued.
This need approx 4 minutes on my PC.
Otherwise its very easy to extend functionality with simple functional global (or just with Shift Register as tst mentioned).
See attached example.
 
best regards,
 
Andrey.
 
Download All
0 Kudos
Message 5 of 5
(5,763 Views)