LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop a while loop with a interrupt

I' m using a while with a delay time of 60 seconds to perform a sub vi.
So when I press the stop button it could take in extrem 2 minutes to stop the vi. I want to use something like an interrupt or jump order to stop the vi without waiting for the end of delay time.
How can I create an interrupt in lab view 6.1.
Thanks for help. bye uli
0 Kudos
Message 1 of 4
(3,785 Views)
If the delay is in the calling VI using Wait (mS), you can run a smaller delay multiple times (a while loop inside your main while loop), checking Stop between each of the smaller delays until the smaller delays add up to your bigger delay. See the attached DelayWithStopCheck.vi.

But this technique doesn't stop the sub-VI: it just stops the loop in the main VI which will still run until the sub-VI is done. You could connect the Stop button to a global which the sub-VI checks in a loop to know if the calling VI pressed Stop.
0 Kudos
Message 2 of 4
(3,785 Views)
Instead of the normal wait function, create your own that can be stopped prior to the timeout value. I've attached one such that uses the millisecond timer inside of a while loop to run until either the present timer count is greater or equal to a specified time or a global boolean becomes true. You can do something similar with occurances or other synchronization functions.
Message 3 of 4
(3,785 Views)
> I' m using a while with a delay time of 60 seconds to perform a sub
> vi.
> So when I press the stop button it could take in extrem 2 minutes to
> stop the vi. I want to use something like an interrupt or jump order
> to stop the vi without waiting for the end of delay time.
> How can I create an interrupt in lab view 6.1.

You should probably use the timeout on either an occurrence, or probably
even better would be the notifier. If the timeout occurs, everything is
normal, but when the notifier or occurrence is set, it means that the
loop should skip its operation and finish.

Greg McKaskle
Message 4 of 4
(3,786 Views)