Laboranleitung AUT Versuch 3 en

You might also like

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

Control of a production plant with PLC

Authors: Georg Frey and Stéphane Klein


Translation: Marcel Krames and Raphael Fritz
Supervision: M.Sc. Raphael Fritz

Module 1
Description of the plant

Topic:
1 DESCRIPTION OF THE PLANT .....................................................................................................2
1.1 OVERVIEW .....................................................................................................................................2
1.2 MODULES ......................................................................................................................................2
1.3 SENSORS UND MOTORS..................................................................................................................7
2 DEFINITION OF INPUT AND OUTPUT VARIABLES ..................................................................10
Module 1 Page 2 of 11

1 Description of the plant


1.1 Overview

Figure 1 Overview of the plant


The system consists of a tower-shaped feeder on the left side, three the three conveyor belts,
three machines and a storage area at the right end of the conveyor belts. The feeder pushes the
workpieces individually onto the first of the conveyor belts. The three conveyor belts have
their own motors and can be controlled individually. The following names are used for the
machines from the left: Drill, vertical mill and horizontal mill. As these are stylized machines,
the movement axis and the tool arrangement of the vertical mill do not necessarily correspond
to those of real machines. This machine has a tool changer in the form of a turret magazine.

On the rear panel (from the left) there is a 24V DC power supply, a terminal strip with 104
terminals, ten relays and two terminal blocks for the inputs and outputs of the controller.

1.2 Modules

1.2.1 Feeder

Figure 2 Feeder and control panel


The feeder can hold a maximum of five workpieces. The motor drives a chain to which small
blocks are attached in two opposite positions. These blocks push the workpieces out of the
feeder. The motor is connected in such a way that it can only turn in the reasonable direction.
Module 1 Page 3 of 11

At the rear end of each block is a magnet. A reed relay is mounted in such a way that it de-
tects this magnet when the chain is in the waiting position to push the next workpiece out of
the feeder.

Transverse to the movement direction of the workpieces is a light barrier which switches to '1'
when no workpiece is left in the feeder.

On the left side of the tower is a control panel with six illuminated buttons. The LEDs in the
buttons can be controlled independently of the button actuation.

1.2.2 Conveyor belt

Figure 3 Conveyor Belt


Each conveyor belt is driven by its own motor, which can be seen at the bottom right of figure
3. It can only rotate in one direction, so the workpieces always move from left to right.

On each conveyor belt are two sensors for detecting the workpieces. They are located at the
beginning of the belt and directly in front of the machine.
Module 1 Page 4 of 11

1.2.3 Drill

Figure 4 Drill
The drill has two motors. The first rotates the tool and is connected in such a way that it can
only rotate in one direction. The second one raises and lowers the machine head. It is con-
nected by two relays in order to reverse the polarity of the voltage on the motor and thus
reverse the movement direction. When moving in one direction, only one relay is active. This
makes the control of the relays very simple.

The module only provides feedback to the controller via two mechanical limit switches. They
are fixed at the lower and upper end of the machine stand. They can be moved vertically and
should not be mistaken for mechanical stops. If programmed incorrectly, the tool may collide
with a workpiece. The movement upwards is not limited, so the machine head would fall out.
Module 1 Page 5 of 11

1.2.4 Vertical Mill

Figure 5 Vertical mill with tool changer


The vertical mill has three motors. One rotates the tool and is connected in such a way that it
can only rotate in one direction. The second one raises and lowers the machine head. Like any
motor whose rotation direction can be reversed, it is connected with two relays. The third mo-
tor rotates the tool changer, which also works in both directions.

As with the drill, two mechanical limit switches are fixed at the lower and upper end of the
machine stand. Incorrect programming also has the same consequences here.

There is also an identical mechanical switch for the position of the tool changer. This switch
is activated every time a tool points downwards. This means that it cannot determine which of
the three tools is pointing downwards.

The position switch for the tool is mounted in such a way that the tool is exactly vertical when
the changer is turned to the right and stops immediately when the switch is actuated. If, on the
other hand, the tool changer is rotated to the left, the motor must not be stopped until the
switch has been exited again after being actuated. This is caused by the fact that the switch is
activated over a certain rotation range.
Module 1 Page 6 of 11

1.2.5 Horizontal mill

Figure 6 Horizontal mill


The horizontal mill also has three motors. The first rotates the tool only in one direction. The
second raises and lowers the machine head and the third moves the machine stand forwards
and backwards. The last two motors each have a direction reversal via two relays.

As with the previous machines, there are two mechanical limit switches at the lower and up-
per end of the machine stand. In addition, there are mechanical limit switches at the front and
back positions of the machine stand on the machine bed. When each of these switches is actu-
ated, the program must ensure that the critical motor is safely switched off.

1.2.6 Storage

Figure 7 Storage
The storage at the end of the production line can hold four workpieces. At the beginning of
the storage is a reflection light barrier which detects a workpiece positioned vertically above
it. Each workpiece that moves over the sensor generates a '1' pulse. If the storage is full, the
last workpiece lies directly above the sensor and thus generates a permanent '1' signal.
Module 1 Page 7 of 11

1.3 Sensors und motors

1.3.1 Illuminated pushbutton on the control panel


There are six buttons on the control panel:
Three red:
STOP, FEEDER EMPTY,
STORAGE FULL
One green:
START PAUSE
Two yellow:
CLEAR STOP, INIT
Figure 8 Control panel
Each button has an LED, a normally open contact and a normally closed contact. The LEDs
have a dropping resistor so that they can be controlled with 24V. The stop button is the only
one to which a normally closed contact is connected. When actuated, it gives a '0' signal to the
controller. All other buttons are wired as normally open contacts, so they give a '1' signal to
the control when actuated.

1.3.2 One-way light barrier


This sensor checks whether the feeder is
empty.
The transmitter is shown in the foreground
and the receiver of the light barrier in the
background of figure 9. The sensor works in
infrared range. If there is a workpiece in the
feeder, the beam is interrupted. If the feeder is
empty, the beam reaches the receiver, whose
signal switches to '1'.

The light barrier, like all sensors of the sys-


Figure 9 Light barrier at the feeder tem, is operated with 24V.
Module 1 Page 8 of 11

1.3.3 Reed relay


The reed relay sends a '1' signal to the control-
ler when there is a magnet near it. There are
two magnets on the chain. The chain should
be stopped whenever the sensor is '1'. So there
are two defined positions in which a block,
that pushes the workpieces out of the feeder,
stands directly behind the lowest workpiece in
the feeder.

Figure 10 Reed relay for detection of chain


position at feeder

1.3.4 Inductive proximity switches


The sensors react to metal in their near area.
Since the workpieces are made of wood, they
have round metal plates on all four sides so
that they can be detected by the sensors.

There are six sensors of this type on the plant.


They are located at the beginning of all three
conveyor belts and in front of each machine.

Figure 11 Inductive proximity switch

1.3.5 Mechanical limit switches


All mechanical switches are normally closed,
with one contact connected to the supply volt-
age and the other to an input of the controller.
When actuated they send a '0' signal to the
controller.

The rounded pieces in the middle of figure 12


are the actuation areas of the switches. Their
rounded edges make them easy to drive over.

Figure 12 Mechanical limit switch


Module 1 Page 9 of 11

1.3.6 Reflection light barrier


This light barrier emits infrared light. Each
body above the sensor reflects a part of the
beam. If the body is not too high above the
sensor and has a sufficiently large area per-
pendicular to it, the sensor send a '1' signal.
These prerequisites are given with the used
workpieces.

Figure 13 Reflection light barrier in storage

1.3.7 Motors

Figure 14 Motor at conveyor belt Figure 15 Motor and gear box


All motors run with 24V DC voltage. A direction reversal is possible by reversing the polarity
of the voltage. The motors of the conveyor belts, the motor of the chain in the feeder and the
tool motors are directly connected to the outputs of the controller and can therefore only rotate
in one direction. The others are supplied with voltage via relays, which allow a reversal of
polarity.

Figure 14 shows the drive mechanism of the conveyor belts. Figure 15 shows a motor for
moving a machine and its associated gear for rotational speed reduction.
Module 1 Page 10 of 11

2 Definition of input and output variables

Address Variable name Meaning of binary zero Meaning of binary one


E 0.0 stop_button STOP-Button is actuated STOP-Button is not actuated
E 0.1 start_button START-Button is not actuated START-Button is actuated
E 0.2 clear_button CLEAR-Button is not actuated CLEAR-Button is actuated
E 0.3 init_button INIT-Button is not actuated INIT-Button is actuated
E 0.6 feeder_ready Conveyor chain in interim posi- Conveyor chain in initial
tion position
E 0.7 feeder_empty Feeder is not empty Feeder is empty
E 1.2 drill_top Drill head is at upper limit Drill head is not at upper
limit
E 1.3 drill_bottom Drill head is at lower limit Drill head is not at lower
limit
E 1.4 drill_entrance No workpiece is at beginning of Workpiece is at beginning of
conveyor belt conveyor belt
E 1.5 drill_position No workpiece is in front of drill Workpiece is in front of drill
E 2.2 vmill_top Mill head is at upper limit Mill head is not at upper
limit
E 2.3 vmill_bottom Mill head is at lower limit Mill head is not at lower
limit
E 2.4 vmill_entrance No workpiece is at beginning of Workpiece is at beginning of
conveyor belt conveyor belt
E 2.5 vmill_position No workpiece is in front of ver- No workpiece is in front of
tical mill vertical mill
E 2.6 vmill_tool_ready Tool is in working position Tool is in not working posi-
tion
E 3.0 hmill_back Mill head is at back limit Mill head is not at back limit
E 3.1 hmill_front Mill head is at front limit Mill head is not at front limit
E 3.2 hmill_top Mill head is at upper limit Mill head is not at upper
limit
E 3.3 hmill_bottom Mill head is at lower limit Mill head is not at lower
limit
E 3.4 hmill_entrance No workpiece is at beginning of Workpiece is at beginning of
conveyor belt conveyor belt
E 3.5 hmill_position No workpiece is in front of hor- Workpiece is in front of hor-
izontal mill izontal mill
Module 1 Page 11 of 11

Address Variable name Meaning of binary zero Meaning of binary one


