LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

on/off boolean

How can I get my On/Off button to stop the VI?
0 Kudos
Message 1 of 13
(4,427 Views)
You could have your entire code in a while loop. Then wire the on/off to the Stop sign. Your code will run continuously in the while loop until the on/off turns TRUE. If you don't use a while loop, the on/off serves no purpose, your code will run once until the end and then stop on its own.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 13
(4,419 Views)
Put everything in a while loop.

Right click on the loop condition and set it to stop when true (stop sign), and wire your button to the stop sign.

The attached vi prints random numbers until you push stop, then the vi stops.
0 Kudos
Message 3 of 13
(4,414 Views)
Your example code does not make a lot of sense. Too many broken wires, loose ends, and controls with hidden labels. Too little information to really guess your true issue. Why don't you attach a simplified version of your VI?

Since you have no while loop on the diagram, it almost seems to me that you are running your code using the "continuous run" button. If you want to stop it in this scenario using a FP control, you would need to wire it to a case structure that contains a "Invoke node: Abort VI" for the current VI in the true case.

Of course the proper way is to use your code inside a while loop and run it with the normal run button. The continous run button has no legitimate use outside debugging.
Message 4 of 13
(4,390 Views)
sorry guys I didn't show the whole VI.
Take a look at what I have and let me know how to connect the on/off button.
0 Kudos
Message 5 of 13
(4,355 Views)
It has to be inside the while loop.
0 Kudos
Message 6 of 13
(4,350 Views)
At run the on/off boolean(marked) to come on which is great but the run also stops.
I don't want the run to stop until I command it to with the on/off boolean.
What is wrong with my VI?
0 Kudos
Message 7 of 13
(4,321 Views)
I don't understand what you're doing with the local of it. It probably shouldn't be connected to anything. If your mechanical action is set to Latch When Released, simply clicking the button will stop the while loop. This makes it true momentarily. It has to be false when entering the while loop. Otherwise, the while loop will only execute once and then stop.
0 Kudos
Message 8 of 13
(4,313 Views)
I was using the variable to turn the push button on when I command it with continue element. Which works fine.
But at the same time it turns the VI off.
How can I use a push button with an led to operation on and off in my set up?
I don't want the VI to work only once. I want it to keep running untill the push button (stop) is pushed.
0 Kudos
Message 9 of 13
(4,303 Views)
You logic is wrong. You've got the while loop set to terminate when true so setting your run/stop to true terminates the loop. You don't have to do this. The simplest thing is just have a button labeled stop and don't worry about the local. Or, if you want something more complex, you label the false case of your run/stop "run" and invert the logic setting the local so that it's set to false at the beginning, or you invert the input to the OR statement so that changing the run/stop to false terminates the while loop.
Message 10 of 13
(4,298 Views)