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: 

Can someone please please help me with state machine problem (transition problem)? I really need your help.

Solved!
Go to solution

I made a simple code with three cases (Main group, group 1, group 2). I would like my the flow to be as shown below:

GRCK5000_0-1646145309921.png

I can smoothly move from Main Group to Group 1, from Group 1 back to Main Group. Now the problem that I am having is to move from Main Group to Group 2. Is there any way I can move from Main Group to Group 2 without duplicating/recreating Main Group code over and over. 

I have attached my block diagram.

 

0 Kudos
Message 1 of 19
(1,249 Views)

You can make decisions in each state that decides what the next state will be:

seldCapture.PNG

 

Also you really should learn how to use a Type Def as this makes working with Enum's a lot easier as if you need to add or remove an item from your Enum. If that Enum is also a Type Def then you only need to change one and every copy of that Type Def Enum will be updated in your program

========================
=== Engineer Ambiguously ===
========================
Message 2 of 19
(1,229 Views)

The thing is I don't want to move from Group 1 to Group 2.

Please here is the flow I want:

I want the flow to be from Main Group to Group 1, from Group 1 back to Main Group, then from main Group to Group 2, then from Group 2 back to main Group.

0 Kudos
Message 3 of 19
(1,220 Views)

@GRCK5000 wrote:

The thing is I don't want to move from Group 1 to Group 2.

Please here is the flow I want:

I want the flow to be from Main Group to Group 1, from Group 1 back to Main Group, then from main Group to Group 2, then from Group 2 back to main Group.


Oh... Okay then you will need to keep track of the states you have executed like with a Boolean and use some logic in your Main Group to select the next state.

 

Or consider a Queued Sate Machine. In a QSM you load a Queue with the states in the order you want to execute them. 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 19
(1,214 Views)

Yes, I am trying my best to create some logic, but if you can, please let me know. 

0 Kudos
Message 5 of 19
(1,207 Views)

Try something like this.

 

Main_Group_State_Machine.png



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
0 Kudos
Message 6 of 19
(1,199 Views)

Honestly instead of coming up with come convoluted logic that is not going to scale well for a large application.

You really should think about moving to a Queued State Machine.

I also made your Type Def for you...

QSM1Capture.PNG

========================
=== Engineer Ambiguously ===
========================
Download All
Message 7 of 19
(1,198 Views)

At a minimum I would suggest looking at the JKI State Machine as a starting point. But yes, I agree that to be a decent state machine, or QMH, there is quite a bit more needed to control the flow.



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
0 Kudos
Message 8 of 19
(1,192 Views)

Thanks RTSLVU. I am not being able to open your block diagrams. Can you please save it as previous version. Then repost them.

The way to do it:

Open the block diagram: Go to File >> save for previous version . Then send back. 

If you can't do it, I will just try to recreate using the picture you posted.

0 Kudos
Message 9 of 19
(1,189 Views)

This is the error that I am getting:

GRCK5000_0-1646151389532.png

 

0 Kudos
Message 10 of 19
(1,181 Views)