Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

STATE DIAGRAM MODEL PROBLEMS

PROBLEM 1

Represent as a state diagram model the process described here, explaining the actions performed in
each state

Whenever the “START” button is pressed, a conveyor belt is activated, and starts carrying cups.
When the sensor “S1” detects a cup, the conveyor belt is stopped, and two valves (V1, V2) are
opened simultaneously. “V1” has to remain open for 5 seconds, “V2” will remain open until the cup
is full. This is detected by the sensor “S2”. Once the cup is full, the conveyor belt starts moving
again in order to bring a new cup. The process continues until 4 cups have been filled, and then the
systems goes back to the idle state. After filling the last cup, the conveyor belt has to remain active
for 10 seconds in order to move the cup to the pick-up area.
SOLUTION:

Inputs: START, S1, S2


Outputs: V1, V2, CB
States:
• IDLE: This is the idle state, no outputs are activated in this state. Counter is set to 0 (c = 0)
• MOVE_CB1: Whenever the system is in this state, the conveyor belt (CB) has to be active.
The system stays in this state until the sensor “S1” detects a cup in the filling position
• FILL V1 & V2: Both valves are opened by activating the corresponding signals (V1, V2).
After 5 seconds, the system leaves this state.
• FILL V2: Only valve 2 is opened (V2 output has to be activated). The system remains in
this state until the sensor “S2” detects that the cup is full. Counter is updated (c = c + 1)
• MOVE_CB2: Whenever the system is in this state, the conveyor belt (CB) has to be active.
The system stays in this state for 10 seconds.

NOTE: It is possible to merge “FILL V1 & V2” and “FILL V2” states into a single state, named
“FILL_CUP”. In this case, inside the “FILL_CUP” state, both valves have to be opened, a timer is
required for deactivating V1 (without leaving the state) , by using the timer’s output Q to deactivate
V1. The system leaves the state when S2 detects that the cup is full.
PROBLEM 2

We want to automate the transport system showed in the following diagram:

Loading valve
V1

Maintenance Loading area Unloading area


area

The system works as follows:


• The trolley starts in the maintenance area.
• The system is activated with a button (P).
• The trolley starts moving to its right (MDer) until it reaches the loading area (detected with
a sensor SC), and then stops.
• Valve V1 is opened for 10 seconds, which is the time required for loading the trolley.
• Once the trolley is full, it moves again to its right until it reaches the unloading area
(detected with a sensor SD), where the trolley empties its load (this takes 5 seconds). The
trolley has a motor (MotDesc) for unloading it.
• The trolley moves to its left (MIzq), to the loading area and repeats the loading-unloading
process five times.
• After the fifth time, the trolley moves back to the maintenance area (detected with a sensor
SM) for an inspection. This inspection takes 1 minute.
• Once the inspection is completed, the process is ready to start again (by pressing the button
P)
• During the whole process, a light (Luz) that indicates the active state has to be ON.

Program the process controller using LD, based on the state diagram model
SOLUTION:

Inputs: P, SM (maintenance area sensor), SC (loading area sensor), SD (unloading area sensor)
Output: MDer, MIzq, MotDesc, V1, Luz

Programming:

Before using LD to program the system, we need to asign the inputs, outputs and states to different
memory slots in the PLC.

In order to assign memory variables, we need to take into account how the PLC manages the
memory. For states, we will use boolean variables with the name %M0, %M1, %M2, etc… For
inputs and outputs of the system, we need to know how the inputs and outputs of the PLC are
configured. In the PLCs that we have in our labs, binary inputs (only two possible states: 0 or 1) are
located in the first module, and they will be labeled %I0.1.0, %I0.1.1, %I0.1.2, etc… Ouptuts are
located in the second module, so they will be labeled %Q0.2.0, %Q0.2.1, %Q0.2.2, etc…

Based on this criteria, we perform the following asignations:


Inputs and Outputs:

Name Const Address Comment Value Used DG


Luz NO %Q0.2.3 Light 2 NO
MDer NO %Q0.2.1 Motor moving right 1 NO
MIzq NO %Q0.2.2 Motor moving left 1 NO
MotDesc NO %Q0.2.5 Motor used for unloading the trolley 1 NO
P NO %I0.1.0 Activation button 1 NO
SD NO %I0.1.2 Position sensor located in the unloading area 2 NO
SC NO %I0.1.3 Position sensor located in the loading area 1 NO
SM NO %I0.1.1 Position sensor located in the maintenance area 1 NO
V1 NO %Q0.2.4 Loading deposit valve 1 NO

