Using a State Machine to control output

By the way, while I think this is a neat trick, it certainly requires using 2 integers otherwise you could end up with the next state (or even states) executing on the same scan.


My other problem with this approach is that it's great if your solution works 100% first time and never needs adding any new states between exisitng ones. So it's a sort of handicapped integer-based method.

move command is manipulating same integer, so there can't be 2 different states on same time. It is move from 1-->2 or 1-->3. On later state 2 is jumped over.
You can use what number you like for this, if you use 10, 20 and 30, then you have 10 spare states, which you can use later if needed. (On that case you need take care, that program can't go to states which isn't used)
 
Last edited:
sure there is much same between those to states. (only decision if output is on or off is different)
But it is easier to read afterwards and you don't need make set/reset latches for bits, like you need if your S500 state behaves differently depending of earlier outputs states.

I understand that one state have outputs allways same way and if outputs are different at different time and depending of different things, then there is more than one state

I see what you mean, but, It's not a separate state. It's a single state, and there's an interlock for the output. In other words, running it the output off is not part of normal operation; it's more like error handling. While it's possible to view it as an independent state, there're many more possible faults and it's not feasible to "branch off" with each.

move command is manipulating same integer, so there can't be 2 different states on same time. It is move from 1-->2 or 1-->3. On later state 2 is jumped over.
You can use what number you like for this, if you use 10, 20 and 30, then you have 10 spare states, which you can use later if needed. (On that case you need take care, that program can't go to states which isn't used)

I have a feeling you missed the point of the specific technique Aardwizz suggested. Take another look.
It's integer based, but the integer is then used in a contact, testing each bit as a separate state. So state 1 would be 00000001, state 2 would be 00000010, state 3 00000100, and so on.
 
To answer one of your original questions, I would have a simple rung with S400 and S500 in parallel with each other - turning on the output. To me, basic state logic says that the outputs are on for certain states and off for all others. So if the machine is in S400 or S500, I would ALWAYS expect the output to be on.

You mention that S500 is just a continuation of S400 - keeping the output on. If so, simple parallel logic accomplishes that. However, if you are saying that you could somehow get to S500 without going through S400 first, and in this case, you would not want to turn on the output, then I totally agree with another poster to say that you have just defined a new state.

On other topics, many people program state logic with an integer that they set to 10, 20, 30.... The benefit of this approach for the programmer is that you can easily add extra steps between these steps if you realize the need. What I hate about that style is that the rest of the program usually has EQUAL statements in the logic. If State=20 then.... The problem in ladder logic (at least AB) is that there is nothing that easily tells the troubleshooter what State=20 means. So it works OK for the programmer who knows what state 20 and state 30 are, but for everyone that follows, its an investigation with guesswork. If you are lucky, the programmer added some rung comments to help you, but I'd rather see bit descriptions.

So I prefer your approach to using the bits of an integer where those bits are easily labelled. FYI, when I use that method, move a zero into the state Integer (to clear all bits to zero) and follow the Move command with a latch that sets the proper bit.
 

Similar Topics

Is there a way to know which is the primary and secondary chassis through gsv? I have read that "PhysicalChassis" (Chassis A/Chassis B) is an...
Replies
2
Views
2,206
Hi guys, In this project we have a PLC for each room monitoring the status of different devices,so there is seven rooms and seven PLCs. Currently...
Replies
2
Views
1,814
May I know how to read the coupler state, whether it is in Idle or in active mode using dot net. What variable I should read? Any sample I can...
Replies
0
Views
1,349
Hello. I am new to expressions in FTView. I am replacing a GOT with a panelview and am trying to drive a multi-state indicator with a expression...
Replies
2
Views
5,165
Dear all Could any one help me. If I have a system to control, and all i know form that system is those state space equation, can any one Help...
Replies
0
Views
1,904
Back
Top Bottom