LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

making sequence structures a state machine

Hey I would like some help I need to work on changing my code and get rid of the flat sequence structure and replace with a state machine I have attached my code at an earlier state but would like some input on changing it over to a state machine in the sequence at the bottom of the code this program is used to cycle a valve and the sequences need to be done in order .any input would be great.

 

 

0 Kudos
Message 1 of 2
(2,109 Views)

Right click on the Flat Sequence and pick Replace with Stacked Sequence  (never would have thought I'd say that.)

Right click on the Stacked Sequence and Replace with Case Structure.

 

Now a lot of wires will wind up broken.  So you'll need to hunt them down and fix them.  Those wires will probably need to go to shift registers so there values are maintained for the next loop iteration.  Keep a copy of your original VI so you have something to refer back to.

 

Create a Typedef Enum and define what your states will be.

 

Start wiring the Enum into a shift register at the left of the loop, then into the selector of the Case Structure.  Rename all the cases to what their respective state should be.

 

Wire enum constants in each case to direct what the next case should be.  It will run out of the case structure to the right hand shift register.

 

Keep working and cleaning still everything is fixed.

 

Try running your VI to see if it behaves like it originally did.

 

Now you are safe to start making modifications to make it behave like you really want it to.

Message 2 of 2
(2,107 Views)