From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with state machine tutorial

Solved!
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: http://www.ni.com/tutorial/7595/en/

 

 

 

 

Download All
0 Kudos
Message 1 of 5
(2,411 Views)
Solution
Accepted by 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 Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 2 of 5
(2,395 Views)

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
(2,370 Views)

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 Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 4 of 5
(2,363 Views)

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

 

0 Kudos
Message 5 of 5
(2,327 Views)