A 0.0 stop_signal LED STOP off LED STOP on
A 0.1 start_signal LED START off LED START on
A 0.2 clear_signal LED CLEAR-STOP off LED CLEAR-STOP on
A 0.3 init_signal LED INIT off LED INIT on
A 0.5 feeder_signal LED FEEDER EMPTY off LED FEEDER EMPTY on
A 0.6 feeder_motor Motor conveyor chain off Motor conveyor chain on
A 1.2 drill_motor_up Motor up off Motor up on
A 1.3 drill_motor_down Motor down off Motor down on
A 1.4 drilling_motor Motor tool off Motor tool on
A 1.5 drill_conveyor Motor conveyor belt off Motor conveyor belt on
A 2.2 vmill_motor_up Motor up off Motor up on
A 2.3 vmill_motor_down Motor down off Motor down on
A 2.4 vmilling_motor Motor tool off Motor tool on
A 2.5 vmill_conveyor Motor conveyor belt off Motor conveyor belt on
A 2.7 vmill_change_right Motor tool changer off Motor tool changer on
A 3.0 hmill_motor_back Motor backwards off Motor backwars on
A 3.1 hmill_motor_front Motor forwards off Motor forwards on
A 3.2 hmill_motor_up Motor up off Motor up on
A 3.3 hmill_motor_down Motor down off Motor down on
A 3.4 hmilling_motor Motor tool off Motor tool on
A 3.5 hmill_conveyor Motor conveyor belt off Motor conveyor belt on
Control of a production plant with PLC

Authors: Georg Frey and Stéphane Klein


Translation: Marcel Krames and Raphael Fritz
Supervision: M.Sc. Raphael Fritz

Module 2
Control design and analysis with SIPN

Topic:
1 THE CONTROL CONCEPT ............................................................................................................2
2 THE PLC AS CONTROL DEVICE ..................................................................................................3
3 THEORETICAL BASICS .................................................................................................................3
3.1 PETRI NETS ...................................................................................................................................3
3.2 SIGNAL INTERPRETED PETRI NETS (SIPN) ......................................................................................4
3.3 CONDITIONS FOR CORRECT SIPN ...................................................................................................6
3.4 REACHABILITY GRAPH ....................................................................................................................7
3.5 ANALYSIS WITH REACHABILITY GRAPH .............................................................................................9
4 RECOMMENDATIONS FOR SIPN DESIGN ................................................................................11
Module 2 Page 2 of 12

1 The control concept


According to DIN 19226, control (here logic control) is the process in a system in which one
or more variables (called inputs) influence other variables (called outputs) based on the sys-
tem inherent rules. The characteristic for control is an open or closed loop design, in which
the output variables influenced by the input variables do not act continuously and not again
through the same input variables on themselves. Therefore, the concept of control is very
comprehensive. Within the framework of this laboratory only binary signals are considered.
This a realistic limitation since about 90 percent of all industrial controllers are based on bina-
ry signals. Such a controller can be characterized as a discrete-event system.
The controller in figure 1 shows the controlling system, the control device, and the controlled
system, the plant. In the technical version, the controlling system consists of one or more au-
tomation devices with data and program memory, mostly so-called programmable logic
controllers (PLCs). In addition to the current process data, interim results (e.g. flags) are
stored in the data memory, which are integrated in the algorithm located in the program
memory. As shown in figure 1, the inputs and outputs of the controller are simultaneously
part of the inputs and outputs of the control device. The operator can influence the control
system from the outside via switches or similar devices, as well as receive information from
the control system, for example via lamps. The aim of the control system is the desired behav-
iour, the process, that is to be controlled within the plant. The plant contains actuators and
sensors for influencing the behaviour. The actuators influence the plant. An example of an
actuator is a motor of a conveyor belt, which is started by a signal from the control unit and
thus influences the process. Sensors are used to obtain information about the process. One
example is a limit switch which, depending on a crane position (end stop reached or not
reached), sends a binary signal (1 or 0) to the controlling system.

Figure 1 Schematic Control

In this laboratory, control algorithms for a given production plant are to be designed. The de-
scriptions of the individual control parts as well as information about their desired behavior
are required for this purpose.
Module 2 Page 3 of 12

2 The PLC as control device


Today, programmable logic controllers (PLCs) are a convenient option for automation of in-
dustrial machines using control devices. In the past, it was necessary to design and
manufacture a machine-specific relay-based control system. Possible changes to the control
task were associated with a great amount of effort in the original wiring. The entire structure
had to be rethought and redesigned. This often resulted in space problems for new relays to be
added, which could only be solved with a lot of effort.
By using a PLC or an IPC with SoftPLC, this problem is solved in an elegant way because the
control task is integrated into the system in the form of software. The relay functions can be
entered into the PLC in the form of programs in different display modes. This means that any
changes that may occur can be realized at any time and without great effort.
A PLC is an automation device in the sense of figure 1 that has a real-time operating system.
The CPU communicates with its peripheral components, for example the I/O cards, over a
backplane bus. Referring to figure 1, the interface between the operator and the PLC is estab-
lished by a PC as well as by the LEDs of the digital cards and the lamps as well as the buttons
of the plant (see below). The production task is solved in such a way that you create the algo-
rithms on the PC and load them to the PLC, which is described in the corresponding modules.

3 Theoretical basics
Within the framework of this laboratory test, control algorithms are to be developed. Since the
tasks to be solved are mostly concurrent processes, Petri-nets can be used to create the algo-
rithms, which also allow an analysis of the modelled algorithm. In particular, so called signal
interpreted Petri nets (SIPN) are used, which have a strong relation to industrially used tech-
nical languages.
3.1 Petri nets
Petri nets are assigned to the class of so-called bipartite digraphs. Bipartite means that there
are two disjoint subsets of nodes (places, transitions), where nodes of one subset are connect-
ed with nodes of the other subset by edges. Digraphs are also called directed graphs. A
distinction is made between the edges leading to a transition (pre-edges) and the edges leading
away from a transition (post-edges). Places can be marked with so-called tokens, whereby in
this laboratory experiment only binary markings of places is considered. The tokens are
switched/fired by the transitions through the net. The following rules apply to the firing of
transitions, which describe if a transition is enabled and the behavior when firing a transition:
(R1) Strong concession rule
A transition is ready to fire (enabled) if all places connected by pre-edges have at least
one token and if none of the places connected by post-edges would have more than one
token after the firing of the transition.

(R2) Token flow rule


When firing a transition, one token is removed from each place connected by pre-edges
and one token is added to each place connected by post edges.

The following semantics of the Petri-net can be specified by the binary marking: A marked
place corresponds to a fulfilled condition, an unmarked place corresponds to an unfulfilled
condition for the occurrence of an event. The firing of a transition can be seen as an event,
Module 2 Page 4 of 12

which can occur if all pre-conditions are fulfilled. During firing, all post-conditions are ena-
bled. The term condition/event net is therefore frequently used in the literature. In the
literature there are a number of other types of Petri nets, which are not relevant for this labora-
tory experiment.
3.2 Signal interpreted Petri nets (SIPN)
In control engineering, the semantics described above can be concretized as follows: Condi-
tions are interpreted as control situations that can be enabled (marked) or disabled. The
operative part of control is expressed in the fact that in every situation certain actions must be
executed by the control device and that the occurrence of events can be explicitly expressed as
a function of certain signals. A distinction is made between internal (timers) and external (in-
put signals) events. Therefore, SIPNs describe control algorithms for the controller by
extending the syntax of the Petri-nets mentioned above.
In general, SIPN can be integrated into the theory of interpreted Petri nets (IPN). IPN are al-
ways binary marked Petri nets. As a special form of IPN, the input and output variables of the
control algorithm in the SIPN are treated by interpretation (syntax extension) of the net-
elements place and transition.
In this laboratory timed signal interpreted Petri-nets (tSIPN) are used [REF GEORG].
A tSIPN is defined as a 10-Tuple SIPN = (P, T, F, m0, I, O, ϕ, ω, Ω, τ) with
(P, T, F, m0) a normal Petri-net with places P, transitions T, directed arcs F and a Boolean
initial marking m0. |P|, |T|, |F| > 0
I a set of binary input signals with |I| > 0
O a set of binary output signals with I ∩ O = ∅, |O| > 0
ϕ a mapping that assigns a switching condition ϕ(ti) = boolean function in I to each transi-
tion ti ∈ T
ω a function that assigns an output ω(pi) ∈ (0, 1, -)|O| to each place pi out of P. "-" means
"not defined".
Ω the output function which combines the output functions of all marked places to the
total output of the SIPN: Ω: m → (0, 1, -, c)|O|. The total output can have the following
values: zero (0), one (1), not defined (-) or contradictory defined (c).
τ a mapping that links each edge fi ∈ (P × T) ∩ F that goes from a place to a transition to
a time delay τi ∈ R0+. With fi = (pj, tk), τi is the minimum time the token must spend in
place pj before tk can fire.

3.2.1 Dynamic behaviour


The dynamic behaviour of a tSIPN is defined by the firing process and is given by four rules.
1. A transition can fire if all its pre-places contain a token and all its post-places are un-
marked. If the connections are time-rated, the token must have spent the minimum time in
the place.
2. A transition fires as soon as it can fire and its firing condition is fulfilled.
3. All transitions that can fire simultaneously and that are not in conflict will fire simultane-
ously.
Module 2 Page 5 of 12

4. The firing process is continued until a stable marking is reached (i.e. no transition can fire
without changing the input signals).
When a stable mark is reached, the output signals are recalculated by function Ω.
The firing process can be accomplished by the algorithm in figure 2.

Figure 2 Firing process

3.2.2 Semantic
Places have action character: If they are marked, they influence the process via outputs or
provide the operator with information. At the same time, they have a static character, since the
marking is associated with a time duration. If a fixed time relationship is required, the mini-
mum duration for marking a place can be determined by the pre-edge time rating τ.
On the other hand, transitions have a transfer character, they receive information from the
process or the operator via input signals. Each transition is assigned a firing condition, which
is a Boolean function of the input variables.
The firing itself is time-free, in other words infinitely short.
With each marking of the SIPN, each individual marked place with its output function influ-
ences the total output of the net. The output of a SIPN results from the overlapping (product)
of the output functions of simultaneously marked places. The output variables are assigned
either the value one or the value zero. If, on the other hand, an output variable is not ad-
dressed, its value is initially undetermined. Figure 3 shows an example of a SIPN:
Module 2 Page 6 of 12

S1
A1=1;

τ = 2,1 sec
T1 T3
/E1 ∨ /E2 E1 ∧ E2
S2 S3
A2=1; A1=1; A4=1;
T2 S5 T4
E1 A3=1; E1
S4
A1=1;
T5
E1

Figure 3 tSIPN

3.3 Conditions for correct SIPN


