LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Design a kill switch

Hey, I am trying to incorporate a kill switch into this VI.  I have made an attempt but it will not exit the wait time in the wait function when I want to turn all of the values to false immediately instead of waiting for the wait time to expire.  Can anyone help me with this?
0 Kudos
Message 1 of 3
(3,614 Views)

That's because the value of the switch is read immediately upon starting the loop.  So you have to wait almost 60 seconds for that loop iteration to end.  Then the loop will begin its next iteration at which time the now False state of the button will be read (logic seems kind of backwards).  But then you have to wait another 60 seconds because that iteraiton of the loop needs to complete.

 

What you need to do is put a while loop inside of there that continually reads the state of the Kill button with a small wait statement to keep from eating up CPU cycles.  Use the Elapsed Time express VI.  Now have that inner while loop stop when either the Elapsed Time Timer goes true, OR the Kill button goes to its False Kill state.  Now the Kill button will be read very frequently and will seem to respond immediately.

0 Kudos
Message 2 of 3
(3,590 Views)

The wait time won't prematurely expire on its own.  You need to code up a time-monitoring loop with maybe a 10ms internal wait time (depending on your timing requirements).  Something like the following without the reference stuff (that got thrown in because of the way the new code snippet feature works, just replace it with a local variable pointed to the kill switch).

 

timeLoop.png

0 Kudos
Message 3 of 3
(3,588 Views)