LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupting a while loop

I have a while loop containing a number of subVIs, that takes several seconds per iteration.  The exact time taken varies based on the subVIs communicating with a number of devices via GPIB, RS232 and ethernet.

 

I have the conditional terminal of the loop wired to a stop button.  So under normal operation, the user presses STOP, and this this is read at the the end of that iteration.  There is then one more complete iteration before the loop terminates.

 

Is there a way of quitting the loop instantly.  I.e. not having to wait for the conditional terminal to go TRUE?

 

Cheers,

Dan

Dan
CLD
0 Kudos
Message 1 of 4
(2,595 Views)

1.png

 

Edit: Make sure you closed all references of any VISA functions if used.

Message Edited by Madboy(Mathan) on 09-25-2009 04:58 AM
0 Kudos
Message 2 of 4
(2,592 Views)

My advice is to read the Stop button in each one of those VI's. Have each VI contain a Stop In and Stop Out. When the VI receives the Stop, it can send out it's own Stop output to keep the subsequent VI's from running. If all the VI's are wrapped in a case statement so that they don't run if Stop is True, then that second iteration will still happen, but it won't matter. Make sense?

 

The Stop function is the same as hitting Abort. Risky.

Richard






0 Kudos
Message 3 of 4
(2,556 Views)
A bit more elegant and much less abrupt would be to use a state machine. So, instead of going to the next instrument read state, you go to the stop state and do any cleanup there.
0 Kudos
Message 4 of 4
(2,553 Views)