Since SIPN describes a control algorithm to be executed automatically, they must be formally
correct, i.e. they have to fulfill the following criteria:
(1) Consistency of output
Contradictory specifications for the assignment of the output signals in the control algo-
rithm must not occur at any time. This means for the Petri net: For no marking in the Petri
net an output must not be set to one and zero at the same time. Such an algorithm does not
make sense because the behavior of the process to be controlled cannot be predicted. The
actuator itself would have to decide whether it reacts to zero or one.
(2) Complete assignment of output
A distinct value must be assigned to each output signal at each marking in the SIPN. Oth-
erwise the value is not defined.
(3) Terminism
Cyclic algorithms have to ensure at all times that the output is at least temporarily constant
and defined. In addition to the mentioned criteria of completeness and consistency it is
meant in this context that at least one output enabled by marking a place is not immediately
disabled again by firing a transition.
(4) Determinism
In control algorithms, all decisions have to be solved unambiguously, since the automation
device executing the algorithm does not have any further decision mechanisms. For exa-
mple, the following SIPN is given in figure 4:
~
S1
Drive empty or acknowledge?
T1 T2
Drive empty Acknowl. button pressed
E 0.2 E 0.3
~ ~
Figure 4 Network section with non-disjunctive firing condition
Module 2 Page 7 of 12

In the case that E0.2 and E0.3 are fulfilled simultaneously, an undetermined switching
would be possible. A possible solution is the introduction of a disjunctive switching condi-
tion, e.g. SB(T2) = E0.3 ∧ E0.2 .

Two additional conditions often imposed on SIPN are deadlock freedom and reversibility:
Deadlock free
Usually control algorithms are designed in cyclic form. Alternatively, it is possible to de-
sign a control algorithm with start and end positions that are not identical. It must not
happen that the token in a marked place, which is not the end place, can never be removed,
because its following transition never becomes fireable/enabled. The algorithm would get
stuck in this situation. Two types of deadlock can be distinguished here: A partial deadlock
would only affect this one transition, which can never fire. On the other hand, a total dead-
lock describes the state in which no transition can fire in the entire Petri net.
Reversibility
Reversibility means that the algorithm can reach its initial state again. This is an important
condition to check if a restart within the system is possible.

3.4 Reachability graph


Firing a concessionary transition t under a marking m in a Petri net generates a new marking
m’.
It is said: m’ is directly reachable from m (or following marking).
If a transition t’ can fire under marking m’ and generates marking m’’, then m’’ is reachable
from m via the firing sequence <t, t’>.
In general, a marking m2 is called reachable from a marking m1 if a firing sequence exists that
leads from m1 to m2.
The reachability set EM of a Petri net PN = (P, T, F, m0) consists of the initial marking m0
and all markings that can be reached from m0.
The reachability graph EG is a graph EG = (EM, E ⊆ EM × EM T) with the reachable
markings as nodes. An edge e ∈ E with e = (mi, mk) tS indicates that the marking mk is
directly reachable by firing transition tS from marking mi. The edges of the graph are labeled
with the corresponding transition, the nodes with the markings.
Module 2 Page 8 of 12

Example:
P1 P2

T1 T2 T3
P3
P6

T4 T5

P4 P5

T6

100001

t2

t4
001001 000101

t5 t1 t1
101000
t4 100100
000011

t1 t5 t2
t3
100010 001100 010100

t5
t2 t4
001010 000110
t3
t6
t3 t1 t4
010001 110000
t3 t2
010010 011000
t5

Figure 5 Petri net with reachability graph

For SIPN the reachability has to be redefined first:


A marking m2 is directly reachable from another marking m1 if there exists an input signal
assignment in such a way that starting from m1 the next stable marking is m2 by firing one or
more transitions simultaneously or iteratively.
On the basis of this definition, reachability, reachability set and reachability graph can be de-
fined analogously to the condition/event net.
Module 2 Page 9 of 12

Expansions in reachability graph:


• In the reachability graph, the SIPN output is now written to the states in addition to the
marking
• The involved transitions and the input signal assignment are noted at the transitions

Example:

SIPN ω(p1)= (-,0,1) RGSIPN

m0=(1,0,0,0,0,0) t5: ¬i1∧i2∧¬i3


φ(t1) = i3
Ω(m0) = (-,0,1)
ω(p2)= (0, 1, 0)

φ(t2) = i3 ∨ i4 t1→t2: i3 ∧¬i1

t1→t2→t3→t4: i3∧i1
ω(p3): o3 = 1 ω(p5)=(1,0,-)

φ(t3) = i1 φ(t4) = i1 m1=(0,0,1,0,1,0) m2=(0,0,0,0,1,1)


Ω(m1) = (1,0,1) t3→t4: i1 Ω(m2) = (c,0,1)
ω(p4)=(0,0,-) ω(p6)=(1,0,1)

φ(t5) = ¬i1 ∧ i2 ∧¬i3


Figure 6 SIPN with reachability graph

3.5 Analysis with reachability graph


For the analysis on the reachability graph the terms livelock and deadlock are required:
Livelock: Strongly connected component in the reachability graph without leaving edges
Deadlock: Single node in reachability graph without leaving edges
Module 2 Page 10 of 12

Deadlocks

Livelocks

Figure 7 Petri-net with livelocks und deadlocks.

(1) Consistency of output


Can be read directly from the outputs of the states: No c
(2) Complete assignment of output
Can be read directly from the outputs of the states: No -
(3) Terminism
A cycle without stable marking appears in the reachability graph as a loop at a node (edge
of the node lead back to itself)
(4) Determinism
Conflicts can be recognized in the reachability graph by the fact that several edges lead
away from a node and the written firing conditions are not disjunct

Deadlock free net (Liveness)


EG contains no deadlocks,
All livelocks in EG contain all transitions

Reversibility
EG contains no deadlocks,
EG contains exactly one livelock,
Initial marking m0 is contained in this one livelock
Module 2 Page 11 of 12

4 Recommendations for SIPN design


SIPNs should not exceed a certain size (DIN A4) in order to maintain a clear overview. How-
ever, since algorithms can be quite complex, the use of the so-called hierarchy, a refinement
of places, is recommended. Each (sub)net can have one or more subnets. In the hierarchy,
refined places represent those subnets, see Figure 8. The refined places as well as the entry
and exit places of the subnet are shown in grey.

Rest

START
Fast heating up to 180° C
Fill with 10° C/min

Fill level
Mix 180° C reached
reached

Heat 5 min

400° C Waiting time


reached finished

Empty Heating up to 200° C


with 1° C/min
Reactor
emptied

Figure 8 Hierachy

If the heating place of the main net is marked, the corresponding subnet is processed, i.e. the
grey input place "Fast heating up to 180°C with 10°C/min" is marked. The algorithm has to
first pass through the subnet. Only when the starting position "heating up to 200°C with
1°C/min" is marked, the transition "200°C reached" is concessioned/enabled in the main net.
It is therefore a kind of macro technique.
Concurrent actions in the Petri-net can also increase transparency if they are used wisely. Ac-
tions that are enabled parallel to a certain process with a constant value should therefore be
listed in the control algorithm. The rotation of the turntable serves as an example, see figure 9.
The transparency is created by graphical visualization of the actual control process. In gen-
eral, this means that the active output of the SIPN can be read directly and easily at the
marked positions in any state (which corresponds to the marking of the SIPN).
Module 2 Page 12 of 12

~ ~
S1 S1
T1 T1
Start button pressed Start button pressed
E0.1 E0.1
S2 S4
Turntable motor on S2
Turntable motor on Turntable rotates
A1.4=1; A1.4=1;
T2 T2
Turntable not in position Turntable not in position
NOT E2.2 NOT E2.2
S3
Turntable rotates to position S3
A1.4=1; Turntable rotates to position
T3 T3
Turntable in position Turntable in position
E2.2 E2.2
S4 S5
Turntable motor off Turntable motor off
A1.4=0; A1.4=0;

~ ~
Figure 9 Net section without concurrency, net section with concurrency

Pre-edges time rating is to be used if and only if a process cannot be completely observed by a
sensor. A transition with time-valuated pre-edges is ready for operation when the concession
and synchronization rules have been fulfilled and the time duration τ specified at the edge has
passed. An example of such a process is the baking of a cake. The corresponding algorithm is
shown in figure 10. Since you usually don't have a sensor that recognizes that the cake is
baked, you stop baking after a certain time (here: τ = 45 time units). Then the oven door will
be opened.
~
S1
Bake cake
τ = 45
T1
S2
Open oven door
~
Figure 10 Pre-edge time rating
Control of a production plant with PLC
Authors: Georg Frey and Stéphane Klein
Translation: Marcel Krames and Raphael Fritz
Supervision: M.Sc. Raphael Fritz

Module 3
Simatic STEP7

Topic:
1 GENERAL INFORMATION ABOUT PLC-PROGRAMMING WITH STEP7 ................................. 2
2 DESCRIPTION OF PROGRAMMING LANGUAGES .................................................................... 2
2.1 IL, FBD, LD ................................................................................................................................ 2
2.2 S7-Graph.................................................................................................................................... 5
Module 3 Page 2 of 6

1 General information about PLC-programming with STEP7


The PLC (programmable logic controller) runs through the block OB1 (organization block 1)
cyclically with a cycle time of a few to a several hundred milliseconds, depending on the pro-
gram length. This block can contain the entire program for small applications. However,
normally it only consists of block calls of program blocks or functions, which together make
up the entire program. These blocks are then executed one after the other in the order in which
they are listed in OB1. Only after each cycle of OB1 the output terminals are assigned with
the states which have resulted from the processing of the program for the outputs and the sig-
nal states of the inputs are read out. For the inputs, this means that their state is stored for the
duration of a program cycle and a signal change cannot be detected until the cycle time has
passed. For the outputs, this means that if an output is changed at different points in the pro-
gram, only the last change has an effect, because the signals are only then applied to the
output terminals.
In this experiment, a Siemens S7-300 is used as the controller. Apart from the analog inputs
and outputs, which are not used in this experiment, it has 32 binary inputs and outputs each.
The programming environment is called STEP7 and can be assembled modularly from differ-
ent programming languages.
There are two fundamentally different types of PLC languages:
• In one case, the controller checks all conditions during each program cycle. As a result,
conditions that trigger unwanted actions in a given situation may be easily fulfilled. The
'classical' PLC languages belong to these languages: Instruction list (IL), function block
diagram (FBD) and ladder diagram (LD).
• The other type includes the language S7-Graph from Siemens. In a S7-Graph, the program
is written as a step chain. There is always an active step in which certain actions are exe-
cuted. Only the switching condition to the next step is checked here. This means that large
parts of the program are skipped.
All languages support symbolic names for inputs, outputs and variables. The symbol table is
already available in the laboratory test. Therefore, the programs can be entered/written imme-
diately with symbolic names.
The local variables still have to be entered in the declaration window of the self-written
blocks. In Step7 it is possible to define 5 different types of local variables. They differ in the
direction in which they are transferred from one program to the other, or whether they are
only used in the program in which they are defined.

