LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help me with a state machine design

I have a little bit of a problem.  I have a system with several modes, each selected by the user and called with a case structure.  Each case in the case structure is its own state machine with a few states (like 4-6).  Now here's the catch.  I need one of the states within one of the modes to call and execute an entirely different mode (and all of its states) without actually changing the mode command, and to do so every iteration until I jump out of that state into another state within the first mode.
 
Is there a simple way to do that that I'm just not thinking of?
 
Lee Jay
0 Kudos
Message 1 of 3
(2,617 Views)

Lee, my first thought would be to use just a big state machine.  For example if each mode needs 4 states, mode 1 gets states 0-3, mode 2 get states 4-7, and so on.  This way, if you need to change modes in the middle of another mode, you just direct the state selector to the state that starts the mode.  (If that makes sense).  It's not real elegant, but it works fairly well as you still maintain the flexibilty of the state machine design, including the ability to add and rearrange cases. 

Don't forget you can use any method to select the cases, including strings, so you have full flexibility with how you setup case select.

Troy
0 Kudos
Message 2 of 3
(2,596 Views)
Don't know why I didn't think of this in the first place, but why not just move the actual code from the mode that needs to be called from the state into a sub-VI and just call it from both places?
 
Lee Jay
0 Kudos
Message 3 of 3
(2,581 Views)