LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop program with 2 Event Case

Solved!
Go to solution

I know this has a really easy solution but I can't seem to find it.

I have two event cases in a while loop. I have worked previously with one event case therefore I placed the stopped button inside the event case. However if I have 2 event cases I cant place the stop button in one of them so how can I stop the program then?

If the stop button is outside the cases the program wont stop.

Here's my vi that consists of adding two different values to one output depending on which button is pressed

0 Kudos
Message 1 of 6
(5,015 Views)

Just add a case for the stop button.

Wire a Boolean constrant set to true out of the case to the while loop stop. In all other ceses wire a false.

Message 2 of 6
(4,992 Views)

as attached 🙂

Message 3 of 6
(4,984 Views)
Solution
Accepted by topic author patomated

Add one more value change event case for stop button and wire to while loop conditional terminal.

 

find the attached VI

 

Regards,

S Nagaraju

Message 4 of 6
(4,968 Views)

The solution suggested by "Sonti_11532" is ideal.

Also a alternate method is to simply connect a small constant value (like 10) to the TimeOut Terminal of the Event Structure in the VI posted by you ("patomated').

How it will work is, the event structure will Time Out after that fixed interval. When it Times Out it will check the value of the stop button and then accordingly proceed for the next iteration or stop the loop.

 

Caution : i suggest this only considering there is no other code written in the while loop.


Regards.
Digant Shetty (LV 18.0)
AE, Combined Digilog Systems Pvt. Ltd.

CDSPL LOGO.pngAlliance Partner.png

Message 5 of 6
(4,955 Views)

As an alternative, instead of even having a stop button, you could use the <This VI>->Panel Close event to stop your VI when the user closes the front panel (typically using the X in the top right corner of the window).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 6
(4,929 Views)