1.3 STATE BASED MODELLING

 

• When we have a single sequence of modes we can use state diagrams.

 

• State diagrams divide a system behavior into discrete states.

 

• The basic technique uses states and transitions to model the systems.

 

 

• The most essential part of creating state diagrams is identifying states. Some key questions to ask are,

1. Consider the system,

What does the system do normally?

Does the system behavior change?

Can something change how the system behaves?

Is there a sequence to actions?

2. List ‘modes’ of operation where the system is doing one identifiable activity that will start and stop. Keep in mind that some activities may just be to wait.

 

• Consider a coffee vending machine,

 

 

• These states can be organized into a state diagram and transitions can be added.

 

 

• Draw a state diagram for the problem below.

 

 

• Draw a state diagram for,

 

 

 

1.3.1 State Diagrams Example

 

• A Complex Example - In this case we have a set of traffic lights. The lights will remain green in one direction until a pedestrian cross button is pushed. They will then turn yellow for four seconds and then turn red.

 

 

• First we will describe the system variables. These will vary as the system moves from state to state. Please note that some of these together can define a state (alone they are not the states).

 

 

• We can then use outputs, or controlled variables, to indicate system states (you can also think of these as modes).

 

 

• State transitions are determined based on inputs, and how the system changes. These events cause a change between states. Care must be taken to avoid confusing them with states.

 

 

• The state transition diagram allows us to visually check for continuous loops. In a simple state diagram multiple transitions may lead to alternate paths.

 

 

• For the previous traffic light example, add a speed up signal for an emergency vehicle.

 

 

 

1.3.1.1 - Block Logic Conversion

 

• The state diagram can be implemented in ladder logic, in this case for a SLC-150. This example uses states to turn lights on or off. An initial block uses the first scan input ‘868’ to ensure the first state is state 1. Each state runs a section of ladder logic code in ‘MCR’ blocks to wait for transitions.

 

 

 

 

 

 

 

 

• Consider the state diagram below and implement it in ladder logic. You should anticipate what will happen if both A and C are pushed at the same time.

 

 

 

 

 

• For the previous traffic light example, add a speed up signal for an emergency vehicle.

 

 

 

1.3.1.2 - Single State Equations

 

• This is the most compact method, but it comes at the cost of robustness.

 

• We can also model state diagrams with equations. To do this we can continue the traffic light example from before.

 

 

 

 

 

• This method will provide the most compact code, but there are two potential problems. Consider the example above.

1. In one scan ST2 might turn on, but ST1 is calculated above it in the ladder logic, so it would not turn off until the next scan - states ST1 and ST2 would both be on for one scan.

2. If in the second scan the input that caused the transition S1 turns off (it is an input on for a brief time) then ST1 would not turn off, and both ST1 and ST2 would be on indefinately.

3. It is also possible for states that have multiple transitions to go to multiple states.

 

• The problem of dual states will occur for at least one of the transitions in this system, and must be tolerable in any system.

 

• The problem of inputs that are only one cycle long can be solved with a seal in or latch circuit.

 

• The problem of parallel state branches can occur if transitions are defined to be mutually independant. This can be overcome by adding terms to the transition logic that will suppress a transition when the competing transition is active.

 

• Consider the state diagram below and implement it in ladder logic. You should anticipate what will happen if both A and C are pushed at the same time.

 

 

 

 

1.3.1.3 - Entry and Exit State Equations

 

• This method deals updates the logic in a single scan, and only has a problem with competing transitions.

 

• This implementation is based upon checking the state activation and deactivation separately.

 

 

 

 

 

• Consider the state diagram below and implement it in ladder logic. You should anticipate what will happen if both A and C are pushed at the same time.

 

 

 

1.3.1.4 - State Transition Equations

 

• This method deals updates the logic in a single scan, and only has a problem with competing transitions.

 

• This implementation is based upon checking the state activation and deactivation separately.

 

 

 

 

 

 

• Consider the state diagram below and implement it in ladder logic. You should anticipate what will happen if both A and C are pushed at the same time.

 

 

• For practice,