Showing results for 
Search instead for 
Did you mean: 

Trouble with state machine tutorial

Go to solution

New member here. I am trying to replicate a tutorial. 

As far as I know I did everything right. But it does not seem to work.

Can someone help me troubleshoot. I would really appreciate that.

State diagram I am trying to replicate is here:





Download All
0 Kudos
Message 1 of 5
Accepted by topic author stooges

Well, the problem is obvious.  You're trying to get a beer out of a coke machine.  Smiley Very Happy


But seriously... You need to use the SAME enum for all the enums and select the right value.  You just made new ones that have the right word.  BUT, they will always output a 0 since that's the only value they contain.  Use the first one (on the left side) to replace all your enums in every state and select the right values for them by opening the pulldown.


Also, you are not actually reading you shift register.  There is a tunnel underneath the left one that is connected, NOT the shift register.  You need to fix that or every loop will just go back to start.


Honestly, that is one crappy tutorial.  I would look at the state machine that you can open though the start menu or the State Machine Fundamentals example.  I'll look around and see if I can find something better as well...

LabVIEW 8.5.1 - 2019 Pro Dev
0 Kudos
Message 2 of 5

Enums for state machines should ALWAYS be based on a typedef!


That "tutorial" doesn't even talk about that.  Because every case will have an enum constant.  What happens when you want to add a new state?  You'd have to go and add that state to each and every instance of that constant.


OR if it was a typedef, you'd just add it to the typedef enum control and all controls, indicators and constants would all update automatically

0 Kudos
Message 3 of 5

Yeah, I was going to mention type-defs but decided to hold off until he got the basic SM running.  They are critical though (esp. for defining SM states).  That NI tutorial is the only one I found that doesn't start out with making a type-def for all the states. Smiley Sad

LabVIEW 8.5.1 - 2019 Pro Dev
0 Kudos
Message 4 of 5

I think it worked… Thanks now I will look into type def.


0 Kudos
Message 5 of 5