LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine

Hi,

 

I have a problem with a state machine. I can't get it to start executing by the first state, that is, I want it to start in the state called "energize motor" and start executing by the state "put position". I have put the first state as "make currente value default" but the first state still does not run first.


Could you help me please?

I attach the program

 

Thank you

0 Kudos
Message 1 of 18
(2,310 Views)

Hi 99,

 


@labview99 wrote:

I can't get it to start executing by the first state, that is, I want it to start in the state called "energize motor" and start executing by the state "put position".


Then there is a problem in your code!

 


@labview99 wrote:

I attach the program

No, you did not.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 18
(2,298 Views)
0 Kudos
Message 3 of 18
(2,294 Views)

Hi 99,

 


@labview99 wrote:

I can't get it to start executing by the first state, that is, I want it to start in the state called "energize motor" and start executing by the state "put position". I have put the first state as "make currente value default" but the first state still does not run first.


The problem is not with your statemachine…

Setting a case in the case structure as "default" doesn't mean it will be executed first: it will be executed when no other case applies!

 

Your statemachine right now should start with "Meter posicion" state as that is what I read in this Enum control. When you want to start with a different state you should replace this Enum control by a constant in the block diagram and choose the correct item!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 18
(2,290 Views)

Hi GerdW,

 

Now it works perfect!

 

Thank you so much!

 

Best regards,

0 Kudos
Message 5 of 18
(2,282 Views)

A little tip:

Get rid of the default case.  Have an explicit case for each state (or, if a case covers several different states, list them all explicitly in one state).  This is so when you add an item to your typedef'd state enum, your code breaks so you know exactly where to add your code to handle this change.  If you don't do this, you run the very real risk of missing all the places your code needs to be updated, and you get "unexpected" results.  The risk varies exponentially with the complexity of your code.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 18
(2,242 Views)

Hi,

I have found another problem.
I have a problem with a state machine that I have made.
When I am in the state called "Reset" I want it to be in that state until it receives a number 2 in the second position of the entering array. That number 2 indicates that the SVRE signal of the cylinder that I am controlling is active.
I can see that the signal SVRE is activated but it never seems to get that two of the array and it stays in that state all the time.

 Could you help me please

 

I attach the program

 

Best regards

0 Kudos
Message 7 of 18
(2,184 Views)

Hi,

 

Thank you so much for your tip.

 

How can I undo the default case?

 

Best regards

0 Kudos
Message 8 of 18
(2,181 Views)

Hi 99,

 


@labview99 wrote:

I can see that the signal SVRE is activated but it never seems to get that two of the array and it stays in that state all the time.


Ofcourse it will stay in "Rearmar" (I guess you are talking about this state) forever! (You should give the exact name of the state as there is no "Reset" state in your staemachine!)

 

There is an array in the shift register and you check its 2nd element for bit #1 (AND with 2). When the test fails you call this state again, just to repeat this test again - which will fail because you test with the very same array data in the shift register!

 

Maybe you need to read a new device response before repeating that test?

 


@labview99 wrote:

How can I undo the default case?


There's a "Remove default" in the context menu of the case structure…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 18
(2,180 Views)

Hi GerdW,

 

Yes you are right, I am going to try to change some things

 

Best regards

0 Kudos
Message 10 of 18
(2,177 Views)