LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

One stop button to control multiple loops?

I want to use on stop button to stop mutilple while loop at the same time.  But if I put the stop button outside the while loop, it is functional.

Is there any way to do that?

Thanks

0 Kudos
Message 1 of 4
(11,219 Views)

Set the stop button mechanical action to Switch When Pressed (or Released).  Create a local variable for each loop you want to stop minus 1.  Put the stop button in one loop and put a local in each of the others.  Wire all to the stop signs.  Pressing the stop button will stop all loops.  You will have to set the stop button back to False at the end of your code.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 4
(11,215 Views)

cguan wrote:

But if I put the stop button outside the while loop, it is functional.


 

 I don't think "functional" is the right word here. 😄
 
I often use event structures, e.g. as in my example posted here. This allows you to keep latched mechanical action for the stop button.
 
For a queued state machine, you would use the error to stop the loop that waits for the queue. Here is an example for that.
 
The most appropriate method really depends on the situation. Can you post some code? 
 
0 Kudos
Message 3 of 4
(11,192 Views)

As a suggestion, you might try doing a search before posting the question -- this question has been asked and answered many times.  There are lots of different ways that you can use a single button to stop multiple loops.

 

Here is a good discussion on various ways to accomplish what you want to do.

Message 4 of 4
(11,179 Views)