LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Exit" button used in multiple sequence frames

Solved!
Go to solution

I am hoping there is a more elegant way to do this...

 

See the attached VI for a vastly-simplified program that typifies what I am trying to accomplish.  Basically, I've got one button that I want available in multiple sequence frames.  In this case, I have used an "Exit" button.  When pressed, the program passes through any remaining sequence frames until it ends.  The final frame "unclicks" the "Exit" button.  This final frame is necessary because I had to set the mechanical action of the Exit button to "Switch When Released" because I used local variables in all sequence frames after the first one.

 

Is there a way I can accomplish the same functionalities of this program without using local variables and/or while setting the mechanical action of the "Exit" switch to "Latch When Released?"  I am specifically looking for solutions which will work in multiple frames of a stacked sequence structure (I realized there are ways to turn the three lights on without using a stacked sequence structure, but I am not interested in doing so).

 

Any help would be greatly appreciated!  Thanks!

 

 

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 5
(3,029 Views)
Solution
Accepted by topic author diarmaede

For something where you are looking at a sequence of steps, you really should be using a state machine architecture.  (Search the forums for examples.)

 

Having multiple event structures with duplicated cases in different frames of a stacked sequence structure (it would be slightly better if you used a flat sequence structure instead), is only asking for trouble down the road.

0 Kudos
Message 2 of 5
(3,027 Views)

I agree that a State Machine is the way to go.  Forget about sequences.  You can see how they make life hard for a programmer.  Study the attached vi.  I've taken your code and converted it to a state machine.  Now the stop button has the proper mechanical action and you can stop the program at any time.  No need to let the sequences play out in order.

 

 

- tbob

Inventor of the WORM Global
Message 3 of 5
(3,011 Views)

hi dia,

So many discussion was finished regarding this multiple Event structure. In your code totally 3 event structures you are using. But in a program only one Event structure is enough to operate properly. Because in LabVIEW only one event queue is there in built. So if you use more than one event structure LabVIEW will got confused and it will get queued up, even though there is no state and it will be masked some time. That's why your code taking so much of time to exit. Some times it seems like hang...

Try this VI...

 

<<Kudos are welcome>>

 

0 Kudos
Message 4 of 5
(2,999 Views)

Thanks all!  The whole concept of a State Machine opens up brave new worlds.

 

Cheers,


Forbes

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 5 of 5
(2,963 Views)