Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

stop a while loop at the same time as in another while loop

Hi! I'm facing a problem in stopping a while loop for grab acquisition process straightaway or at the same time when i stop the outer while loop. The grab acquisition while loop is located in a while loop of my whole program. There is a power button in my big while loop. and a measure button in the grab acquisition while loop. I want to stop the grab acquisition while loop together when the power button is turned to OFF. The problem is that the program will only abort after another click of Measure button when the Power button is OFF.
0 Kudos
Message 1 of 3
(3,299 Views)

That is one of the problems with nested while loops.  I would recommend restructuring the code to eliminate the second loop.  However, there is a quick and dirty method to do what you want:

Move the Exit button inside your inner loop.  Use a boolean OR and stop the inner loop if either Measure or Exit are pressed.  Wire the Exit output out to your outer loop as well, so it will stop the outer loop.

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 3
(3,294 Views)
Thanks Mr Bruce. I'll Try it out.
0 Kudos
Message 3 of 3
(3,283 Views)