LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what is this?

 

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.

 

Capture.PNG

 

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.

=====================
LabVIEW 2012


Message 21 of 29
(334 Views)
Highlighted

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??

0 Kudos
Message 22 of 29
(319 Views)
Highlighted

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.

 

State Machine.png

=====================
LabVIEW 2012


Download All
0 Kudos
Message 23 of 29
(310 Views)
Highlighted

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

original.png

"Should be" isn't "Is" -Jay
0 Kudos
Message 24 of 29
(304 Views)
Highlighted

Ohh I sort of understand now!!! That was inspiring Smiley Surprised. But I m actually using labview 7.1. Is it possible to convert this VI into an older version?

0 Kudos
Message 25 of 29
(303 Views)
Highlighted

Thanks Jeff! The template will be very helpfulSmiley Happy!

0 Kudos
Message 26 of 29
(301 Views)
Highlighted

State Machines: Application Design Patterns: State Machines

 

That article contains an example writte in LabVIEW 6.1.

Message 27 of 29
(295 Views)
Highlighted

@j49sun wrote:

Ohh I sort of understand now!!! That was inspiring Smiley Surprised. 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

=====================
LabVIEW 2012


0 Kudos
Message 28 of 29
(291 Views)
Highlighted

found it!

0 Kudos
Message 29 of 29
(267 Views)