• IN : Variable which is transferred from the calling program to the subprogram


• OUT : Variable which is returned to the calling program
• IN-OUT : Variable which is transferred in both directions
• STAT : Static internal variable which keeps its previous value for each program
cycle
• TEMP : Temporary internal variable which has a preset value at the beginning of
each program cycle

2 Description of programming languages


2.1 IL, FBD, LD
The programming languages IL (instruction list), FBD (function block diagram) and LD (lad-
der diagram) are only different representations of an identical program structure. If
programmed correctly, they can be fully converted into each other. The program consists
Module 3 Page 3 of 6

mainly of Boolean algebra formulas. Counters, time elements or algebraic operations can be
implemented additionally.
For programming, exactly one network has to be provided for each output or flag (Boolean
variable) if it is an assignment, and exactly two if the output or flag is to be set and reset as
stored. A network corresponds to the condition for an action in the form of an AND/OR in-
struction. An assignment means that the output is only assigned with ' 1' as long as the
condition for the output is fulfilled. If the output is set stored, it keeps the '1' signal until the
reset condition is fulfilled. A network is required for the set and reset conditions.
As already mentioned, if you program several assignments of an output at different points that
contradict each other, the signal that was generated during the last assignment is transferred to
the output. Since this may lead to errors, the rule mentioned above should be followed. How-
ever, this also means that if the set and reset conditions are fulfilled simultaneously for one
output, the action behind the other in the program sequence is valid. Therefore, normally the
set network is written before the reset network so that a reset priority is given.

For the use of timers, the following time elements are common:

1. Switch-on delay:
The time starts with a positive edge at the input of the timer. After the time has elapsed,
the output becomes '1'. With a negative edge at the input, the output becomes '0' again. If
the negative edge at the input comes before the time has elapsed, the output remains at '0'.
2. Switch-off delay:
The output immediately switches to '1' if there is a positive edge at the input. The time
starts at the negative edge at the input of the timer. After the time has elapsed, the output
becomes '0' again.
3. Impulse:
If the edge at the input is positive, the output immediately goes to '1' and the timer starts.
After the time has elapsed, the output becomes '0' again. If the negative edge at the input
comes before the time has elapsed, the output immediately returns to '0.

There are also three different types of counters: the forward counter, the reverse counter, and
a counter with one input for forward counting and one for reverse counting. Counting always
starts with a positive edge at the counting input. All counters have two outputs at which the
current counter value is present, one as a dual number and the other as a decimal number. Fur-
thermore, they have a binary output which is only '0' if the counter value is '0', and otherwise
'1'. Besides the counter inputs, there is also a reset input and two inputs to preset the counter
to a certain value.
Because of the faster entry, it is advised to enter the program in IL. However, the view in the
program editor should be changed from time to time to the other two languages in order to
understand them as well. For reasons of conversion, it is important to make sure that there is
only one assignment, one set command or one reset command in each network. The pro-
gramming of timers and counters alone is easier in the other two languages and should be
implemented there. This also has the advantage that the program can always be displayed in
all three languages. To do this when entering the program in IL, the instruction NOP (no op-
eration) has to be used instead of the unused inputs and outputs for timers and counters.

Explanations for IL:


Boolean formulas are entered in IL using the shortcuts U (And), O (Or), UN (And Not), and
ON (Or Not). The assignment is marked with '=', the letter 'S' is used for setting and the letter
'R' is used for resetting. The use of shortcuts and parentheses are explained in the following
Module 3 Page 4 of 6

examples. Instead of the absolute addresses, the symbolic addresses will appear in the pro-
gram to be written.

Verbale Beschreibung AWL


While E 0.0 is '1', A 0.0 should be '1' U E 0.0
= A 0.0
While E 0.0 is '0', A 0.0 should be '1' UN E 0.0
= A 0.0
If E 0.0 is '1', set A 0.0 to '1' U E 0.0
S A 0.0
If E 0.1 is '1', reset A 0.0 U E 0.1
R A 0.0
While E 0.0 is '1' and either E 0.1 is '1' or E U E 0.0
0.2 is '0', A 0.0 is '1' U(
U E 0.1
ON E 0.2
)
= A 0.0
While E 0.0 is '0' or E 0.1 is '0' as well as E UN E 0.0
0.2 is '1', A 0.0 shall be '1' O(
UN E 0.1
U E 0.2
)
= A 0.0
Table 1 Example for IL-Programming

It should always be ensured that the parentheses are correctly placed, otherwise the program
would not be able to be displayed in the other languages either.
Every line at the beginning of a network or a parenthesis has to be started with U, UN, O or
ON. Beginning with U or O has no influence on the function.
Like inputs, the signal states of outputs, flags, counters (e.g. Z1) and timers (e.g. T1) can also
be read.

Explanation for FBD:


In this language, the Boolean formulas are entered as in graphic representations in digital
technology. So the program consists of rectangles, the gates that are connected to each other.
They contain the symbols '&' for the AND gate and '>=1' for the OR gate. Negations at inputs
and outputs are represented as circles. The rectangles for the assignments, set and reset opera-
tions contain the letters of the IL.

Explanation for LD:


This language originated from relay technology. It symbolizes current paths. And-operations
correspond to series-connections and OR-operations correspond to parallel-connections. The
operands in the conditions have the following form:

Not negated operand:

Negated operand:
Module 3 Page 5 of 6

The assignment is represented by open and closed round parentheses on the right side. For set
and reset operations, these parentheses contain the letters 'S' or 'R'.

Explantion for timers and counters:


The representation of counters and timers are identical in FBD and LD.
Up counter Down counter

Z_VORW Z_RUECK
ZV Q ZR Q

S DUAL S DUAL

ZW DEZ ZW DEZ

R R