States:

Name Const Address Comment Value Used DG


IDLE NO %M0 Idle state bit 2 NO
MOVE_R1 NO %M1 MOVE_R1 (from maintenance to loading) state 1 NO
bit
LOAD NO %M2 Loading state bit 1 NO
MOVE_R2 NO %M3 Motor used for unloading the trolley 1 NO
UNLOAD NO %M4 Activation button 1 NO
MOVE_L NO %M5 Position sensor located in the unloading area 2 NO
INSPECTION NO %M6 Position sensor located in the loading area 1 NO

Next, we proceed to program this system using LD. We can identify three different parts:

Initializing the system: Program must be initialized in the %M0 state, this is, the IDLE state.
When we run the program, all variables start with a value of zero. So, if no state variable is True (if
the program is not in any state), then we activate the %M0 state.

Programming the state sequence: Next, we need to program the sequence that the state diagram
follows. Whenever a state is active and the condition for activating a transition is met, the active
state is reseted to 0 and the next state is set to 1. This is done by using set and reset operations. In
this problem, if we are in the %M0 state and the activation button is pressed (input P), then %M0
state is reseted and %M1 state is activated.
Moving from %M1 to %M2 is similar, %M2 is set to 1 when %M1 is active and S_LA (loading
area position sensor) is active. In order to move from %M2 to %M3, we need to check a timer that
indicates that the state has been active for 10 seconds (the time that takes to load the trolley).

The transition between %M3 and %M4, and the one between %M4 and %M5 follows the same
logic that the ones presented before. The only changes would be the input that we have to check and
how long we have to remain in the state %M4.

In %M5 we have to increase the value stored in a counter, that has to be programmed as well.

Once %M5 is active, there are two possible routes. If the counter is equal to 5, then the counter’s
output %FB1_2.Q is set to 1. So, if we are in %M5, the counter’s value is 5 and the trolley is in the
maintenance area (S_MA is active), then we transition from %M5 to %M6. On the other hand, if the
count is lower than 5 (this is detected by using a comparer that checks the counter’s value by
reading the output %FB1_2.CV), we are in %M%, and the trolley is in the loading area (S_LA is
active), then we transition from %M5 to %M2.
Now, we have programmed all the required transitions between states.

Output activation: Once we have programmed all the state transitions, we need to program the
activation of the different outputs required:

• We place all the outputs that have to be activated in the actions area (right). Next, we check
in which state each output has to be active, and we place those states in the conditions area
(left), using an OR logical operation.
• Outputs SHOULD NOT appear more than once, because they could receive contradictory
instructions.
• States have to be placed in parallel, so the action can be active in any of those states
PROBLEM 3

We want to mix two products with water. The tank is filled with water by opening the valve V1. The
dosage of both products is done by pouring them into a hopper. First add the product A, until the
weight SP1 is reached, and then we add product B, until the final weight (SP2) is reached. Once
both products are in the hopper, then the valve V2 is opened for 10 seconds, and the contents of the
hopper are dropped in the tank. The mixer (M) is activated in order to start the mixing process,
which goes on for 30 seconds. Finally, the tank is emptied, and the system is ready to start a new
cycle. The process starts when the button P is pressed

Program the process controller using LD, based on the state diagram model
SOLUTION:

First of all, we need toassign memory addresses to the inputs, outputs, and states:

Inputs Outputs States


P → %I0.1.0 V1 → %Q0.2.0 IDLE → %M0
DL → %I0.1.1 V2 → %Q0.2.1 FILL TANK / ADD A → %M1
DV → %I0.1.2 V3 → %Q0.2.2 ADD A → %M2
SP1 → %I0.1.3 VA → %Q0.2.3 ADD B → %M3
SP2 → %I0.1.4 VB → %Q0.2.4 FILL TANK / ADD B → %M4
M → %Q0.2.5 FILL TANK → %M5
POUR → %M6
MIX → %M7
EMPTY TANK → %M8
Program:

1. Initialization:

2. Transitions:
3. Output activation:
There is another possible solution for this problem:

