Académique Documents
Professionnel Documents
Culture Documents
Krzysztof Sacha
Institute of Control and Computation Engineering, Warsaw University of Technology,
ul. Nowowiejska 15/19, 00-665 Warszawa, Poland, k.sacha@ia.pw.edu.pl
Abstract: The paper describes a simple method for the development of programs for PLC
controllers. A specification of the program behaviour is defined using a formal model of
finite state machine. The model is formal, unambiguous, language-independent, yet
readable. The model can be verified against the behavioural and safety requirements.
After the specification phase, the model can be converted directly into a program written
in the form of a ladder diagram. Because the implementation of the graph is direct, no
further verification of the target program is necessary. Copyright 2002 IFAC
Keywords: Programmable logic controllers, programming, finite state machines, software
engineering, real-time systems.
1. INTRODUCTION
The goal of this paper is to describe a simple, yet
formal method for PLC programming. Unlike more
advanced and complex methods, like Grafcet (Bossy
et al., 1979) or IsaGraf, which are based on Petri net
theory, the method introduced in this paper relays on
a classical finite state machine (FSM) model of the
reality. An advantage of this approach is that FSM
models are recognized by the majority of software
specification and design methods and languages,
including UML (Douglass, 1998). Therefore the
described method can easily be interfaced to the
general development process of systems consisting
of computer-based and PLC-based objects.
The method described in this paper starts from the
state transition graph of a FSM, and leads towards
the target program for a PLC, written in the language
of ladder diagrams. Because the implementation of
the graph is direct, no further verification of the
target program is necessary.
The method consists of seven phases:
1. Problem analysis and specification in the form of
a state transition graph.
2. Coding of states.
Stopped
S
Set M, T
bottle supply gate
S
line
start
conveyor
Gate Open
scale platform
open
out
go
ready
full
open
W
Set M, T
F
Reset M
Moving
W
Set Z, Reset T
Bottle Filling
P
Reset Z
Bottle Full
Stopped
SW
Set M, T
Gate Open
F
Reset M
W
Set M , T
S
Reset M
Moving
W
Set Z, Reset T
Set M1 = S W M1 M2 M3
Bottle Filling
W
Reset Z
Reset Z
Bottle Full
Fig. 3 Modified state transition graph
Res M1 = W M1 M2 M3 + S M1 M2 M3
The functions to set and reset the other flip flops can
be defined similarly. This way, the behaviour of
control program can be described by the following
six Boolean functions:
(1) Set M1 = S W M1 M2 M3
( 2) Res M1 = W M1 M2 M3 + S M1 M2 M 3
3. CODING OF STATES
The states identified in the previous phase must be
stored within the controller as states of flip-flops
used by the control program. The minimum number
of flip-flops results from the number of states using
n flip-flops one can store at most 2n individual states.
For example, there are five states in the bottling line
system, which require at least three flip-flops. The
mapping of system states into the states of flip-flops
(the coding) is ambiguous, and can be chosen as
result of a design decision. Usually, it is reasonable
to select such a mapping, in which as many
transitions change the state of a single flip-flop only,
as possible. This can help in keeping the transition
functions simple.
The selected coding of states of the bottling line
controller is presented in Table 1.
Table 1. The coding of states
M1
0
1
1
1
1
Flip-flops
M2
0
0
0
1
1
Line state
M3
0
0
1
1
0
Stopped
Gate Open
Moving
Bottle Filling
Bottle Full
( 3) Set M2 = W M1 M2 M3
( 4) Res M2 = W M1 M2 M3 + W M1 M2 M3 + S M1 M2 M3
(5) Set M3 = F M1 M2 M3
( 6) Res M3 = P M1 M2 M3 + W M1 M2 M3
( 2) Res M11 = M2 W M3 + S M3
( 4) Res M12 = W M1 M2 M3 + M2 M3 W + S
( 3) Set M12 = W M 1 M2 M3
( 4) Res M12 = W M 1 M2 M3 + W M 1 M2 M3 + S M 1 M2 M3
(5) Set M13 = F M1 M2 M3
( 6) Res M13 = P M 1 M2 M3 + W M 1 M2 M3
( ) M1 = M11
( ) M2 = M12
( ) M3 = M13
8. PROGRAMMING
9. CONCLUSION
M11
S
M1
M2
M3
M3
M11
R
1
M2
M3
M12
(1)
(2)
W
(3)
(4)
S
1
M3
M1
M2
M2
M3
M12
R
1
M1
M2
M3
(5)
W
(6)
M1
M2
M3
M13
S
1
M13
R
1
M2
M3
M1
M2
M3
M1
M2
M3
ACKNOWLEDGEMENTS
M3
(7)
(8)
M1
(9)
(10)
M2
M
M11
M12
M14
M13
M11
M14
M1
M12
M14
M2
M13
M14
M3
(11)
(12)
(13)