ZV and ZR are the counting inputs. At input ZW, the number (e.g. C#5 for the number 5) is
entered which is to be loaded into the counter when a positive edge at input S is detected. As
long as a '1' signal is connected to the reset input R, the counter is kept at '0'. Q is the binary
output. The current counter value is present at DUAL and DEZ as a dual or decimal number.

On-dealy Off-delay Pulse

S_EVERZ S_AVERZ S_IMPULS


S DUAL S DUAL S DUAL

TW DEZ TW DEZ TW DEZ

R Q R Q R Q

Input S has to be connected to the signal that starts the timer. The time duration is entered at
input TW (e.g. S5T#500MSnfor the value 500ms). The outputs and the reset input have the
same functions as the counter.

2.2 S7-Graph
The step chain in the S7-Graph is processed as follows: The program starts in a so-called ini-
tialization step, which is specially marked in the editor (double frame). Each step is followed
by a transition with a corresponding condition. If the condition is fulfilled, the next step be-
comes active by executing the actions of this step. Only one step can be active at one time.
Conditions must be programmed as AND/OR instructions in the ladder diagram (LD).
Branches can be made after a step, so alternative branches must always begin with a transi-
tion. After a transition, it is possible to insert a jump that has to lead to a step.
The following operations are sufficient for the program to be written:
N The output or flag is only '1' when the step is active
S The output or marker is set to '1' and remains '1' even beyond the step
R A set output or flag is reset again
D The output or marker becomes '1' with a time delay and goes back to '0' when
leaving the step (for entering the time see example)
Module 3 Page 6 of 6

CALL Block call that is executed cyclically when the step is active
S0 CALL Block call that is executed only once when the step is exited

Figure 1 shows an example of an S7-Graph program. It has nothing to do with the program to
be written and only serves to understand the structure of a step chain. The two arrows in the
program represent a jump. The arrows always show the destination or source address.

Figure 1 Example program for S7-Graph


Control of a production plant with PLC

Authors: Georg Frey and Stéphane Klein


Translation: Marcel Krames and Raphael Fritz
Supervision: M.Sc. Raphael Fritz

Module 4
Description of the control system

Topic:
1 INFORMAL DESCRIPTION OF THE ENTIRE PROGRAM ............................................................2
1.1 PROGRAM STRUCTURE ...................................................................................................................2
1.2 DEFINITION OF OPERATING STATES .................................................................................................2
1.3 DESCRIPTION OF THE PROCESS IN AUTOMATIC MODE .......................................................................2
1.4 DESCRIPTION OF THE PLANT BEHAVIOUR IN THE OTHER OPERATING MODES ......................................4
2 SUBDEVISION INTO DIFFERENT PROGRAM MODULES ..........................................................6
2.1 OVERVIEW OF THE MODULE STRUCTURE .........................................................................................6
2.2 DEFINITION OF INTERFACE VARIABLES AND LOCAL VARIABLES ...........................................................7
3 EXACT TASK DESCRIPTION OF THE INDIVIDUAL MODULES ...............................................14
3.1 MODE .........................................................................................................................................14
3.2 FEEDER.......................................................................................................................................14
3.3 DRILL ..........................................................................................................................................15
3.4 VMILL ..........................................................................................................................................15
3.5 HMILL ..........................................................................................................................................16
3.6 STORAGE ....................................................................................................................................17
Module 4 Page 2 of 17

1 Informal description of the entire program


1.1 Program structure
Main program

Mode Feeder Drill Vmill Hmill Storage

Hand- Pause-
mode mode

The main program consists only of the block calls of the six mentioned program modules. It is
written in IL (instruction list). The calls are made cyclically in the order from left to right. The
module Mode is to be programmed in sequential function chart and calls in the relevant steps
the modules Hand-mode or Pause-mode.

1.2 Definition of operating states


The controller distinguishes between six different operating states of the system. It starts in
Stop-mode, in which all motors are stopped. By pressing the INIT-button the Hand-mode is
activated. In Hand-mode, the tool on the vertical milling machine is changed each time the
INIT-button is pressed. From this mode, as from any other operating mode, the STOP-button
is used to return to the Stop-mode. By pressing the START-button, the Init-mode is started
first, in which the plant is moved to its initial position. Once this is reached, the system auto-
matically switches to Automatic-mode. The processing of the workpieces can be interrupted
at any time by pressing the START-button. For this purpose, the plant runs into the Pause-
mode. Pressing the START-button again returns the plant to the Automatic-mode. The pro-
cessing can be ended regularly by pressing the CLEAR STOP-button. In this case, the plant
first switches to the Clear-mode. All the workpieces which are still on the belts are finished
here. Then the plant automatically switches to the Stop-mode.

1.3 Description of the process in automatic mode


As soon as the feeder contains workpieces and the conveyor belt is free in front of the drill, a
workpiece should be pushed out of the feeder. The conveyor belt is considered to be 'free' if at
most one workpiece is located at the end of the conveyor belt. Each conveyor belt transports
an incoming workpiece immediately into the working position. The operating cycles are as
follows:
1.3.1 Drill:
As soon as the sensor detects a workpiece in front of the drill, the tool motor starts and the
drilling head moves downwards and upwards again when the lower limit switch is reached.
The tool motor also stops at the upper limit switch. Then the conveyor belt moves until the
sensor no longer registers the workpiece. The drilling process described above now starts a
second time.
Module 4 Page 3 of 17

1.3.2 Vertical mill:


As soon as the sensor in front of the vertical mill detects the workpiece, the tool motor also
starts up and the milling head moves to the lower limit switch and up again. At this point the
tool motor stops and the tool is changed in right-hand rotation. This process takes place three
times until the workpiece has been processed with each tool and the first tool points down-
wards again.

1.3.3 Horizontale mill:


Also here the '1' signal of the sensor in front of the milling machine starts the tool motor and
the milling head moves downwards. When it reaches the lower limit switch, the machine
moves forward. Once there, the belt moves a little further until the sensor no longer registers
the workpiece. The vertical mill then moves back again. Only in the back position the milling
head moves upwards again and the tool motor stops.

1.3.4 Conveyor belts


After processing, the respective conveyor belts only transport the workpiece to the end of the
belt when the belt of the next machine is empty, or in the case of the horizontal mill when the
storage is not yet full.

1.3.5 Interactions of the components


Figure 1 describes the process again graphically in the form of a Gantt-chart. This diagram
shows the chronological sequence of the work steps (T1 to T16), whereby the three machines
can be seen independently of each other and are not synchronized with each other, as would
be assumed in the diagram. The movements of the conveyor belts and the machines always
end when a limit switch is reached. Exceptions are the fields marked by (*). The belt is al-
ready stopped at these points when the current position sensor has just returned to '0'.
Module 4 Page 4 of 17

Operation

T10
T11
T12
T13
T14
T15
T16
T17
T18
T19
T20
T21
T1
T2
T3
T4
T5
* T6
T7
T8
T9
Conveyor
Lower Drill
Drill

Raise Drill
Drill on
Drill off
Conveyor
Lower Mill
Vertical Mill

Raise Mill
Rotate Mill
Mill on
Mill off
Conveyor
*

Lower Mill
Horizontal Mill

Raise Mill
Mill forward
Mill back
Mill on
Mill off
Figure 1 Gantt-Chart for automatic mode

1.4 Description of the plant behaviour in the other operating modes


1.4.1 Init-mode:
The chain of the feeder is moved into a defined position and thus prepared to push a work-
piece out of the feeder at the next startup. The conveyor belts stay in position because it is
assumed that there are no workpieces on them and therefore the position of the conveyor belts
is irrelevant. All machines are moved to the upper end position, the horizontal mill also to the
back limit position. The tool motors, like the conveyor belts, can be disregarded, since the
Init-mode can only be reached from the Stop-mode and all motors have already been switched
off there.

1.4.2 Pause-mode:
Already running cycles are finished and then the machine is stopped. One of the cycles is the
transport of a workpiece from one sensor to the next or out of the feeder. A processing cycle
on the machine is considered to be completed, except after machining has been finished, at the
following points: In the case of the drill, when the machine head is at the upper end position
after the first drilling operation and the workpiece has already been moved further; In the case
of the vertical mill, when the machine head is at the upper end position and the tool has been
changed; In the case of horizontal mill, when after the first processing step the machine head
is at the bottom and front and the workpiece has already been moved further.
Module 4 Page 5 of 17

1.4.3 Clear-mode:
The machines continue to run all possible operations of the automatic mode. The only differ-
ence is that the feeder does not push any more workpieces onto the conveyor belt.

1.4.4 Stop-mode:
All motors will be stopped immediately..

1.4.5 Hand-mode:
Since the control system cannot detect which of the three tools of the vertical mill is pointing
downwards, there has to be a possibility to operate the tool changer manually. This is possible
in the Hand-mode by pressing the INIT-button. The tool is already changed for the first time
when the button is pressed in Stop-mode, which leads to the Hand-mode.
Module 4 Page 6 of 17

2 Subdevision into different program modules


2.1 Overview of the module structure
The following section defines six modules, each of them forming a logical unit based on their
tasks. There is also another program, the organization block, which only consists of calls to
the actual program modules that are processed cyclically. To distinguish the workpieces, a
further module would be necessary, but this function is no longer part of this laboratory ex-
periment. The program modules used are as follows:

Module(german) English name Symb. name Description

Betriebsmodus- Operation-Mode Mode Supervises the actuation of the buttons


Überwachung Supervision and controls the operating modes and
LEDs of the buttons

Magazin Feeder Feeder Pushes a workpiece onto the conveyor


belt depending on the operating mode
and controls the FEEDER EMPTY
LED

Bohrmaschine Drill Drill Controls the drill with conveyor belt

Vertikale Fräse Vertical Mill Vmill Controls the vertical mill with convey-
or belt

Horizontale Fräse Horizontal Mill Hmill Controls the horizontal mill with con-
veyor belt

Rollenlager Storage Storage Supervises incoming workpieces and


controls the LED STORAGE FULL

Table 1 Definition of program modules

The modules only communicate with each other via global variables. These variables contain
information on the operating status of the plant, the initial position of the machines and the
presence of a workpiece in a machine module.

In addition, the inputs and outputs are always allocated to only one module. For example, the
sensors at the transitions between the conveyor belts are always allocated to the next module.
The information that a workpiece has reached the next conveyor belt is therefore not received
directly by the module from the sensor, but only via the variable that indicates that a work-
piece is located in the next module. This simplifies the fault detection in case this sensor is
defective.
Module 4 Page 7 of 17

2.2 Definition of interface variables and local variables


2.2.1 Explanations for the variables:
All variables used in the respective module are listed below. The inputs and outputs can be
global flags (M) for communication between the modules as well as signals from the plant (E)
or to the plant (A).

The local variables, if available, are listed in a third table. With Step7 it is possible to define 5
different types of local variables. They differ in the direction in which they are transferred
from one program to another, or whether they are only used in the program in which they are
defined.

• IN : Variable which is transferred from the calling program to the subprogram


• OUT : Variable which is returned to the calling program
• IN-OUT : Variable which is transferred in both directions
• STAT : Static internal variable which keeps its previous value for each program
cycle
• TEMP : Temporary internal variable which has a preset value at the beginning of
each program cycle

In this program only variables of the types IN and STAT are used.

2.2.2 Module: Mode


Address Variable name Meaning of binary zero Meaning of binary one
M 0.6 feeder_init_state Feeder not in initial position Feeder in initial position
M 1.6 drill_init_state Drill not in initial position Drill in initial position
M 2.6 vmill_init_state Vertical mill not in initial position Vertical mill in initial position
M 3.6 hmill_init_state Horizontal mill not in initial posi- Horizontal mill in initial posi-
tion tion
M 1.7 drill_cleared At least one workpiece in front of Drill cleared
the drill
M 2.7 vmill_cleared At least one workpiece in front of Vertical mill cleared
the vertical mill
M 3.7 hmill_cleared At least one workpiece in front of Horizontal mill cleared
the horizontal mill
E 0.0 stop_button STOP-button pressed STOP-button not pressed
E 0.1 start_button START-button not pressed START-button pressed
E 0.2 clear_button CLEAR-button not pressed CLEAR-button pressed
E 0.3 init_button INIT-button not pressed INIT-button pressed
E 0.4 storage_cleared STORAGE-button not pressed STORAGE-button pressed
E 0.5 feeder_filled_up FEEDER-button not pressed FEEDER-button pressed
Table 2 Input variables of module Mode
Module 4 Page 8 of 17

Address Variable name Meaning of binary zero Meaning of binary one


M 0.0 stop_mode Modules not in Stop-mode Modules in Stop-mode
M 0.1 automatic_mode Automatic-mode not active Automatic-mode active
M 0.2 clear_mode Clear-mode not active Feeder no longer pushes out
any more workpieces
M 0.3 init_mode Init-mode not active Drive to initial positions
M 0.4 pause_mode Pause-mode not active Pause-mode active
M 0.5 tool_changer No influence Tool changer should move to
next position
A 0.0 stop_signal LED STOP off LED STOP on
A 0.1 start_signal LED START off LED START on
A 0.2 clear_signal LED CLEAR-STOP off LED CLEAR-STOP on
A 0.3 init_signal LED INIT off LED INIT on
Table 3 Output variables of module Mode

Address Variable name Meaning of binary one


0.0 (in) verlassen Transfer variable to the respective subprogram. As a result, the re-
spective LED is switched off at the last call.
2.0 (stat) einschalten The time in which the LED should be off has elapsed.
2.1 (stat) ausschalten The time in which the LED should be on has elapsed.
Table 4 Local variables of module Mode

These three variables exist in the two subprograms Mode_Hand and Mode_Pause. The pro-
grams flash the LEDs INIT and START with the help of the local variables.

2.2.3 Module: Feeder


Address Variable name Meaning of binary zerro Meaning of binary one
M 0.0 stop_mode Modules not in Stop-mode Modules in Stop-mode
M 0.1 automatic_mode Automatic-mode not active Automatic-mode active
M 0.2 clear_mode Clear-mode not active Feeder no longer pushes out any
more workpieces
M 0.3 init_mode Init-mode not active Drive to initial positions
M 0.4 pause_mode Pause-mode not active Pause-mode active
M 1.7 drill_cleared At least one workpiece in front of Drill cleared
the drill
E 0.6 feeder_ready Conveyor chain in interim posi- Conveyor chain in initial position
tion
E 0.7 feeder_empty There are workpieces in the feed- Feeder is empty
er
Table 5 Input variables of module Feeder
Module 4 Page 9 of 17

Address Variable name Meaning of binary zerro Meaning of binary one


M 0.6 feeder_init_state Feeder not in initial position Feeder in initial position
A 0.5 feeder_signal LED FEEDER EMPTY off LED FEEDER EMPTY on
A 0.6 feeder_motor Motor conveyor chain off Motor conveyor chain on
Table 6 Output variables of module Feeder

2.2.4 Module: Drill


Address Variable name Meaning of binary zerro Meaning of binary one

M 0.0 stop_mode Modules not in Stop-mode Modules in Stop-mode

M 0.1 automatic_mode Automatic-mode not active Automatic-mode active

M 0.3 init_mode Init-mode not active Drive to initial positions

M 0.4 pause_mode Pause-mode not active Pause-mode active

M 2.7 vmill_cleared At least one workpiece in front of Vertical mill cleared


the vertical mill
E 1.2 drill_top Drill head is at upper limit Drill head is not at upper limit

E 1.3 drill_bottom Drill head is at lower limit Drill head is not at lower limit

E 1.4 drill_entrance No workpiece is at beginning of Workpiece is at beginning of


conveyor belt conveyor belt
E 1.5 drill_position No workpiece is in front of drill Workpiece is in front of drill

Table 7 Input variables of module Drill

Address Variable name Meaning of binary zerro Meaning of binary one

M 1.6 drill_init_state Drill not in initial position Drill in initial position

M 1.7 drill_cleared Modul ist nicht leergefahren Modul ist leergefahren

A 1.2 drill_motor_up Motor up off Motor up on

A 1.3 drill_motor_down Motor down off Motor down on

A 1.4 drilling_motor Motor tool off Motor tool on

A 1.5 drill_conveyor Motor conveyor belt off Motor conveyor belt on

Table 8 Output variables of module Drill


Module 4 Page 10 of 17

Address Variable name Meaning of binary one

0.0 (stat) neues_teil There is a workpiece on the conveyor belt which does not yet have a
hole or where the first hole has just been drilled and the machine
head is on its way up.

0.1 (stat) ein_loch There is a workpiece in front of the drilling machine which has a
hole or where the second hole has just been drilled and the machine
head is on its way up.

0.2 (stat) zwei_loecher There is a workpiece in front of the drill that has two holes but has
not yet been transported to the end of the conveyor belt.

Table 9 Local variables of module Drill

2.2.5 Module: Vmill


Address Variable name Meaning of binary zerro Meaning of binary one

M 0.0 stop_mode Modules not in Stop-mode Modules in Stop-mode

M 0.1 automatic_mode Automatic-mode not active Automatic-mode active

M 0.3 init_mode Init-mode not active Drive to initial positions

M 0.4 pause_mode Pause-mode not active Pause-mode active

M 0.5 tool_changer No influence Tool changer should move to


next position
M 3.7 hmill_cleared At least one workpiece in front of Horizontal mill cleared
the horizontal mill
E 2.2 vmill_top Mill head is at upper limit Mill head is not at upper limit

E 2.3 vmill_bottom Mill head is at lower limit Mill head is not at lower limit

E 2.4 vmill_entrance No workpiece is at beginning of Workpiece is at beginning of


conveyor belt conveyor belt
E 2.5 vmill_position No workpiece is in front of verti- No workpiece is in front of verti-
cal mill cal mill
E 2.6 vmill_tool_ready Tool is in working position Tool is in not working position

Table 10 Input variables of module Vmill


Module 4 Page 11 of 17

Address Variable name Meaning of binary zerro Meaning of binary one

M 2.6 vmill_init_state Vertical mill not in initial posi- Vertical mill in initial position
tion
M 2.7 vmill_cleared At least one workpiece in front Vertical mill cleared
of the vertical mill
A 2.2 vmill_motor_up Motor up off Motor up on

A 2.3 vmill_motor_down Motor down off Motor down on

A 2.4 vmilling_motor Motor down off Motor down on

A 2.5 vmill_conveyor Motor tool off Motor tool on

A 2.6 vmill_change_left Motor tool changer left off Motor tool changer left on

A 2.7 vmill_change_right Motor tool changer right off Motor tool changer right on

Table 11 Output variables of module Vmill

Address Variablen name Meaning of binary one

0.0 (stat) neues_teil There is a workpiece on the conveyor belt that does not yet have a
hole.

0.1 (stat) bearbeitung There is a workpiece in front of the machine that is still being pro-
cessed, or that is already finished, but has not yet been removed.

0.2 (stat) zaehler There is a workpiece on the conveyor belt where not all holes have
been drilled.

0.3 (stat) drehen The machine head was at the lower end position, and the next time
the upper limit position is reached, the tool changer has to be rotated.

0.4 (stat) hand The tool is changed because the INIT button was pressed in Stop- or
Hand-mode.

Table 12 Local variables of module Vmill


Module 4 Page 12 of 17

2.2.6 Module: Hmill


Address Variable name Meaning of binary zerro Meaning of binary one

M 0.0 stop_mode Modules not in Stop-mode Modules in Stop-mode

M 0.1 automatic_mode Automatic-mode not active Automatic-mode active

M 0.3 init_mode Init-mode not active Drive to initial positions

M 0.4 pause_mode Pause-mode not active Pause-mode active

M 3.0 storage_full Storage is not full Storage is full

M 3.1 storage_entrance No influence Workpiece has reached storage

E 3.0 hmill_back Mill head is at back limit Mill head is not at back limit

E 3.1 hmill_front Mill head is at front limit Mill head is not at front limit

E 3.2 hmill_top Mill head is at upper limit Mill head is not at upper limit

E 3.3 hmill_bottom Mill head is at lower limit Mill head is not at lower limit

E 3.4 hmill_entrance No workpiece is at beginning of Workpiece is at beginning of


conveyor belt conveyor belt
E 3.5 hmill_position No workpiece is in front of hori- Workpiece is in front of horizon-
zontal mill tal mill
Table 13 Input variables of module Hmill

Address Variable name Bedeutung der binären Null Meaning of binary one

M 3.6 hmill_init_state Horizontal mill not in initial posi- Horizontal mill in initial posi-
tion tion
M 3.7 hmill_cleared At least one workpiece in front of Horizontal mill cleared
the horizontal mill
A 3.0 hmill_motor_back Motor backwards off Motor backwars on

A 3.1 hmill_motor_front Motor forwards off Motor forwards on

A 3.2 hmill_motor_up Motor up off Motor up on

A 3.3 hmill_motor_down Motor down off Motor down on

A 3.4 hmilling_motor Motor tool off Motor tool on

A 3.5 hmill_conveyor Motor conveyor belt off Motor conveyor belt on

Table 14 Output variables of module Hmill


Module 4 Page 13 of 17

Address Variable name Meaning of binary one

(stat) bearbeitung There is a workpiece in front of the machine that is still being
processed, or the finished workpiece is just being transported to
the warehouse.

Table 15 Local variables of module Hmill

2.2.7 Module: Storage


Addresse Variablenname Meaning of binary zerro Meaning of binary one

E 3.6 storage_sensor No workpiece above the sensor Workpiece above the sensor on
on storage storage

Table 16 Input variables of module Storage

Addresse Variablenname Meaning of binary zerro Meaning of binary one

M 3.0 storage_full Storage is not full Storage is full

M 3.1 storage_entrance No influence Workpiece has reached storage

A 0.4 storage_signal LED STORAGE FULL off LED STORAGE FULL on

Table 17 Output variables of module Storage


Module 4 Page 14 of 17

3 Exact task description of the individual modules


3.1 Mode
3.1.1 Stop-Mode
The module starts in this mode and all motors are switched off (stop_mode and stop_signal
are '1'). From any operating state, pressing the STOP-button (stop_button) will enter the Stop-
mode and all motors will be stopped immediately. Before restarting the system, all workpiec-
es on the conveyor belts should be removed manually..

3.1.2 Hand-Mode
The INIT-button (init_button) can be used to switch from the Stop-mode to the Hand-mode
(init_signal flashes). The first time the button is pressed, a tool change is executed on the ver-
tical mill. In Hand mode, the tool changer is moved one position further each time the INIT-
button is pressed. In order to execute the tool change, the signal tool_changer is set to '1' by
the module Mode as long as the INIT-button is pressed. It is only possible to return from
Hand-mode to Stop-mode by pressing the STOP-button (stop_button).

3.1.3 Init-Mode
If the START-button (start_button) is pressed in Stop-mode, the plant moves to the initial
position (init_mode and init_signal are '1'). When all modules are in the initial position (all
init_state variables are set to '1'), the plant automatically switches to Automatic-mode.

3.1.4 Automatic-Mode
In Automatic-mode, the variable automatic_mode and the output start_signal are '1'.

3.1.5 Pause-Mode
If the START button is pressed in the Automatic-mode, the plant switches to the Pause-mode
(pause_mode is '1' and start_signal flashes). By pressing the START button again, the plant
can be returned to the Automatic-mode.

3.1.6 Claer-Mode
By pressing the CLEAR STOP-button (clear_button) in Automatic-mode, the Clear-mode is
initiated. This is not possible in the Pause-mode. In Clear-mode, the plant is still processing
the workpieces on the conveyor belts. However, no new workpiece is pushed out of the feeder
(clear_mode and clear_signal become '1'; automatic_mode remains at '1'). When all modules
are empty (all cleared variables are set to '1'), the plant switches to the Stop-mode.

3.2 Feeder
Independently in which mode the plant operates, the LED FEEDER EMPTY (feeder_signal)
is switched on after 500ms if the signal feeder_empty has a positive edge. It switches off when
this signal has a negative edge.

3.2.1 Init-Mode
If the variable init_mode is set to '1', the system checks whether the conveyor chain of the
feeder is in one of its defined positions (feeder_ready). Otherwise, the feeder is moved to that
position (feeder_motor). Reaching the initial position is indicated by the variable
feeder_init_state.
Module 4 Page 15 of 17

3.2.2 Automatic-Mode
In Automatic mode, it is checked whether the next module is empty (drill_cleared), and if so,
a workpiece is pushed out of the feeder (feeder_motor). First of all, it is of course checked
whether there are still workpieces in the feeder (feeder_empty is '0'). The signal feeder_ready
reports to the controller whether the workpiece is completely pushed out of the feeder.

3.2.3 Pause-Mode und Clear-Mode


The pushing out of a workpiece is blocked by the variables clear_mode and pause_mode.
However, a running cycle is not interrupted.

3.2.4 Stop-Mode
If the variable stop_mode has a positive edge during the push-out cycle, the motor of the con-
veyor chain is stopped immediately.

3.3 Drill
3.3.1 Init-Mode
In the Init-mode (init_mode is '1') the drill is moved to its initial position. It is assumed that
there are no more workpieces on the conveyor belt. The initial position is reached when the
drill head is in the upper end position (drill_top is '0') and is indicated by the variable
drill_init_state. The module now also sets the variable drill_cleared, so that the module Feed-
er knows that there is no workpiece on the belt of the drill at the first start of the Automatic-
mode.

3.3.2 Automatic-Mode
If a workpiece is at the beginning of the conveyor belt (drill_entrance), the drill_cleared vari-
able is reset. Then the new workpiece is transported to the first working position
(drill_position). After arriving there, the processing begins. The tool motor of the drill (drill-
ing_motor) starts running. At the same time the drill head moves downwards
(drill_motor_down) to the lower limit position (drill_bottom) and moves upwards again
(drill_motor_up) to the upper limit position (drill_top). At this moment the tool motor also
stops. Then the conveyor belt transports the workpiece just forward until the drill_position
signal has become '0'. The workpiece is now in the second working position in which the en-
tire drilling process is repeated. Once the processing cycle has finished, the system checks
whether the next module is empty (vmill_cleared). If yes, the workpiece is transported to the
end of the conveyor (vmill_cleared has become '0'). After reaching this point, the variable
drill_cleared is set again.

3.3.3 Pause-Mode
When the pause_mode signal has a positive edge, the current step will still be executed and
then all motors will be stopped. The Automati-mode resumes seamlessly as soon as the varia-
ble pause_mode has returned to '0'. The processing of the workpiece can only be interrupted
after it has been transported to the second working position.

3.3.4 Stop-Mode
If the stop_mode signal has a positive edge, all motors are stopped immediately.

3.4 Vmill
3.4.1 Init-Mode
In the Init-mode (init_mode is '1') the vertical mill is moved to its initial position. It is as-
sumed that there are no more workpieces on the conveyor belt. The initial position is reached
Module 4 Page 16 of 17

when the milling head is in the upper limit position (vmill_top is '0') and any tool points
downwards (vmill_tool_ready is '0'). The initial position is indicated by the variable
vmill_init_state. The module now also sets the variable vmill_cleared so that the module Drill
knows at the first start of Automatic-mode that there is no workpiece on the conveyor belt of
the vertical mill.

3.4.2 Automatic-Mode
If a workpiece is at the beginning of the conveyor belt (vmill_entrance), the variable
vmill_cleared is reset. Then the new workpiece is transported to the working position
(vmill_position). After arriving there, the processing begins. The tool motor of the milling
machine (vmilling_motor) starts running. At the same time the milling head moves down-
wards (vmill_motor_down) to the lower limit position (vmill_bottom) and moves upwards
again (vmill_motor_up) to the upper limit position (vmill_top). At this moment the tool motor
also stops. Then the tool is changed in right-hand rotation (vmill_change_right). The entire
milling process, including the tool change, is now repeated twice. Once the processing cycle
has finished, the system checks whether the next module is empty (hmill_cleared). If yes, the
workpiece is transported to the end of the conveyor belt (hmill_cleared has become '0'). After
reaching this point, the variable vmill_cleared is set again.

3.4.3 Pause-Mode:
When the pause_mode signal has a positive edge, the current step will still be executed and
then all motors will be stopped. The Automati-mode resumes seamlessly as soon as the varia-
ble pause_mode has returned to '0'. The processing of the workpiece can only be interrupted
directly after a tool change.

3.4.4 Stop-Mode:
If the stop_mode signal has a positive edge, all motors are stopped immediately.

3.5 Hmill
3.5.1 Init-Mode
In the Init-mode (init_mode is '1') the horizontal mill is moved to its initial position. It is as-
sumed that there are no more workpieces on the conveyor belt. The initial position is reached
when the milling head is in the upper limit position (hmill_top is '0') and the machine stand is
in the back limit position (hmill_back is '0'). It is indicated by the variable hmill_init_state.
The module now also sets the variable hmill_cleared so that the module Vmill knows that
there is no workpiece on the conveyor belt of the horizontal milling machine at the first start
of automatic operation.

3.5.2 Automatic-Mode
If a workpiece is at the beginning of the conveyor belt (hmill_entrance), the variable
hmill_cleared is reset. Then the new workpiece is transported to the working position
(hmill_position). After arriving there, the processing begins. The tool motor of the milling
machine (vmilling_motor) starts running. At the same time the milling head moves down
(hmill_motor_down) to the lower limit position (hmill_bottom) and then the machine stand
moves forward (hmill_motor_front) to the front limit position (hmill_front). Then the convey-
or belt transports the workpiece just forward until the signal hmill_position has become '0'.
The workpiece is now in the second working position. Now the machine stand moves back
again (hmill_motor_back) to the back limit position (hmill_back) and then the milling head
moves up (hmill_motor_up) to the upper limit position (hmill_top). The tool motor also stops
at this moment. If the processing cycle has finished, the system checks whether the storage is
Module 4 Page 17 of 17

full. If not (storage_full is '0'), the workpiece is transported to the end of the conveyor belt
(storage_entrance). After reaching this point, the variable hmill_cleared is set again.

3.5.3 Pause-Mode
When the pause_mode signal has a positive edge, the current step will still be executed and
then all motors will be stopped. The Automati-mode resumes seamlessly as soon as the varia-
ble pause_mode has returned to '0'. The processing of the workpiece can only be interrupted
after it has been transported to the second working position.

3.5.4 Stop-Mode
If the stop_mode signal has a positive edge, all motors are stopped immediately.

3.6 Storage
Independently in which mode the plant operates, the variable storage_entrance is set syn-
chronously with the sensor signal (storage_sensor). In addition, a timer is started with each
positive edge of this sensor signal. If the time has elapsed and the sensor signal is still at '1',
the variable storage_full is set to '1'. If the sensor signal has a negative edge, the variable re-
turns to '0'. The LED STORAGE FULL (storage_signal) is controlled synchronously with the
variable storage_full.
Control of a production plant with PLC

Authors: Georg Frey and Stéphane Klein


Translation: Marcel Krames and Raphael Fritz
Supervision: M.Sc. Raphael Fritz

Module 5
Implementation of SIPN in control languages

Topic:
1 INTRODUCTION AND EXAMPLE ..................................................................................................2
2 IMPLEMENTATION IN CONTROL LANGUAGES .........................................................................3
2.1 SEQUENTIAL FUNCTION CHART – SFC............................................................................................3
2.2 TEXTUAL LANGUAGES ....................................................................................................................4
2.3 GRAPHICAL LANGUAGES ................................................................................................................7
3 LITERATURE ................................................................................................................................11
Module 5 Page 2 of 11

1 Introduction and example


In this module, the method for implementing a SIPN in control languages is examined in
more detail. The focus will be on the five languages of the IEC 61131-3 standard [IEC 61131-
3].
The implementation will be presented using the example of a boiler.
The signals used are summarized in the following table:

Input signals Outpur signals


Name Meaning Name Meaning
e1 Tank is empty a1 Mix
e2 Tank is full a2 Fill
e3 Desired temperature reached a3 Heat
e4 Start a4 Empty

The informal specification is as follows:


- If the tank is empty (e1) and the start button is pressed (e4), the tank is filled (a2) up to the
upper level (e2))
- If the liquid does not have the desired temperature, it is heated until it reaches it (e3)
- The warm liquid is mixed for 20 seconds (a1)
- After this mixing time the tank is emptied (a4) to the lower level (e1)
- During filling, heating and emptying, the liquid is mixed

This specification is implemented in the following SIPN (Figure 1).


Explanation of the SIPN:
In the initial position all actions are reset and the system waits for the start signal. When the
tank is empty and the start button is pressed, the transition T1 fires. The mixing motor is then
switched on in position P2, while the tank is filled in position P3. When the liquid has already
reached the desired temperature, transition T4 fires and the liquid is mixed for 20 seconds. If
the incoming liquid has not yet reached the desired temperature, Transition T2 fires and the
liquid is heated until it reaches the desired temperature. Afterwards the transition T3 fires and
starts the 20 seconds mixing phase. Then T5 fires and the tank is emptied until the signal e1
(tank is empty) is set. Finally, after firing the transition T6, the initial state is reached again.
Module 5 Page 3 of 11

Figure 1 SIPN

2 Implementation in control languages


In this section, the implementation of the designed SIPN is presented in detail.
For each IEC 61131-3 language, the implementation starts with the definition of the variables.
Nevertheless, there are differences because not all languages use the same variables. First of
all, the Sequential Function Chart will be introduced before looking at the textual (Instruction
List and Structured Text) and graphical (Ladder Diagram and Function Block Diagram) lan-
guages.
2.1 Sequential Function Chart – SFC
After the definition of the global variable (input and output signals), the sequence is repre-
sented. Only normal actions marked with N will be used. When defining these actions, the
output signal is only set as long as the corresponding place is active. The precondition is that
output signals that are not explicitly set in a marker are set to 0.
For conversion: As already seen, an SFC can only have one start position. For implementing a
SIPN, it first has to be changed so that it only contains one marked place. Then a conflict- and
contact-free SIPN can be converted automatically. The structure remains unchanged.
Module 5 Page 4 of 11

PROGRAM Main
VAR_GLOBAL
e1 AT %IX0.1 : BOOL ;
e2 AT %IX0.2 : BOOL ;
e3 AT %IX0.3 : BOOL ;
e4 AT %IX0.4 : BOOL ;
a1 AT %QX0.1 : BOOL ;
a2 AT %QX0.2 : BOOL ;
a3 AT %QX0.3 : BOOL ;
a4 AT %QX0.4 : BOOL ;
END_VAR

S1

e1 & e4

S2 N a1 S3 N a2

e2 & ¬e3

e2 & e3 S4 N a3

e2 & e3

S5

S5.T=20s

S6 N a4

e1

RET
END_PROGRAM
2.2 Textual Languages
For each place Pi of the SIPN a variable Pi is defined. In the definition of this variables, the
initial marking of the net is entered. In addition, a Boolean variable stable whose initial value
is 1 is defined. This variable is used to check whether the marking reached is stable or not. In
the variable definition the timers are also defined, but only the type of the timer (TON,
TOFF).
After the variable definition, the defined timers are called. The variable to be used as input
and the value of the time delay are defined here.
After defining the variables and calling the timers the code is introduced. First each transition
is coded. Here it is checked that all pre-places are marked, that all post-places are empty and
that the firing condition is fulfilled. If this Boolean expression is true, the pre-places are reset
and the post-places are set. At the same time, the stability variable is reset. After coding the
transitions, the system checks whether the state is stable. If no, the transitions are calculated
again to see if another evolution is possible.
If a stable marking is reached, the defined variable is loaded for each place and the corre-
sponding output signals are set or reset.
Module 5 Page 5 of 11

2.2.1 Instruction List – IL


PROGRAM Main LD P2
ANDN P5
VAR_GLOBAL AND e2
e1 AT %IX0.1 : BOOL ; AND e3
e2 AT %IX0.2 : BOOL ; R P2
e3 AT %IX0.3 : BOOL ; S P5
e4 AT %IX0.4 : BOOL ; R stable
a1 AT %QX0.1 : BOOL ;
a2 AT %QX0.2 : BOOL ; (* Transition T5 *)
a3 AT %QX0.3 : BOOL ; LD P5
a4 AT %QX0.4 : BOOL ; ANDN P6
END_VAR AND T_1.Q
R P5
VAR S P6
P1 : BOOL := TRUE ; R stable
P2 : BOOL := FALSE ;
P3 : BOOL := FALSE; (* Transition T6 *)
P4 : BOOL := FALSE; LD P2
P5 : BOOL := FALSE; AND P6
P6 : BOOL := FALSE; ANDN P1
stable : BOOL := TRUE ; AND e1
T1 : TON ; R P2
END_VAR R P6
S P1
CAL T1 (IN:=P5, PT:=T#20s) R stable

Label_1: LD stable
JMPCN Label_1
LD 1
S stable (* Place P1 *)
LD P1
(* Transition T1 *) R a1
LD P1 R a2
ANDN P2 R a3
ANDN P3 R a4
AND e1
AND e4 (* Place P2 *)
R P1 LD P2
S P2 S a1
S P3 (* Place P3 *)
R stable LD P3
S a2
(* Transition T2 *) R a3
LD P2 R a4
ANDN P4 (* Place P4 *)
AND e2 LD P4
ANDN e3 R a2
R P2 S a3
S P4 R a4
R stable (* Place P5 *)
LD P5
(* Transition T3 *) R a2
LD P4 R a3
ANDN P5 R a4
AND e2 (* Place P6 *)
AND e3 LD P1
R P4 R a2
S P5 R a3
R stable S a4

(* Transition T4 *) RET
Module 5 Page 6 of 11

END_PROGRAM
2.2.2 Structured Text – ST

PROGRAM Main END_IF ;

VAR_GLOBAL (* Tranisition T5 *)
e1 AT %IX0.1 : BOOL ; IF P5 & NOT P6 & T_1.Q THEN
e2 AT %IX0.2 : BOOL ; P5:=0 ;
e3 AT %IX0.3 : BOOL ; P6:=1 ;
e4 AT %IX0.4 : BOOL ; stable := 0 ;
a1 AT %QX0.1 : BOOL ; END_IF ;
a2 AT %QX0.2 : BOOL ;
a3 AT %QX0.3 : BOOL ; (* Tranisition T6 *)
a4 AT %QX0.4 : BOOL ; IF P2 & P5 & NOT P1 & e1 THEN
END_VAR P5:=0 ;
VAR P6:=1 ;
P1 : BOOL := TRUE ; stable := 0 ;
P2 : BOOL := FALSE ; END_IF ;
P3 : BOOL := FALSE;
P4 : BOOL := FALSE; IF stable = 0 THEN JMP label_1 ;
P5 : BOOL := FALSE; END_IF ;
P6 : BOOL := FALSE;
stable : BOOL := TRUE ; IF P1 THEN
T1 : TON ; a1 := 0 ;
END_VAR a2 := 0 ;
a3 := 0 ;
CAL T1 (IN:=P5, PT:=T#20s) a4 := 0 ;
END_IF ;
Label_1
IF P2THEN
stable := 1 a1 := 1 ;
END_IF ;
(* Tranisition T1 *)
IF P1 & NOT P2 & NOT P3 & e1 & e4 IF P3 THEN
THEN a2 := 1 ;
P1:=0 ; a3 := 0 ;
P2:=1 ; a4 := 0 ;
P3:=1 ; END_IF ;
stable := 0 ;
END_IF ; IF P4 THEN
a2 := 0 ;
(* Tranisition T2 *) a3 := 1 ;
IF P3 & NOT P4 & e2 & NOT e3 THEN a4 := 0 ;
P3:=0 ; END_IF ;
P4:=1 ;
stable := 0 ; IF P5 THEN
END_IF ; a2 := 0 ;
a3 := 0 ;
(* Tranisition T3 *) a4 := 0 ;
IF P4 & NOT P5 & e2 & e3 THEN END_IF ;
P4:=0 ;
P5:=1 ; IF P6 THEN
stable := 0 ; a2 := 0 ;
END_IF ; a3 := 0 ;
a4 := 1 ;
(* Tranisition T4 *) END_IF ;
IF P3 & NOT P5 & e2 & e3 THEN
P3:=0 ; RET ;
P5:=1 ;
stable := 0 ; END_PROGRAM ;
Modul 7 Seite 7 von 110

2.3 Graphical Languages

2.3.1 Ladder Diagram – LD


The implementation of the SIPN in LD follows the same rules as the implementation in the
text languages.

PROGRAM Main

VAR_GLOBAL
e1 AT %IX0.1 : BOOL ;
e2 AT %IX0.2 : BOOL ;
e3 AT %IX0.3 : BOOL ;
e4 AT %IX0.4 : BOOL ;
a1 AT %QX0.1 : BOOL ;
a2 AT %QX0.2 : BOOL ;
a3 AT %QX0.3 : BOOL ;
a4 AT %QX0.4 : BOOL ;
END_VAR

VAR
P1 : BOOL := TRUE ;
P2 : BOOL := FALSE ;
P3 : BOOL := FALSE;
P4 : BOOL := FALSE;
P5 : BOOL := FALSE;
P6 : BOOL := FALSE;
stab : BOOL := TRUE ;
T1 : TON ;
END_VAR

CAL T1 (IN:=P5, PT:=T#20s)

| |
START:
| stab |
+----------------------------------------------------(S)--+
| |
(* Transition T1 *)
| |
| P1 P2 P3 e1 e4 P1 |
+--| |--|/|--|/|--| |--| |------------------------+--(R)--+
| | |
| | P2 |
| +--(S)--+
| | |
| | P3 |
| +--(S)--+
| | |
| | stab |
| +--(R)--+
| |
(* Transition T2 *)
| |
| P3 P4 e2 e3 P3 |
+--| |--|/|--| |--|/|-----------------------------+--(R)--+
| | |
| | P4 |
| +--(S)--+
| | |
| | stab |
Modul 7 Seite 8 von 11

| +--(R)--+
| |
(* Transition T3 *)
| |
| P4 P5 e2 e3 P4 |
+--| |--|/|--| |--| |-----------------------------+--(R)--+
| | |
| | P5 |
| +--(S)--+
| | |
| | stab |
| +--(R)--+
| |
(* Transition T4 *)
| |
| P3 P5 e2 e3 P3 |
+--| |--|/|--| |--| |-----------------------------+--(R)--+
| | |
| | P5 |
| +--(S)--+
| | |
| | stab |
| +--(R)--+
| |
(* Transition T5 *)
| |
| P5 P6 T1.Q P5 |
+--| |--|/|--| |----------------------------------+--(R)--+
| | |
| | P6 |
| +--(S)--+
| | |
| | stab |
| +--(R)--+
| |
(* Transition T6 *)
| |
| P2 P6 P1 e1 P2 |
+--| |--| |--|/|--| |-----------------------------+--(R)--+
| | |
| | P6 |
| +--(R)--+
| | |
| | P1 |
| +--(S)--+
| | |
| | stab |
| +--(R)--+
| |
| stab |
+--|/|----->>START |
| |
(* Place P1 *)
| |
| P1 a1 |
+--| |--------------------------------------------+--(R)--+
| | |
| | a2 |
| +--(R)--+
| | |
| | a3 |
| +--(R)--+
| | |
Modul 7 Seite 9 von 11

| | a3 |
| +--(R)--+
| |
(* Place P2 *)
| |
| P2 a1 |
+--| |-----------------------------------------------(S)--+
| |
(* Place P3 *)
| |
| P3 a2 |
+--| |--------------------------------------------+--(S)--+
| | |
| | a3 |
| +--(R)--+
| | |
| | a4 |
| +--(R)--+
| |
(* Place P4 *)
| |
| P4 a2 |
+--| |--------------------------------------------+--(R)--+
| | |
| | a3 |
| +--(S)--+
| | |
| | a4 |
| +--(R)--+
| |
(* Place P5 *)
| |
| P5 a2 |
+--| |--------------------------------------------+--(R)--+
| | |
| | a3 |
| +--(R)--+
| | |
| | a4 |
| +--(R)--+
| |
(* Place P6 *)
| |
| P6 a2 |
+--| |--------------------------------------------+--(R)--+
| | |
| | a3 |
| +--(R)--+
| | |
| | a4 |
| +--(S)--+
| |

RET

END_PROGRAM

2.3.2 Function Block Diagram – FBD


For the implementation in FBD no additional variables have to be defined. Only the input and
output variables are defined.
Modul 7 Seite 10 von 11

For each place of the SIPN a memory (RS Flip-Flop) is used, whose initial state corresponds
to the initial marking of the place. An AND-gate is used for each transition, since the transi-
tion can only fire if it is concessioned and the firing condition is fulfilled. In the presented
implementation, the weak concession rule is used. The transition gates are then connected to
the places they set or reset.
Each output signal is the result of an OR-operation of the different places where it is set. In
this example, each signal is set in only one place, but generally there should be an OR-gate in
front of each output.
Modul 7 Seite 11 von 11

PROGRAM Main

VAR_GLOBAL
e1 AT %IX0.1 : BOOL ;
e2 AT %IX0.2 : BOOL ;
e3 AT %IX0.3 : BOOL ;
e4 AT %IX0.4 : BOOL ;
a1 AT %QX0.1 : BOOL ;
a2 AT %QX0.2 : BOOL ;
a3 AT %QX0.3 : BOOL ;
a4 AT %QX0.4 : BOOL ;
END_VAR

T1 P1
e1 & S a1
&
R

T2
P2
e2 & S a2
&
R

T3
P3

& S
e3 & a3
≥1 R

T4
P4

& S
e4 a4
R

P5
T5 ≥1 S
TON
IN Q R
t#20s PT
T6
P6

& S
&
R

RET

END_PROGRAM

3 Literature

[IEC 61131-3] IEC, International Standard 61131-3, 2nd Ed., Programmable Controllers -
Programming Languages, 1999.
[Modul 2] G. Frey und S. Klein: Steuerungsentwurf mit SIPN. Laborunterlagen, Technische
Universität Kaiserslautern, 2003.
[Modul 3] G. Frey und S. Klein: Simatic STEP 7. Laborunterlagen, Technische Universität
Kaiserslautern, 2003.

You might also like