In this case, we simlify the state diagram, but when programming the activation of the outputs, we
need to take into account all the possibilities that can happen inside each state. When assigning the
memory addresses, the input and output assignation is the same in both solutions, the only thing that
changes is the memory adresses for the states:

Inputs Outputs States


P → %I0.1.0 V1 → %Q0.2.0 IDLE → %M0
DL → %I0.1.1 V2 → %Q0.2.1 FILL TANK / ADD A / ADD B → %M1
DV → %I0.1.2 V3 → %Q0.2.2 POUR → %M2
SP1 → %I0.1.3 VA → %Q0.2.3 MIX → %M3
SP2 → %I0.1.4 VB → %Q0.2.4 EMPTY TANK → %M4
M → %Q0.2.5
And the new program would look like this:

In this case, output activation depends on which state is active, and also the activation and
deactivation of the input variables in each state.
PROBLEM 4

We want to automate a system that packs soda bottles in packs of two bottles. The following figure
depicts a top view of the whole process:

START BUTTON

PISTONS
BOTTLE PACKING
MACHINE PICK-UP
AREA
BELT 1

BELT 3

BELT 2

BOTTLE BOTTLE
PACK

The system works as follows:

The process starts whenever the worker presses the start button P. Two independent conveyor belts
(MC1 and MC2) bring bottles from the previous stage of the manufacturing process, where they
have been filled and tagged. We need to pack them in sets of two bottles each. The PLC has to
control each belt independently, so they can be stopped when a bottle is in place (SP1 or SP2
sensors activate) It is important to notice that bottles can arrive at different times. When both
sensors have detected a bottle (both conveyor belts are stopped), then two lateral pistons (EMB) are
activated. The pistons place the bottles in the third conveyor belt (MC3). This operation takes 2
seconds. Next, MC3 is activated, and moves the bottles to the packing machine (EMP). This is
detected by the sensor SP3. The packaging process takes 10 seconds. Then, the bottle pack is sent to
the pick-up area, until the sensor SP4 detects the pack, stops the MC3, and the system goes back to
the idle state.

a) Model the system using a state diagram model, and program it using LADDER logic
MC1 is active while SP1
MC1 is not active, MC2 is
MC2 active while SP2 is not
active

%M 4
EMB

%M 5
MC3

%M 6
EMP

%M 7

MC3

Inputs Outputs States


P → %I0.1.0 MC1 → %Q0.2.0 IDLE → %M0
SP1 → %I0.1.1 MC2 → %Q0.2.1 MOVE CB1 & CB2 → %M1
SP2 → %I0.1.2 MC3 → %Q0.2.2 PISTONS → %M4
SP3 → %I0.1.3 EMP → %Q0.2.3 MOVE CB3 → %M5
SP4 → %I0.1.4 EMB → %Q0.2.4 PACKAGE → %M6
MOVE CB3_2 → %M7
PROBLEM 5

We want to automate a level crossing system. The desired system’s behavior is the following:
While the system is in the idle state, the barrier has to be open, and the green traffic light (LV) has
to be on.
Whenever the system detects a train coming (this is detected either by the sensors S1 or S2), then
the following actions have to be performed:
• Change the light to orange (LA) for 30 seconds, while at the same time we activate an
acoustic signal (SA)
• Then, the light changes to red (LR) and, 20 seconds later, the barrier goes down, by
activating the barrier’s lowering motor (MBaj), until sensor SD detects that the barrier is at
the lower position
• When the train passes by the other sensor over the rail (either S1 if S2 was activated before
or S2 if S1 was activated before), the barrier is raised by activating the motor (MSub) until
the barrier is at the higher position (detected by the SU sensor).
• Once the barrier is open, the light changes back to green and the acoustic signal is
deactivated

a) State Diagram Model that represents this system


b) Program using LD
SOLUTION

reset(SA)
reset(LR)
LV

LA
set(SA)

set(LR)

MBaj

MSub

Inputs Outputs States


P → %I0.1.0 MBaj → %Q0.2.0 IDLE → %M0
S1 → %I0.1.1 MSub → %Q0.2.1 ORANGE → %M1
S2 → %I0.1.2 LA → %Q0.2.2 RED → %M2
SD → %I0.1.3 LV → %Q0.2.3 LOWER BARRIER → %M3
SU → %I0.1.4 LR → %Q0.2.4 WAIT → %M4
SA → %Q0.2.5 RAISE BARRIER → %M5

You might also like