LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to monitor the E-Stop button

Hi, I'm programming for a machine. The machine has a E-Stop (hardware) button. I wired the button to a digital input.

The way I monitor the E-stop in my program is to make a Do-While loop separated from the main part of my program. Inside this Do-While loop, a boolean will be toggled based on that digital input status (high or low). The main part of my program will respond to the E-stop button based on the status of the designated boolean.

One disadvantage of this approach is there could be too many Do-While loop (currently the main part already has two While loops). Any other way to monitor that E-stop button?
0 Kudos
Message 1 of 6
(2,651 Views)
Unfortunately, you have to continuously read the digital input to get the E-Stop value, which has to be done inside a while loop. I don't think there is any other way. Just be sure to put some timer (>=100msec) inside the loop to allow the processor time to do other processing.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 6
(2,651 Views)
The best way to achieve this is to use event structures. You could just put the two main loops inside the event structure which is triggered by you boolean value change.
0 Kudos
Message 3 of 6
(2,651 Views)
But I still need to use another While-Loop to monitor the digital input though, right?
0 Kudos
Message 4 of 6
(2,651 Views)
You still need the loop to monitor the digital input. Your program has no way of knowing when the event happens unless you monitor the digital input inside a loop. The event structure is for front panel events or user programmable events, not external hardware events.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 6
(2,651 Views)
Well, you will, as far as I know always need a While or For loop surrounding your entire program unless you only want it to run 1 time.
0 Kudos
Message 6 of 6
(2,651 Views)