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: 

State Machines are great...thank you all

Solved!
Go to solution

Thank you!!!!!

 

For the past several months I have struggled to learn how to use LabView, at all...much less effectively.  With the help of the forum I finally was able to cobble together a display manager for our lab.  It was slow, unresponsive and completely event driven, and totally unmaintainable.  With the help of several key forum members (and I'm sure the good wishes of the rest)  I learned about state machines, queues and other good habits. 

 

In less than 2 days, I have rewritten the project in state machine form and it works beautifully.  It uses a typedef enum for state definitions and a sub.vi for variable initialization.  The BD is readable, simple and can be seen on one screen (nearly...have to scroll down a bit to see all of the error function.)

 

I can't thank all of you enough.

 

Hummer 1

Message 1 of 25
(3,993 Views)
Glad to hear that things went well for you.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 25
(3,983 Views)

Now young Grasshopper it is time to take it to the next level.  With LV scripting you can write a state machine to write your state machine for you.  Smiley Surprised

 

I need coffee now, still waiting for a state machine to do that.  Wait, I, err my daughter, got a Mindstorm for Christmas, could their power be unleashed in the physical world?

Message 3 of 25
(3,945 Views)

Oh thank you master, but I see the coin is still in your hand.

 

Hummer1

Message 4 of 25
(3,940 Views)

A Coin!  Sheesh, back in my day all I got was a pebble.Smiley Sad

 

Congrats on your success! 

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 5 of 25
(3,935 Views)

We have used State Machines for years and they are great.  But the thing thats even better is a state machine with a queue in front.  You can execute the same state multiple times if need be and you can use different states in different orders depending on what is needed. 

 

Give it a shot for your next project. 

Message 6 of 25
(3,932 Views)

tsksesa wrote:

We have used State Machines for years and they are great.  But the thing thats even better is a state machine with a queue in front.  You can execute the same state multiple times if need be and you can use different states in different orders depending on what is needed. 

 

Give it a shot for your next project. 


A queue-driven state machine is my favorite architecture. And I use a typedef enum as the data type for the states. You can mix and match states and it's so easy to maintain and read.
PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 7 of 25
(3,904 Views)

PaulG. wrote:

tsksesa wrote:

We have used State Machines for years and they are great.  But the thing thats even better is a state machine with a queue in front.  You can execute the same state multiple times if need be and you can use different states in different orders depending on what is needed. 

 

Give it a shot for your next project. 


A queue-driven state machine is my favorite architecture. And I use a typedef enum as the data type for the states. You can mix and match states and it's so easy to maintain and read.

I also use the queued state machine extensively. Recently Ihave switched to using a cluster for the state rather than a simple typdefed ENUM. My cluster consists of the typedefed ENUM and a variant. This provides a mechanism for easily passing data between states and since it is a variant one the poster and the specific state need to know the data type. New states can be added without worrying about updating typedefs for the state data that may be required.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 25
(3,896 Views)

A queued state machine is your friend

It's not just a fad or a trend

A typedef'd enum

Leaves plenty of room

For changes you won't have to mend!

 

I also like type-defined clusters

A variant gives it some lustre

You can pass anything

Array, number, or string

And your next state will always pass muster!

 

d

 

 

 

 

Message 9 of 25
(3,820 Views)
NIce!
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 10 of 25
(3,793 Views)