LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use event to jump to a case in a state machine

How would I use an event to force a jump to a certain case in a state machine? For example, in the attached VI, I have a state machine that will simply blink a green LED indicator on and off for five seconds. I have a case in which the LED turns red for five seconds and a button which I would like to use to jump to this case. In other words, if the state machine is currently halfway (2.5 seconds) through my "Green_Light_ON" case when the button is pressed, I would like the state machine to immediately jump out of the "Green_Light_ON" case and into the "Red_Light_ON" case. This is not my ACTUAL VI, but it's a simplified example that will work for finding my solution. Thank you very much in advance for your help! 

0 Kudos
Message 1 of 3
(2,593 Views)

Sounds like the classic "Producer-Consumer (Events)" design pattern.  File>>New...>>VI from template.  There is a good shipping example as well as the comments on the template vi

untitled.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 3
(2,580 Views)

I would also suggest investigating Queued State Machines, where you can build "macros" which will carry out a sequence of States based on how the states are queued up. Check out the JKI State Machine, it is a classic example.

 

 

Richard






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