07-14-2011 12:39 PM - edited 07-14-2011 12:40 PM
You can refactor a stacked sequence structure into the beginnings of a state machine using the following steps. Make sure that you do not press CTRL-B until you are done!
Edit: I just noticed that the i terminal is not wired to the case selector in steps 4 and 5. But you get the point.
The next step will be to convert this to a "real" state machine. Create an enumerated typedef with names that you would have given the frames in your stacked sequence structure. Create another shift register and wire constants from the cases to the right side of the shift register. Connect the left side of the shift register to the case selector. Also make sure to wire the error through another shift register.
07-14-2011 02:04 PM
Thank you Steve! I understand how the iteration will drive each case. But what do the shift registry do in the state machine with enumdef??
07-14-2011 03:17 PM
Here is a state machine VI and an enumerated type def for the state. As you can see the enum constant determines the next state. This allows you to jump from one case to any other case which is something that is impossible with a stacked sequence structure. You pass values from one loop iteration to the next with shift registers.
Take a look at the VI and figure out how it works. State machines are a very simple yet powerful concept.
07-14-2011 03:42 PM
You'll eventually wind up using the enum typedef to drive the state machine. Steve just showed you a starting point (and well) but the code at step 5 is still a implementation of a stacked sequence since it can only transition incrementally and the loop must complete all iterations. You'll need to replace the for loop with a while loop as well to get close to this template
07-14-2011 03:45 PM
Ohh I sort of understand now!!! That was inspiring . But I m actually using labview 7.1. Is it possible to convert this VI into an older version?
07-14-2011 03:47 PM
Thanks Jeff! The template will be very helpful!
07-14-2011 04:01 PM
State Machines: Application Design Patterns: State Machines
That article contains an example writte in LabVIEW 6.1.
07-14-2011 04:13 PM - edited 07-14-2011 04:14 PM
@j49sun wrote:
Ohh I sort of understand now!!! That was inspiring . But I m actually using labview 7.1. Is it possible to convert this VI into an older version?
Click on File/New/From Template/Frameworks/Design Patterns/Standard State Machine. I am not sure if it is included in 7.1
07-15-2011 09:06 AM
found it!