04-29-2020 05:02 AM
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
04-29-2020 05:12 AM
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.
04-29-2020 05:14 AM - edited 04-29-2020 05:14 AM
Sorry, I try again
04-29-2020 05:18 AM
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!
04-29-2020 05:28 AM
Hi GerdW,
Now it works perfect!
Thank you so much!
Best regards,
04-29-2020 07:15 AM
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.
04-30-2020 06:29 AM
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
04-30-2020 06:33 AM
Hi,
Thank you so much for your tip.
How can I undo the default case?
Best regards
04-30-2020 06:37 AM - edited 04-30-2020 06:39 AM
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…
04-30-2020 06:40 AM
Hi GerdW,
Yes you are right, I am going to try to change some things
Best regards