A Graphical Language For Batch Control
A Graphical Language For Batch Control
ISSN 02805316
ISRN LUTFD2/TFRT1051SE
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.1 Contribution of the Thesis . . . . . . . . . . . . . . . . . 15
1.2 Published Papers . . . . . . . . . . . . . . . . . . . . . . . 16
1.3 Outline of the Thesis . . . . . . . . . . . . . . . . . . . . 18
2. Petri Nets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2 Formal Definition . . . . . . . . . . . . . . . . . . . . . . 24
2.3 Petri Net Properties . . . . . . . . . . . . . . . . . . . . . 26
2.4 Petri Net Analysis Methods . . . . . . . . . . . . . . . . . 26
2.5 Generalized Petri Nets . . . . . . . . . . . . . . . . . . . 29
2.6 Other Petri Net Classes . . . . . . . . . . . . . . . . . . . 30
2.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3. Grafcet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.1 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.2 Dynamic Behavior . . . . . . . . . . . . . . . . . . . . . . 37
3.3 Formal Definition . . . . . . . . . . . . . . . . . . . . . . 40
3.4 Grafcet vs Petri Nets . . . . . . . . . . . . . . . . . . . . 46
3.5 Grafcet vs Finite State Machines . . . . . . . . . . . . . 47
3.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5
Contents
4. High-Level Nets . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.1 Coloured Petri Nets . . . . . . . . . . . . . . . . . . . . . 50
4.2 Coloured Grafcet . . . . . . . . . . . . . . . . . . . . . . . 57
4.3 Object Petri Nets and LOOPN . . . . . . . . . . . . . . . 60
4.4 OBJSA Nets . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.5 Other High-Level Languages Influenced by Petri Nets . 63
4.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5. Grafchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.1 Graphical Language Elements . . . . . . . . . . . . . . . 68
5.2 Actions and Receptivities . . . . . . . . . . . . . . . . . . 73
5.3 Parameterization and Methods . . . . . . . . . . . . . . . 74
5.4 Grafchart the basic version . . . . . . . . . . . . . . . . 76
5.5 Grafchart the high-level version . . . . . . . . . . . . . 86
5.6 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 100
5.7 Foundations of Grafchart . . . . . . . . . . . . . . . . . . 104
5.8 Grafchart vs Grafcet/Petri Nets . . . . . . . . . . . . . . 106
5.9 Implementation . . . . . . . . . . . . . . . . . . . . . . . . 118
5.10 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 128
5.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
6
Contents
A. Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
7
Contents
E. An Introduction to G2 . . . . . . . . . . . . . . . . . . . . . . 289
8
Acknowledgments
Acknowledgments
The work presented in this thesis started in August 1993 when I started
as a PhD-student at the department. Now, in February 1999, when the
thesis is completed, there are several people that I would like to extend
my special thanks to.
Throughout the project, Karl-Erik rzn, my advisor, has helped and en-
couraged me. He has been an excellent advisor with many great ideas and
a deep knowledge in my research area. Thank you Karl-Erik!
Karl Johan strm, the head of the department, led me into the world
of Automatic Control and for this I am very grateful. He has also been a
never ending source of inspiration and optimism.
During the work with the thesis, I have had the opportunity to visit and
work with colleagues from universities abroad. I have enormously appre-
ciated these sessions and I would like to thank Professor Ren David and
Professor Hassane Alla at Laboratoire dAutomatic de Grenoble, Institut
National Polytechnique de Grenoble, France, Professor Venkat Venkata-
subramanian at Laboratory for Intelligent Process Systems, Purdue Uni-
versity, USA, and Jo Simensen at Department of Engineering Cybernetics,
Norwegian University of Science and Technology, Norway.
The work has been supported by NUTEK, the Swedish National Board
for Industrial and Technical Development, Project Regina, 97-00061 and
by TFR, the Swedish Research Council for Engineering Sciences, 95-759.
I would also like to thank some people, not directly involved in the project.
Thanks to my friends for giving me many great moments far away from
batch control systems. Thanks to my parent and my sisters for always
9
Contents
supporting and encouraging me. The last and most important thanks go
to Hans, my beloved husband, for his love, enthusiasm and help through
times of hard work. As a sign of my gratitude, the thesis is dedicated to
him and to our newborn daughter Josefine.
10
1
Introduction
Batch processes are common and important in, e.g., the chemical, food
and pharmaceutical industries. Batch processes are often of the multi-
purpose, multiproduct type, which means that different batches of differ-
ent products can be produced in the same plant at the same time. The
specification of how to produce a batch is called a recipe. The batch plants
can have a network structure which means that the batch can take sev-
eral different paths when passing through the plant. The combination of
multiproduct and network-structured batch plants is the most effective
and the most economical profitable plant structure. However, the multi-
product and network-structured batch plants are also the most difficult
plants to control.
Economical interests have caused an increased interest for small scale pro-
ductions, quick product changes, and order-based production. This means
that there is a need for a flexible way of modifying the production in a
plant. Recipe-based production is suitable for these purposes. Batch pro-
cesses and the control of such processes have therefore lately received
great interest. Even though batch production traditionally has belonged
to the food, pharmaceutical and chemical industries, the idea of having a
recipe-based system is applicable also in many other industries.
Recipe-based control can be seen as a special type of sequential control.
Sequential control is important, not only in batch production but also in
the continuous and discrete industries. All industries have devices that
11
Chapter 1. Introduction
In the first research area, formal specification languages and formal mod-
eling techniques are used to describe the behavior of a system. Formal
analysis techniques are then used to verify certain critical properties. A
number of approaches have been developed. They are based on, e.g., state
12
machines, Petri nets, logics, and process algebras. The approaches must
provide appropriate means for modeling the process and the controller.
The model must be able to represent the dynamics and reactive nature of
the process, and allow for proper expression of timing properties. Hence,
a strong focus of formal methods is modeling and modeling languages.
Most of the proposed approaches are only concerned with verification. The
verifier is presented with a formal model of the process and the control
system and a specification of the desired behavior of the system. The
verification problem consists of demonstrating that the model satisfies
the specification. In the synthesis problem a specification is given that the
process should satisfy. The synthesis problem consists of the construction
of a controller that ensures that the combined model of the process and
the controller fulfills the specification.
One formal method approach that has gained a lot of interest in the control
community is the Supervisory Control Theory (SCT) [Ramadge and Won-
ham, 1989]. This approach has also been combined with Grafcet [Char-
bonnier, 1996], [Charbonnier et al., 1995]. SCT has also been developed
in to Procedural Control Theory (PCT) [Sanchez et al., 1995]. Petri nets
have been used as the basis for controller analysis and synthesis, in the
form of Controlled Petri Nets [Holloway and Krogh, 1994], [Holloway and
Krogh, 1990].
The second research area focuses on development of tools and languages
for implementation of discrete event controllers. With better abstraction
and structuring possibilities it is easier to get a good overview of the con-
trol problem and the implementation is simplified drastically. The focus in
this research area is, in most cases, on graphical programming languages
rather than on modeling and specification languages.
The two research areas complement each other. Most formal approaches
only support verification. The designer must develop and implement the
controller manually. If the approach also supports synthesis, a controller
is constructed and presented in terms of a specification language. Also in
this case, the user must implement the controller. It is therefore important
to have good structuring mechanisms and good programming languages
for controller implementations. Of course, it is also important to be able
to use formal methods for verification of systems that have already been
designed and implemented with, e.g., a high-level implementation lan-
guage.
Two lines of research have been pursued in this thesis
13
Chapter 1. Introduction
The two lines can be regarded as two separate activities. However, there
has been a strong interaction. Both research lines belong to the latter of
the two research areas of DEDS. However, elements better categorized to
the first area can be found.
The work of developing a programming language and tool for sequen-
tial control applications has consisted in providing better abstraction and
structuring mechanisms for Grafcet. A secondary aim of the work has
been to make use of the available formal methods that exists for Petri
nets and Grafcet. The first goal is met by Grafchart, a new high-level pro-
gramming language for sequential control applications presented in this
thesis. Grafchart can, unlike Grafcet, be used to implement all levels in a
control system, supervisory as well as local. The situation, of having bet-
ter abstraction and structuring possibilities, can be compared with moving
from assembly languages to object-oriented high-level languages in ordi-
nary programming. Grafcet can be compared to an assembly language
whereas Grafchart is a high-level object-oriented language. The approach
taken for the secondary goal is to show that Grafchart can be translated
into Grafcet and/or into Petri nets. The formal methods for analysis of
Petri nets or Grafcet can then be applied.
The development of Grafchart has, as much as possible, followed the
Grafcet standard. Grafchart has a syntax similar to Grafcet, i.e., it is
based on the concepts of steps, representing the states, and transitions,
representing the change of state. Grafchart exists in two versions: one
basic version and one high-level version. The basic version is a Grafcet-
based model with an extended syntax with improved abstraction facilities.
A toolbox implementation exists. When the work presented in this the-
sis started, the basic version of Grafchart was already available, [rzn,
1994a]. The high-level version of Grafchart contains additional high level
programming language constructs and features inspired by high-level
Petri nets. Also for the high-level version of Grafchart, a toolbox has been
implemented.
Recipe-based control can with advantage be represented sequentially by a
graphical programming language. The language should have an intuitive
and clear syntax and must have good abstraction facilities. This is pro-
vided by Grafchart. In the thesis it is shown how Grafchart can be used
for recipe structuring both at the lowest level of control and for the over-
all structuring. A recent international standard, IEC 61512 [IEC, 1997],
provides a formal definition of terminology, models and functionality of
14
1.1 Contribution of the Thesis
batch systems. The standard was originally an ISA standard, ISA S88.01,
[ISA, 1995], and is therefore often refered to as the ISA S88.01 standard.
The standard actually mentions the possibility to use Grafcet to control a
batch process, i.e., to structure a recipe and to perform the actions associ-
ated with it. However, it is only suggested for the lowest level of control.
No suggestions are made for how to do the overall structuring of a recipe.
The main application area of Grafchart and of this thesis is recipe-based
control of batch systems. In the thesis it is shown how Grafchart can be
used for recipe structuring both at the lowest level of control and for the
overall structuring. By using the features of Grafchart in different ways,
recipes can be represented in a number of alternative ways. All comply
with the ISA S88.01 standard. The different structures are presented and
their advantages and drawbacks are discussed. A simulation of a multi-
purpose, network structured batch plant has served as a test platform.
The thesis also shows how the recipes, structured with Grafchart, can be
transformed into a Petri net and analyzed with respect to deadlock situ-
ations. The results can be used for static deadlock prevention or dynamic
deadlock avoidance. Grafchart, the recipe-execution system, and the batch
plant are implemented in G2, an object oriented programming environ-
ment. G2 is also an industrial environment which makes it possible to
directly use the results in industry.
15
Chapter 1. Introduction
The work has received a lot of interest by the members of the ISA S88.01
standardization committee.
rzn K.-E. and Johnsson C., and (1996): Object-oriented SFC and
ISA-S88.01 recipes, Presented at World Batch Forum, Toronto,
Canada, [rzn and Johnsson, 1996a]
16
1.2 Published Papers
17
Chapter 1. Introduction
Grafchart has also been used in other areas of batch control. This work is
only presented marginally in this thesis. More information can be found
in the following conference presentations and journal articles:
18
1.3 Outline of the Thesis
19
Chapter 1. Introduction
Happy Reading!
20
2
Petri Nets
Petri nets were proposed by the German mathematician Carl Adam Petri
in the beginning of the 1960s, [Petri, 1962]. Petri wanted to define a gen-
eral purpose graphical and mathematical model describing relations be-
tween conditions and events. The mathematical modeling ability of Petri
nets makes it possible to set up state equations, algebraic equations, and
other models governing the behavior of the modeled system. The graphical
feature makes Petri nets suitable for visualization and simulation.
The Petri net model has two main interesting characteristics. Firstly, it
is possible to visualize behavior like parallelism, concurrency, synchro-
nization and resource sharing. Secondly, there exists a large number of
theoretical methods for analysis of these nets. Petri nets can be used at all
stages of system development: modeling, mathematical analysis, specifi-
cation, simulation, visualization, and realization. Petri nets have been use
in a wide range of application areas, e.g., performance evaluation, [Molloy,
1982], [Sifakis, 1978], distributed database systems, [Ozsu, 1985], flexible
manufacturing systems, [Murata et al., 1986], [Desrochers and AlJaar,
1995], [Silva and Teruel, 1996], logic controller design, [Silva and Velilla,
1982], [Valette et al., 1983], multiprocessor memory systems, [Kluge and
Lautenbach, 1982], and asynchronous circuits, [Yoeli, 1987].
Petri nets have during the years been developed and extended and several
special classes of Petri nets have been defined. These include, e.g.: gen-
eralized Petri nets, synchronized Petri nets, timed Petri nets, interpreted
Petri nets, stochastic Petri nets, continuous Petri nets, hybrid Petri nets,
coloured Petri nets, object-oriented Petri nets, and multidimensional Petri
nets.
21
Chapter 2. Petri Nets
place
P
1
token
1
0
0
1
0
1
transition
T
1
P
2
T
2
The set of places is called P and the set of transitions T . Each place
contains a nonnegative integer of tokens. The number of tokens contained
in a placed is denoted M ( Pi ) or mi . The marking of the net, M, is defined
by a column vector where the elements are the number of tokens contained
in the corresponding places. The marking defines the state of the PN or
the state of the system described by the PN. For the PN given in Figure 2.1
we have:
Places: P { P1 , P2 }
Transitions: T {T1 , T2}
Marking: m1 1, m2 0
1
M
0
22
2.1 Basic Concepts
and-divergence
or-divergence
or-convergence
and-convergence
State graphs and event graphs are special classes of Petri net structures.
An unmarked Petri net is a state graph (state machine) if and only if
every transition has exactly one input and one output place. If the Petri
net is marked its behavior will be equivalent to a classical state machine
if and only if it contains only one token. A Petri net is an event graph
(marked graph, transition graph) if and only if every place has exactly one
input and one output transition. In a state graph parallelism cannot be
modeled whereas alternatives or conflicts cannot be modeled in an event
graph.
Some typical interpretations of transitions and places are shown in Ta-
ble 2.1, [Murata, 1989].
Dynamic Behavior
A transition is enabled if each of its input places contains at least one
token. An autonomous PN is a PN where the firing instants are either
unknown or not indicated whereas a non-autonomous PN is a PN where
the firing of a transition is conditioned by external events and/or time.
An enabled transition in an autonomous PN may or may not fire. An en-
abled transition in a non-autonomous PN is said to be fireable when the
23
Chapter 2. Petri Nets
Table 2.1 Some typical interpretations of transitions and places in Petri nets.
24
2.2 Formal Definition
EXAMPLE 2.2.1
Consider the Petri net given in Figure 2.3.
P1
T1
P2
T2 T3
P3 P4
T4 T5
1 0 0 0 0
0 1 1 0
0
W [ Pre( Pi , Tj )]
0 0 0 1 0
0 0 0 0 1
0 0 0 1 1
1 0 0 0
0
W + [ Post( Pi , Tj )]
0 1 0 0 0
0 0 1 0 0
0
1
M0
1
0
#
25
Chapter 2. Petri Nets
The firing of more than one transition is called a firing sequence and is
denoted S.
Safe A PN is safe for an initial marking M0 if, for all reachable mark-
ings, each place contains at most one token, i.e., the net is 1-bounded.
Live A transition Tj is live for an initial marking M0 if, for every reach-
able marking Mi M0, a firing sequence S from Mi exists, which con-
tains transition Tj . A PN is live for an initial marking M0 if all its tran-
sitions are live from M0 .
26
2.4 Petri Net Analysis Methods
(1) Reachability graph and Coverability tree The basic and most
simple method is to draw the reachability graph. In this graph the nodes
correspond to the reachable markings and the arcs correspond to the firing
of transitions. In Figure 2.4 a PN and its reachability graph is shown. The
graph can be used to find out that the PN is safe, live, reversible and that
it has two repetitive components T1 T2 T4 and T1 T3 T5. Another, equivalent
name for the reachability graph is the marking graph.
P1
T4 0
0
T1 0
T2 1
1 0 0
P2 P3 0 T1 1
0 1
T3
T2 T3 0 0
0 0 0
P4 P5 0
0
T4 T5 0
T5
1
Mk Mi + W S
27
Chapter 2. Petri Nets
0
T2 0
1 T1 0 0
0
0 1 T2 0
P1 0 1
1 0
T3
0 1
T1
T3 T1 1
T3 0
P2
P3
0
T2 T2 0
1 T1 0 0
0
0 1 T2 0
0 1 T1
1 0
T3
0 1
T3
Figure 2.5 A Petri net and its coverability graph (lower) and coverability tree
(upper).
W W+ W
+
W [ Post( Pi, Tj ) ]
W [ Pre( Pi , Tj ) ]
The marking of a Petri net can be changed through the firing of its tran-
sitions. If a deadlock situation does not occur the number of firings is
unlimited. However, not all markings can be reached and not all firing
sequences can be carried out. The restrictions are given by the invariants
of the net. A marking invariant is obtained if a weighted sum of the mark-
ing of a subset of the places in a net is always constant, no matter what
the firing might be. The places contained in this subset is a conservative
component and the vector containing the weights is the P-invariant. The
conservative components of a net often have a physical interpretation. If
the firing of a certain sequence of transitions results in the same marking
as it was started from, the sequence is called a repetitive component. The
characteristic vector of the firing sequence is the T-invariant.
The P-invariants and the T-invariants of a net can be deduced by linear
algebra methods, [David and Alla, 1992].
28
2.5 Generalized Petri Nets
The reduction rules are developed for autonomous Petri nets. The rules
are briefly described in Appendix B.
29
Chapter 2. Petri Nets
P1 P1
0
1
11
0
10
1
00 11
00
0
1 00
11
0
1 00
11
2 Firing of T1 2
T1 T1
3 3
1
0 0
1
01
1 0
11
00 01
1 0
P2 11
00
00
11 00
11
P2 11
00
00
11
00
11
2 2
T2 T2
A number of special classes of Petri nets have been defined. They are
briefly described in this section.
Synchronized PN
In ordinary autonomous PN an enabled transition may or may not fire,
i.e., the ordinary PN are asynchronous. In synchronized Petri nets exter-
nal events are associated with the transitions. If a transition is enabled
and the associated event occurs, the transition will immediately fire. It is
assumed that two external events can never occur simultaneously.
Timed PN
Using timed PN, systems with time dependent behavior can be described.
The timing can either be associated with the places or with the transitions.
These nets are called P-timed PN and T-timed PN respectively.
30
2.6 Other Petri Net Classes
When a token arrives in place Pi of a P-timed PN, the token must remain
in this place at least di time units. During this time the token is unavail-
able. When time di has elapsed, the token becomes available again and
can now participate in the enabling of a transition.
Interpreted PN
An interpreted PN is a synchronized, P-timed Petri net. Associated with
the places are operations O { O 1, O 2 , }. The interpreted PN has a
data processing part whose state is defined by a set of variables V
{ V1 , V2 , }. This state is modified by the operations. The variables de-
termine the value of the condition (predicate) C associated with the tran-
sition. The operation of an interpreted PN together with its environment
is shown in the left part of Figure 2.7. The right part of the same fig-
ure shows that the timing di and the operation O i are associated with
the place Pi while the event Ej and the condition C j are associated with
transition Tj . The behavior of an interpreted Petri net is strongly related
to Grafcet.
Stochastic PN
In a timed PN a fixed duration is associated with each place or with
each transition. In stochastic PN a random time is associated with the
transition. The most common hypothesis is that the timing is distributed
according to an exponential law. The marking at time t, M ( t) of a stochas-
tic PN is then an homogeneous Markov process. A Markov chain can thus
be associated with every stochastic PN and the probabilities of states in
stationary behavior can be calculated.
31
Chapter 2. Petri Nets
Oi Cj Pi Oi d i
Control Part
Tj C j Ej
Synchronized
and P-timed
Petri Net
Vk Ej
Environment
2.7 Summary
Petri nets can conveniently be used to model systems with e.g., concur-
rency, synchronization, parallelism and resource sharing. The graphical
nature of Petri nets also makes them suitable to use for visualization and
simulation of systems. In addition to this, the nets can be theoretically
analyzed with different analysis methods.
32
3
Grafcet
3.1 Syntax
33
Chapter 3. Grafcet
Initial
step
Alternative paths
Transition
Parallel paths
Token
Step
Steps
A step can be active or inactive. An active step is marked with one (and
only one) token placed in the step. The steps that are active define the
situation or the state of the system. To each step one or several actions
can be associated. The actions are performed when the step is active.
Transitions
Transitions are used to connect steps. Each transition has a receptivity.
A transition is enabled if all steps preceding the transition are active.
When the receptivity of an enabled transition becomes true the transition
is fireable. A fireable transition will fire immediately. When a transition
fires the steps preceding the transition are deactivated and the steps suc-
ceeding the transition are activated, i.e., the tokens in the preceding steps
are deleted and new tokens are added to the succeeding steps.
34
3.1 Syntax
Actions
There are two major categories of actions: level actions and impulse ac-
tions. A level action is modeled by a binary variable and has a finite du-
ration. The level action remains set all the time while the step, to which
the action is associated, is active. When the step is deactivated, the action
is reset. A level action may be conditional or unconditional. An impulse
action is responsible for changing the value of a variable. The variable
can, but must not, be a binary variable. An impulse action is carried
out as soon as the step changes from being inactive to active. A variable
representing time may be introduced to create time-delayed actions and
time-limited actions. A level action can always be transformed into a set
of impulse actions.
In Figure 3.2 (left) two steps, x1 and x2, are shown. A level action, A, is
associated with the upper step and an impulse action, B*, is associated
with the lower step. In the same figure (right) an example is given de-
scribing the activation and deactivation of the two steps together with the
duration of the two actions.
x1
x1
A
x2
A
x2
B*
B*
35
Chapter 3. Grafcet
Receptivities
Each transition has a receptivity. A receptivity may either be a logical
condition, an event, or an event and a condition. In Figure 3.3 (left) three
transitions and their receptivities are shown. The receptivity of the first
transition is an event, x . The receptivity of the second transition is a
condition, y, and the receptivity of the last transition is a combination of
a condition and an event, x z .
In the same figure (right) an example is given of the events and conditions
and the corresponding activation and deactivation of the two steps x1 and
x2.
x x
x1
y
y z
x2
x1
x. z
x2
Macro steps
To facilitate the description of large and complex systems macro steps
can be used. A macro step is a step with an internal representation that
facilitates the graphical representation and makes it possible to detail
certain parts separately. A macro step has one input and one output step.
When the transition preceding the macro step fires the input step of the
macro step is activated. The transition succeeding the macro step does not
become enabled until the execution of the macro step reaches its output
step. The macro step concept is shown in Figure 3.4.
36
3.2 Dynamic Behavior
M Action
EXAMPLE 3.2.1
In Figure 3.5 (left) a system consisting of a tank is shown. The tank has
an inlet valve V1 and an outlet valve V2 . There are two level sensors L0
and L1 , one temperature sensor T and one heater Q.
The Grafcet for controlling the tank system is shown in Figure 3.5 (right).
When the system is started, valve V1 should open and the filling should
start. When the level in the tank reaches L0 , the heating should start.
The tank is now heated and filled in parallel. When the level in the tank
reaches L1 the filling is stopped and when the temperature reaches T the
37
Chapter 3. Grafcet
V1
X1
L1
^| Start
T1
T
X2
V2 V1
L0
T2 L0
Q
X3 x4
Q V1
T3 T T4 L1
X5 x6
0. Start
1. Fill to L1
2. Heat to T. Start at L0 T5 true
3. Empty to L0
x7
V
2
T6 L0
heating is stopped. When both the right level and the right temperature
are reached, the tank is emptied. This is done by opening the outlet valve
V2 . When the system is empty, i.e., when the level in the tank is below L0 ,
the sequence can be restarted. All the actions shown in Figure 3.5 (right)
are level actions, e.g., the valve V2 is open (boolean variable V21) as
long as step x7 is active.
Interpretation Algorithm
A Grafcet describes a logic controller, i.e., it specifies the relation be-
tween the input sequence and the output sequence. The interpretation of
a Grafcet must be without ambiguity, i.e., the same input sequence ap-
plied to a Grafcet must result in the same output sequence, independently
of the person or system interpreting the Grafcet. The output sequences
must be equivalent both with respect to the relative order between the
actions and with respect to the timing. The aim of the interpretation al-
gorithm given below, [David and Alla, 1992], is to define exactly how a
Grafcet should be interpreted so that there will never be any ambiguities.
38
3.2 Dynamic Behavior
Algorithm:
The algorithm searches for stable situations (step 6). However, the algo-
rithm is based on the assumption that a finite number of iterations always
results in a stable situation. Therefore, it might seem as if it is not neces-
sary to do the search. Another simpler algorithm exists where the search
is not done. However, the shorter algorithm does not give a correct result
if the net contains unstable situations. Even though the shorter algorithm
does not always give a correct output, this algorithm is the one used most
often in industrial implementations of Grafcet, [Gaffe, 1996].
An interpretation algorithm that works in a synchronous manner has
been developed, [Gaffe, 1996]. The output of a Grafcet interpreted with
39
Chapter 3. Grafcet
Implementation Aspects
The interpretation algorithm to choose when implementing a Grafcet is
the algorithm where a search for stable situations is done. However, cer-
tain practical aspects must be taken into consideration if the real behavior
should be consistent with the interpretation (theoretical behavior). The
algorithm is based on the assumption that no external events can occur
simultaneously. However, when a logic controller, i.e., a Grafcet, is imple-
mented, two events may occur so close in time that there is no technical
mean to distinguish which event occurred first. This might cause prob-
lems in a conflict situation (alternative path). Situations like this should
therefore be avoided. This is done by making the receptivities mutually
exclusive.
A Grafcet can formally be defined in many ways. The definition does only
describe the structure of a Grafcet, its actions and its receptivities. To
execute a Grafcet an interpretation algorithm must be applied. In other
words, the formal definition defines the syntax whereas the interpretation
algorithm defines the semantics.
G < V r , V a , X , T , I >
where:
V r is the set of variables originating from the plant, V ext,
or corresponding to the internal states of the Grafcet, V int.
V r {V ext V int }
40
3.3 Formal Definition
{action( xi)}
where
action( xi) defines the actions associated with the step
xi , action( xi) V a.
T is the set of transitions, T {t1 , t2 , t3 , ...}.
A transition t T is defined by the 3-tuple
where
X P R ( t) is the set of previous steps of t, X P R ( t) X .
X F O ( t) is the set of the following steps of t, X F O ( t)
X.
( t) is the receptivity associated with t, ( t) {V r
true f alse}.
I is the set of initial steps, I X .
EXAMPLE 3.3.1
The Grafcet given in Figure 3.5 is represented by the 5-tuple G.
G < V r , V a , X , T , I >
where:
V r { Start, L0 , T, L1 , L0 }
V a { V1 , Q, V2 }
41
Chapter 3. Grafcet
X { X 1, X 2, X 3, X 4, X 5, X6, X7}
action( X 2) V1
action( X 3) Q
action( X 4) V1
action( X 7) V2
T {T 1, T 2, T 3, T 4, T5, T6}
X P R ( T 1) X 1
X P R ( T 2) X 2
X P R ( T 3) X 3
X P R ( T 4) X 4
X P R ( T 5) { X 5, X 6}
X P R ( T 6) X 7
X F O ( T 1) X 2
X F O ( T 2) { X 3, X 4}
X F O ( T 3) X 5
X F O ( T 4) X 6
X F O ( T 5) X 7
X F O ( T 6) X 1
( T 1) Start
( T 2) L0
( T 3) T
( T 4) L1
( T 5) true
( T 6) L0
I { X 1}
#
42
3.3 Formal Definition
43
Chapter 3. Grafcet
EXAMPLE 3.3.2
The Grafcet given in Figure 3.6 is represented by the 6-tuple G.
G < Vr , Va , X , T , M , I >
X1
T1 a
X2
A
T2 b
X3 X4 M1
B* C
I
X6
T3 ^| c
T6 b
X7
M1 C
T7 d
X8
T4 1 O
X5 A
T5 ^| e
Vr { VrX VrM }
VrX {a, b, c , e}
Va { VaX VaM }
VaX { A, B , C }
44
3.3 Formal Definition
X { X 1, X 2, X 3, X 4, X 5}
action( X 2) A action( X 3) B
action( X 4) C action( X 5) A
T {T 1, T 2, T 3, T 4, T 5}
X P R ( T 1) X 1 X F O ( T 1) X 2
X P R ( T 2) X 2 X F O ( T 2) { X 3, X 4}
X P R ( T 3) X 4 X F O ( T 3) M1
X P R ( T 4) { X 3, M1} X F O ( T 4) X 5
X P R ( T 5) X 5 X F O ( T 5) X 1
( T 1) a ( T 2) b
( T 3) c ( T 4) 1
( T 5) e
M { M1}
VrM Vr1 {b, d}
VaM Va1 { C }
X 1 { X 6, X 7, X 8}
action( X 7) C
T 1 { T 6, T 7}
X P R ( T 6) X 6 X F O ( T 6) X 7
X P R ( T 7) X 7 X F O ( T 7) X 8
( T 6) b ( T 7) d
M1
In1 X 6
Out1 X 8
I { X 1}
45
Chapter 3. Grafcet
1. Both models have two types of nodes: steps and transitions for
Grafcet, places and transitions for Petri nets.
2. In both models, the net execution is synchronized by external events.
Despite the differences that exist, an Interpreted Petri net can be made
equivalent to a Grafcet and a Grafcet can be made equivalent to an In-
terpreted Petri net, see Figure 3.7.
46
3.5 Grafcet vs Finite State Machines
No step can have more than one simultaneously fireable input tran-
sition.
The classical models for describing sequential systems are state machines.
Two different types exist; Mealy machines and Moore machines, [Mealy,
1955], [Moore, 1956]. The output from a Mealy-machine depends on the
internal state and the input whereas the output from a Moore machine
depends only on the internal state.
In Figure 3.8 a Mealy-machine (left) and the corresponding Moore-machine
(right) are shown. The two state machines have two inputs, a and b, and
two outputs, z0 and z1.
A Mealy or a Moore machine can directly be transformed into a Grafcet.
Moreover, it can be shown that the number of steps (and transitions)
47
Chapter 3. Grafcet
Mealy: Moore:
ab
ab/z0 S1/z0
a/z1 a
S0 S1 S0/z1
a
ab/z1 S2/z1
ab
Z1 Z1
a ab ab
Z0 if b
Z0 Z1
Z1 if b
a a a
Figure 3.9 The Grafcet corresponding to the Mealy machine (left) and to the
Moore machine (right) in Figure 3.8.
48
3.6 Summary
3.6 Summary
Grafcet was developed in France in the mid seventies. It was proposed
as a formal specification and realization method for logical controllers.
Grafcet has since become well known through the two international stan-
dards, IEC 848 from 1988 and IEC 1131-3 from 1993. In these standards
Grafcet is refered to as Sequential Function Charts (SFC). The aim of
Grafcet, or SFC, in the standards has gradually shifted from being a rep-
resentation format for logical controllers towards being a graphical pro-
gramming language for sequential control problems at the local level. One
main advantage of Grafcet, or SFC, is its simple and intuitive graphical
syntax. Today Grafcet is widely used and well accepted in industry.
49
4
High-Level Nets
If a system has several parts that are identical these parts should, using
ordinary Petri nets or Grafcet, be modeled by as many identical nets as
there are parts. This kind of problem is of no importance for small systems
but it might be catastrophic for the description of a large system. Real-
world systems are often large and contain many parts which are similar
but not identical [Jensen, 1992]. Using ordinary nets, these parts must
be represented by disjoint subnets with a nearly identical structure. This
means that the total net becomes very large and it becomes difficult to see
the similarities between the individual subnets representing the similar
parts. To make the representation more compact, efficient, and manage-
able the different identical parts could be modeled by one net where each
part is represented by an individual token. In order to distinguish the
different tokens, i.e., the different parts, an identifier is associated with
each token. This is the main idea behind all high-level nets, [Jensen and
Rozenberg, 1991].
In this chapter some different high-level nets are described. The different
models presented are not supposed to give a complete overview of the field
but a rough idea of what has been done in the area.
50
4.1 Coloured Petri Nets
guages. In low level nets there is only one type of token which means
that the state of the place is described by an integer (or by a boolean).
In high-level nets, each token can carry complex information or data. The
state of the system can therefore be more precise [Jensen, 1992].
EXAMPLE 4.1.1
An example taken from [David and Alla, 1992] illustrates the idea of
coloured Petri nets. Figure 4.1 represents two identical systems. In each
system, the truck can move either to the left or to the right. As soon as
the truck reaches one end, it changes direction and sets of again towards
the other end.
Movement to Movement to
the right the right
Movement to Movement to
the left the left
Figure 4.1 Two identical systems and their associated Petri nets.
#
The operation performed when transforming an ordinary Petri net to a
Coloured Petri net is called folding. The reverse operation is called un-
folding.
51
Chapter 4. High-Level Nets
<U> Movement to
the right
Movement to
<L>
the left
Figure 4.2 One coloured Petri net representing two identical systems.
The properties of a coloured Petri net are the same as those for an ordinary
Petri net, i.e., firing sequences, bounded, live, deadlock-free, etc.
EXAMPLE 4.1.2
An example of a small coloured PN is given in Figure 4.3. In the figure it
is shown how the colour functions, associated with the arcs, can be used.
Transition T 1 is enabled with respect to the firing colour m since the
input places contains at least f ( m) and g ( m) tokens, respectively. The
transition is not enabled with respect to the firing colour b. This is due
to the left input place that does not fulfill the condition of containing
f ( b) tokens. When the transition fires with respect to the firing colour m,
f ( m) and g ( m) tokens will be removed from the respective input place
and f ( m) and Id( m) 1 m tokens will be added to the respective output
place.
#
52
4.1 Coloured Petri Nets
m bb Firing of T1 m b
m m b
bb m b
m m
f g f g
Colour functions:
T1 (m,b) T1 (m,b)
f (m) = 1 m + 2 b
f (b) = 3 m
f Id f Id
g (m) = 1 b m
g (b) = 1 m + 2 b b b m
EXAMPLE 4.1.3
In Figure 4.2 a single colour is used to identify each truck. The system
can however be even more compactly described using complex colours.
The upper and the lower truck can both move either to the left or to the
right. In Figure 4.2 the two directions are represented by two separate
places. If each truck instead is represented by a complex colour where the
first subcolour indicates if it is the upper, U, or the lower, L, truck and
the second subcolour indicates if the truck moves to the right, r, or to the
left, l, the system can be described by only one place and one transition,
see Figure 4.4.
< U, r >
P1
< L, l >
f(<L,l>) = <L,r>
f(<L,r>) = <L,l> f Id
f(<R,l>) = <R,r>
f(<R,r>) = <R,l>
T1 { <L,l>,<L,r>,<U,l>,<U,r>}
53
Chapter 4. High-Level Nets
Formal Definition
A coloured PN is a 6-tuple
where:
P is the set of places.
T is the set of transitions.
Pre and Post are functions relating the firing colours to
colours of the tokens.
M0 is the initial marking.
C { C1 , C2 , . . . } is the set of colours.
EXAMPLE 4.1.4
The coloured Petri net shown in Figure 4.4 can be described by the 6-tuple
R.
where
P { P1 }
T {T1}
Pre [ Id ]
Post [f]
M0 [ < U , r > < L, l > ]T
C {< U , r >, < U , l >, < L, r >, < L, l >}
54
4.1 Coloured Petri Nets
combination with guards. It has been shown that the two representations
can be transformed into each other.
The token colour is a data value, that might be of arbitrarily complex type,
e.g., a record where the first place is an integer and the second place a
boolean variable. Each place in the net have a colour set that specifies
the possible colours of tokens that might reside in this place.
The concept of guards is introduced. A guard is a boolean expression
restricting the conditions under which a transition can fire. The guard
must be fulfilled before the transition can fire. Each arc has an associated
arc expression that determines which and how many tokens that will be
affected by a transition firing. A declaration is associated with each net
specifying the different colour sets and variables.
Presentations of practical applications with Coloured Petri nets can be
found in [Jensen, 1997]. A formal definition of Coloured Petri nets version
1986 can be found in [Jensen, 1995].
EXAMPLE 4.1.5
A example, inspired by [Jensen, 1995], illustrates how this type of net
works. In Figure 4.5 there are two types of processes, called p and q. Three
q-processes start in place p1 and cycle through the places ( p1, p2, p3). Two
p-processes start in place p2 and cycle through the places ( p2, p3). Each
of the five processes is represented by a token, where the token colour is
a pair such that the first element tells whether the token represents a
p-process or a q-process and the second element is an integer telling how
many full cycles that process has completed. In the initial marking there
are three ( q, 0)-tokens at place p1 and two ( p, 0)-tokens at place p2. There
are two different types of resources, one r-resource and three s-resources.
In the arc expressions and in the guards different variables are used. The
variables are specified in the declaration that is associated with the net.
The variable i is allowed to be of type I where I is a colour declared
as an integer. The variable x is allowed to be of type U where U is a
colour either equal to p or q. A guard might restrict the possible types of
variables that can enable a transition. This is, e.g., the case for transition
T 1 where the variable x is only allowed to be of type q. The colour set, P,
associated with the places, indicates the possible token colours allowed in
a place. The colour P is composed of one part of type U and one part of
type I. The resources are of token type E.
Transition T 1 is enabled if there is a token of type ( q, i) in place P1, a
token of type e in place R and a token of type e in place S. When the
transition fires the tokens that enabled the transition are removed and a
token of type ( q, i) is added in place P2. Transition T 3 does not have a
55
Chapter 4. High-Level Nets
declaration
colour U: with p|q;
colour I = int;
initial expression
colour P = product U*I;
colour E: with e;
var x: U; 3(q,0)
var i : I; colour set P P1
if x = q
(x,i) then 1(q,i+1)
e [x = q] else empty
T1
(x,i) guard
2(p,0)
e
P P2
if x = p
1e (x,i) then 1(p,i+1)
R case x of else empty
T2
p => 2e
E | q => 1e (x,i)
arc expression
P P3
if x=p then
1e else (x,i)
3e
empty
S T3
case x of
E p => 3e
| q => 2e
guard, this means that the transition can be enabled by a token of type
( p, i) or a token of type ( q, i) in place P3. If the transition is enabled with
respect to a token of type ( p, i), the firing of the transition will remove a
token of type ( p, i) from place P3 and add one token of type e in place R,
three tokens of type e in place S and one token of type ( p, i + 1) in place
P2. If the transition instead is enabled with respect to a token of type
( q, i), the firing of the transition will remove a token of type ( q, i) from
place P3 and add two tokens of type e in place S and one token of type
( q, i + 1) in place P1.
A toolbox, called Design/CPN, has been developed for Coloured Petri nets,
[Met, 1993]. The user graphically draws the net and textually specifies the
colour sets, arc expressions and guards. The inscription language of the
toolbox is Standard ML, [Harper, 1986].
56
4.2 Coloured Grafcet
The new concepts in Coloured Grafcet, compared to Grafcet, are the in-
troduction of colours and the colour-functions.
EXAMPLE 4.2.1
Consider the case were there are two machines, M1 and M2. Each machine
can be in either of two states: idle or busy. If the machine is in the state
idle and the button start is pushed the machine switches state and starts
to work. If the machine is in state busy and the button stop is pushed
the machine stops working and becomes idle. The two machines can be
modeled by two separate Grafcets, see Figure 4.6 (left), or by one Coloured
Grafcet, see Figure 4.6 (right).
57
Chapter 4. High-Level Nets
S1 S1 S1
Idle S1 Idle
<m1>
<m2>
pre 11
T1 T1 T1
{<m1;start1>, <m2;start2>}
S2 S2 post21
Busy Busy S2
M1 Work
Work Work
M2 Work
pre 22
T2 T2 T2
{<m1;stop1>, <m2;stop2>}
post 12
Machine 1 Machine 2
pre 11<m1;start1> = <m1>
pre <m2;start2> = <m2>
11
pre 22<m1,stop1> = <m1>
pre 22<m2;stop2> = <m2>
Formal Definition
where:
58
4.2 Coloured Grafcet
EXAMPLE 4.2.2
The Coloured Grafcet in Figure 4.6 (right) is described by the sextuple:
where
S { S1 , S2 }
T {T1, T2 }
C { CS CT }
C {< m1 >, < m2 >}
CS
{< m1 >, < m2 >, < m1 > + < m2 >}
R {start1, start2, stop1, stop2}
CT
{< m1; start1 >, < m1; start2 >, < m1; stop1 >, < m1; stop2 >,
< m2; start1 >, < m2; start2 >, < m2; stop1 >, < m2; stop2 >}
pre11 0
Pre
0 pre22
0 post12
Post
post21 0
M0 [ < m1 > + < m2 > 0 ]T
59
Chapter 4. High-Level Nets
EXAMPLE 4.3.1
A small example will illustrate how the OBJSA nets work. Figure 4.7
illustrates a truck that can move either to the left or to the right. The
truck is driven by driver. Inside the truck there is food. As soon as the
driver becomes hungry, he stops the truck and starts to eat, when he is
no longer hungry he continues to drive.
The token type for a driver is called Driver and is shown in Figure 4.8
60
4.3 Object Petri Nets and LOOPN
The net describing the truck is shown in Figure 4.8 (right). The token
moving around in this net is of type Driver. Associated with the transitions
are receptivities from which it is possible to check the data of the token.
Modeling a multi-level system with CPN will often result in a large and
complicated net whereas the modeling with OPN will be easier and the
resulting structure of the net becomes easy to read and understand.
The formal definition of OPN as well as the relation to CPN are given
in [Lakos, 1994]. LOOPN++, a textual language for Object Petri nets is
defined in [Lakos and Keen, 1994].
61
Chapter 4. High-Level Nets
EXAMPLE 4.4.1
A small example will demonstrate the idea behind the OBJSA nets. The
example is a modified version of an example first published in [Battiston
et al., 1988].
Consider a system that consists of one sender (S) and one receiver (R).
The receiver has a mailbox (M) consisting of a one-cell buffer where the
sender asynchronously put messages. The receiver asynchronously reads
the messages and removes them from the mailbox. The system can be
modeled by an ordinary PN or by a coloured PN (CPN). In the CPN the
tokens carry an identifier permitting the tokens to be distinguished from
each other. The messages from a sender can be represented by the token
< msg > where msg is the message to be sent. The tokens representing
the messages in the mailbox is either of the type empty < > or of the
type message < msg >.
However, usually mailboxes are not one-cell buffers but list of messages.
This can conveniently be modeled using algebraic nets, i.e., nets where
the information associated with the token is algebraically specified and
algebraically modified. Figure 4.9 shows the sender and the mailbox rep-
resented by an algebraic net. The token representing the mailbox is now a
list, either empty < eL > or nonempty < L >. When a new message comes
the mailbox modifies its list of messages by placing the new message in
the end of the old list. This operation is performed by the @-operator in
the OBJ3 language. There exists a large number of operators defined in
the OBJ3 language, e.g., tail ( L), an operator that returns all elements in
the list L but the first.
62
4.5 Other High-Level Languages Influenced by Petri Nets
Sender Mailbox
<> Empty
<> Mailbox
<eL>
Produce a
Message <eL>
Receiver
<msg>
<eL@msg>
<msg> Send <tail(L)>
<L> <L>
<msg> Mailbox with
Send Messages
<> <L@msg>
Cooperative Objects
Cooperative Objects is an object-oriented language influenced by the lan-
guage Eiffel and by high-level Petri nets, [Bastide et al., 1993]. Cooper-
ative Objects aims at modeling a system at various abstraction levels as
a collection of concurrent objects. The objects cooperate in a well defined
way to provide the services expected from the system.
In this language concurrency, object behavior and inter-object communi-
cation are described in terms of high-level Petri nets. The language relies
on a client-server organization of objects and it retains the most impor-
tant features in object-oriented languages: classification, encapsulation,
inheritance, instantiation and dynamic use relationship.
In Eiffel, the contract that the server object should fulfill for its client
is expressed by a set of preconditions, postconditions and invariants. In
Cooperative Objects, the contract is expressed by a high-level Petri net.
63
Chapter 4. High-Level Nets
The language can be used both for specification of a concurrent class and
for implementation. Results from the PN theory can be used to ensure
the compatibility between a specification and its implementation.
Moby
MOBY (MOdellierung von BrosYstemen) is a tool which supports mod-
eling and analysis of systems by hierarchical timed high level Petri nets
with objects, [Fleischhack and Lichtblau, 1993]. The tool should assist
in the modeling, analysis and simulation of processes in various applica-
tion areas. The tool consists of editors for the specification of the net part,
and of a simulator for the validation of constructed models. The simulator
contains a conflict resolution component, which reduces the combinatorial
complexity of possible behaviors of a model by using specific knowledge
about the system, [Fleischhack and Lichtblau, 1993].
The nets considered in MOBY combines features from algebraic high level
nets and coloured Petri nets with concepts of time and hierarchy. The
tokens are structured in an object oriented manner. A transition may
be refined and the can be seen as a kind of macro expansion. From a
transitions subnets can be called.
To each place in an object net one of the four types: multiset, stack, queue
or priority queue, is assigned. This means that the objects in a place
are handled according to the rules of the corresponding data type. Multi-
set places may contain tokens belonging to different types whereas other
places are bound to one token type.
GINA
Gina is an object-oriented language concept for parallel, hierarchically
structured, data driven programs. It is also a Petri net language based on
dynamically modified, interpreted nets, [Sonnenschein, 1993].
64
4.6 Summary
4.6 Summary
Real-world systems are often very large and do often contain many parts
which are similar but not identical. Using ordinary low level nets, these
parts must be represented by disjoint subnets with nearly identical struc-
tures. This means that the total net becomes very large and it becomes
difficult to see the similarities between the individual subnets represent-
ing similar parts. To make the representation more compact, efficient and
manageable the different identical parts could be modeled by one net
where each part is represented by an individual token. To be able to
distinguish the different tokens, i.e., the different parts, an identifier is
associated with each token.
65
5
Grafchart
66
high-level version also incorporates ideas from high-level Petri nets.
Grafchart is also the name of an implementation of the Grafchart model in
G2, an object-oriented graphical programming environment. G2 is briefly
described in [Gensym Coorporation, 1995], see Appendix E. With Graf-
chart the same language can be used both on the local control level and
on the supervisory control level, see Figure 5.1.
Grafchart for
sequential control
SEQUENTIAL
PROCESS
The language of Grafchart is, like any other programming language, fully
defined by its syntax, semantics and pragmatics, [Turbak et al., 1995].
The syntax defines the notations used, the semantics defines the meaning
of the syntax, and the pragmatics focuses upon how the semantics is
implemented. If the pragmatics is omitted the language is reduced to a
model.
This chapter starts with a presentation of the syntax of Grafchart, i.e.,
its graphical elements and its step actions and transition receptivities.
Then follows a presentation of the basic version (Grafchart-BV) and the
high-level version (Grafchart-HLV) of the language. The presentation cov-
ers, among other things, the dynamic behavior, i.e., the semantics, of
Grafchart-BV and Grafchart-HLV. A section in the chapter covers the
error handling aspect and another section describes the G2 implemen-
tation, i.e, the pragmatics of Grafchart. The chapter ends with a short
presentation of some applications of Grafchart.
67
Chapter 5. Grafchart
Grafchart processes
An entire function chart can be represented as a Grafchart process object,
see Figure 5.2. The function chart is encapsulated by the Grafchart pro-
cess object. In the G2 implementation the function chart is placed on the
subworkspace, see Chapter 5.9, of the Grafchart process.
68
5.1 Graphical Language Elements
Steps
A step is an object that is represented as a square, see Figure 5.4. Actions,
i.e., can be associated with a step. A step can be active or inactive.
Initial steps
The graphical representation of an initial step, i.e. a step that should be
active when the function chart is started, is a double square, see Fig-
ure 5.5.
Transitions
A transition is represented by an object. The graphical representation
of a transition is shown in Figure 5.6. A transition can be enabled or
disenabled.
Parallel bars
A parallel bar is used to indicate the beginning and the end of a parallel
branch. To indicate the beginning of such a branch a parallel bar of type
69
Chapter 5. Grafchart
anddivergence
andconvergence
Macro steps
Macro steps are used to represent steps that have an internal structure
of (sub)steps, transitions and macro steps. In the G2 implementation a
macro step is represented by an object that has a subworkspace. The
internal structure is placed on the subworkspace. In Figure 5.8, a macro
step and its internal structure are shown.
70
5.1 Graphical Language Elements
enabled. The transitions following a macro step will not become enabled
until the execution of the macro step has reached its exit-step. An enter
step and an exit step are shown in Figure 5.9.
Grafchart procedures
Sequences that are executed in more than one place in a function chart
can be represented as Grafchart procedures, see Figure 5.10. The Graf-
chart procedure object has a subworkspace on which the procedure body
is placed. The enter-step and exit-step objects are used to indicate the
first and the last sub-step of a procedure. Only one enter step is allowed
in each Grafchart procedure.
Procedure steps
A Grafchart procedure is called from a procedure step. The procedure step
has a procedure attribute in which the name of the Grafchart procedure
that should be called is specified. Immediately when a procedure step is
activated, the Grafchart procedure is called and a new token is placed
in the enter step of the Grafchart procedure. The transitions following a
procedure step do not become enabled until the execution of the Grafchart
procedure has reached its exit step. In Figure 5.11 a procedure step is
shown.
71
Chapter 5. Grafchart
procedure
call
Grafchart
procedure
Process steps
A procedure step is the equivalent of a procedure call in an ordinary pro-
gramming language. Sometimes it is useful to start a procedure as a sep-
arate execution thread, i.e., to start the procedure as a separate process.
This is possible with the process step, see Figure 5.12. The transitions af-
ter a process step become enabled as soon as the execution has started in
the Grafchart procedure. An outlined circle token is shown in the process
step as long as the process is executing. It is possible to have more than
one process executing at the same time from the same process step.
process
creation
Grafchart
procedure
Tokens
Tokens are represented as filled circles. In the basic version of Grafchart,
the tokens are boolean indicators indicating if a step is active or not,
whereas the tokens in the high-level version of Grafchart are objects that
have an identity and may contain information.
72
5.2 Actions and Receptivities
Actions
Four different types of actions exist: always, initially, finally and abortive.
An initially action is executed once immediately when the step becomes
active. A finally action is executed once immediately before the step is
deactivated. An always action is executed periodically while the step is
active. An abortive action is executed once immediately before the step is
aborted. All actions can be conditional or unconditional. The actions that
may be performed in a step action depends on the underlying implemen-
tation language. The minimum requirement is that it should be possible
to assign values to variables and that it should be possible to execute
macro actions, see Chapter 5.9.
In Figure 5.13 a step, x1, is shown. Three actions are associated with the
step. The figure (right) shows the execution of the actions.
x1
Initially
x1
Always
Finally
73
Chapter 5. Grafchart
Receptivities
A receptivity is used for specifying when an active step should fire. Each
receptivity contains two attributes, condition and event. These are used
to enter the event expression and/or the logical condition telling when
the transition should fire. The event expression and the logical condition
are expressed in the underlying implementation language.
In Figure 5.14 two examples are given of how the event or condition of
the transition receptivity effects the activation and deactivation of the two
steps x1 and x2.
x1 x1 x1 x1
y becomes x2 y is true x2
true
x2 x2
y y
Parameterization
Parameterization denotes the possibility for a graphical element to have
attributes acting as parameters. Grafchart processes (i.e., entire function
charts), Grafchart procedures, macro steps, and steps can be parame-
terized. The parameterization feature makes it easier to reuse function
charts from one application to another.
A step is allowed to have none, one or several attributes. These attributes
act as parameters that can be referenced and modified from within the
step actions associated to this step.
The attributes of a Grafchart process, Grafchart procedure, or a macro
step can be referenced from within all steps and all transitions placed
74
5.3 Parameterization and Methods
sup.attribute1
refers to the attribute1 attribute visible in the current context.
sup.attribute1^
refers to the object named by the attribute1 attribute visible in
the current context. This notation is the G2 equivalent of a pointer
attribute in a conventional programming language.
sup.attribute1^.attribute2
refers to the attribute2 attribute of the object given by the
attribute1 attribute visible in the current context.
Lexical scoping is used when searching for the attribute of an object re-
placing the sup notation. Sup is short for superior.
self
refers to the object that the method belongs to, i.e., this object.
self.attribute1
refers to the attribute1 attribute of this object.
self.attribute1^
refers to the object named by attribute1 of this object.
self.attribute1^.attribute2
refers to the attribute2 attribute of the object named by the
attribute1 attribute of this object.
75
Chapter 5. Grafchart
Initially
conclude that x = 4
Always
conclude that y = y+1
a transition
event
condition
Associated with the procedure steps and the process steps is a procedure
attribute that is used to specify the name of the Grafchart procedure that
should be called. When the procedure step or the process step becomes
76
5.4 Grafchart the basic version
a procedurestep a processstep
name name
parameters parameters
procedure gp1 procedure gp1
Enter
step
Exception
transition
Exit
step
77
Chapter 5. Grafchart
Parameterization
Consider the example shown in Figure 5.20. In the figure a macro step
with two attributes, tank and limit, is shown. The macro step is named
FT1 and it contains the logic for the control and monitoring of the filling
of a tank. The tank attribute contains the name of the tank that should be
filled, i.e., the value of this attribute acts as a pointer. The limit attribute
contains the limit up to which the tank should be filled. The macro step
has an enter-step that contains an action that initiates the filling. In this
action a reference is made to the value of the tank attribute, i.e., the tank-
12 object , using the notation sup.tank^. Similarly the transition condition
refers to the level of the tank referenced by the tank attribute and to the
value of the limit attribute. The sup.attribute notation is translated
and replaced by the corresponding G2 expression during compilation as
described in Chapter 5.9.
FT1
Initially
start filltank(sup.tank^)
FT1, a filltank
name FT1
Condition:
tank tank12 "sup.tank^.level > sup.limit"
limit 10
Lexical scoping is used when searching for the attribute of an object re-
placing the sup notation. Consider the example shown in Figure 5.21. The
macro step M1 has an attribute named x with value 156. The substructure
of the macro step contains among other a transition and another macro
step, M2. The macro step M2 has an attribute named x with value 12. The
substructure of M2 contains a transition with a reference to an x-attribute
using the sup.X notation. This reference will be to the x-attribute of the
macro step M2. The transition placed on the subworkspace of the macro
step M1 also refers to an x-attribute using the sup.X notation. In this
case the reference will be to the x-attribute of M1, see Figure 5.21. If,
however, the macro step M2 would not have had an attribute named x,
the sup.X reference of the transition in M2 would instead have refered to
the x-attribute of M1.
78
5.4 Grafchart the basic version
sup.X >10
sup.X >10
a macro step
Name M1
a macro step
X 156
Name M2
X 12
Initially
a Grafchart procedure if sup.U then
start count(sup.V,
name gp1 sup.W)
U
V
Grafchart
W procedure
a procedurestep
Procedure
name P1 call
parameters "u = true
v = 100
w = ok"
procedure "gp1"
79
Chapter 5. Grafchart
a procedurestep Procedure
call
name P1
parameters "u sup.val IN
v sup.v OUT
w sup.q INOUT"
procedure "sup.proc"
80
5.4 Grafchart the basic version
r1 a reactor
capacity 100
charge a grafchart
method
R1: a reactor a grafchartmethod
procedure "reactor
charge"
Grafchart
a procedure step procedure
Procedure
step Parameters " .... "
Procedure " R1 charge"
reactor
charge
EXAMPLE 5.4.1
Consider the tank example in given in Figure 5.25. This is the same tank
as the one in Chapter 3.2 Example 3.2.1.
V1
L1 0. Start
1. Fill to L1
T
2. Heat to T. Start at L0
V2
L0
3. Empty to L0
81
Chapter 5. Grafchart
a grafchart process
name gp1
V1 v11
V2 v12
Q q1
L0 false
L1 false
T 100
T1, a transition
Event Start
Condition
T2, a transition
Event
T1
Condition sup.L0
Initially
open sup.V1 T3, a transition
T2 Event
Condition tank1.temp > sup.T
Initially
start sup.Q T4, a transition
T3 T4 Event
Condition sup.L1
Initially Initially
stop sup.Q close sup.V1
T5, a transition
T5 Event
Initially Condition true
open sup.V2
Finally
close sup.V2 T6, a transition
T6 Event
Condition not(sup.L0)
Dynamic Behavior
The dynamic behavior of Grafchart is given by the following rules.
A step, initial step, enter step, exit step, or process step is deactiveable if
and only if it is active.
82
5.4 Grafchart the basic version
A macro step is deactiveable if and only if the exit step upon the sub-
workspace of the macro step is active.
A procedure step is deactiveable if and only if the exit step in the Grafchart
procedure started by the procedure step is active.
A macro step is active if at least one of the steps upon the subworkspace
of the macro step is active.
A process step is active if at least one of the step in the Grafchart proce-
dure started by the procedure step is active.
Firing rules
83
Chapter 5. Grafchart
Interpretation Algorithm
The interpretation algorithm of Grafchart describes the theoretical un-
derstanding of a Grafchart and guarantees that everyone faced with the
same Grafchart understands it in the same way.
As in the case of Grafcet, multiple interpretation algorithms or semantics
are possible for Grafchart. The following algorithm corresponds to the
search for stability algorithm for Grafcet, see Chapter 3.2 (Interpretation
Algorithm). Step 4 - 18 are assumed to take zero time. In order for the
algorithm to be deterministic, all or-divergence situations must be made
mutually exclusive. The algorithm presented below is not deterministic
unless this condition is fulfilled.
Algorithm
84
5.4 Grafchart the basic version
8. Carry out the abortive actions associated with the steps (and their
substeps) preceding the transitions in T2.
9. Fire the transitions in T2.
10. Carry out the initially actions of the steps (and their activated sub-
steps) succeeding the transitions in T2.
11. Let T1 be the set of transitions contained in T1 that are still enabled.
If T1 is empty, go to Step 18.
12. Make sure that T1 contains no transitions that are in conflict with
each other, i.e., transitions participating in the same or-divergence
situation. If so, the number of transitions contained in T1 must be
reduced. This is done by excluding transitions participating in the
conflict until T1 no longer contains any transitions that are in con-
flict with each other. The transitions to exclude are chosen randomly.
13. Stop executing the always actions that are still executing and that
belong to the steps (or their activated substeps) preceding the tran-
sitions in T1.
14. Carry out the finally actions of the steps (and their activated sub-
steps) preceding the transitions in T1.
15. Fire the transitions in T1.
16. Carry out the initially actions of the steps (and their activated sub-
steps) succeeding the transitions in T1.
17. Let T2 be the set of transitions contained in T2 and that are still
enabled. If T2 is non-empty, go to Step 6.
18. Determine the set of fireable transitions and exception transitions
T. If T is non empty go to Step 4.
19. A stable situation is reached. Start executing the always actions
associated with the active steps (and their activated substeps). Go
to step 2.
Formal Definition
The formal definition of the basic version of Grafchart is presented to-
gether with an illustrative example in Appendix C.
85
Chapter 5. Grafchart
an Object Token A
Attribute1
Grafchart marker A Method 1
86
5.5 Grafchart the high-level version
an Object Token A
an Object Token A Attribute1
Attribute1 Method 1
Method 1
an Object Token B
Attribute1
Method 1
Figure 5.28 Two active steps (left and middle), and an inactive step (right).
V11
Tank1
L1
T1 T1
T Initially Initially
V12 open sup.V1 open sup.V1
L0 T2 T2
q1
Initially Initially
V21 start sup.Q start sup.Q
T3 T4 T3 T4
Initially Initially Initially Initially
Tank2 stop sup.Q close sup.V1 stop sup.Q close sup.V1
L1
T T5 T5
Initially Initially
V22 open sup.V2 open sup.V2
L0 Finally Finally
close sup.V2 close sup.V2
q2 T6 T6
Figure 5.29 A system composed of two identical tanks, each controlled by a Graf-
chart.
If, however, the high-level version of Grafchart is used, the two tanks can
be controlled by one chart in which there are two object tokens, one for
each tank. The information about, e.g., the temperature, the level etc.,
can no longer be stored in the attributes of the chart since they do not
have the same values for the two tank systems. Instead the information
87
Chapter 5. Grafchart
V11
a tanktoken
L1 Tank1
name t1
T tank tank1
V12 V1 v11
L0
V2 v12
q1 T1 Q q1
p: tanktoken L0 false
Initially
open p.v1 L1 fasle
T2
T 100
V21
p: tanktoken
Initially
start p.Q
Tank2 T3 T4
L1
p: tanktoken p: tanktoken a tanktoken
Initially Initially
T stop p.Q close p.V1 name t2
V22
L0 tank tank2
T5 p: tanktoken
Initially
V1 v21
q2 open p.V2 V2 v22
Finally Q q2
T6 close p.V2
L0 true
L1 false
T 500
Figure 5.30 A system composed of two identical tanks, controlled by one Graf-
chart.
88
5.5 Grafchart the high-level version
89
Chapter 5. Grafchart
type P-token exists in the step, and, if the value of the y attribute of the
P-token is greater than ten, then, when a token of type Q-token leaves
the step, the value of its v attribute will be assigned the same value as
the value of the y attribute of the P-token.
a Ptoken
name token22
marker grafchartmarkerx
y 3
The receptivity is built up by six parts. The token class, for any and
there exists parts are used in the same way as those of a step action.
The event and condition parts are used to specify the event and condi-
tions of the receptivity. When a transition becomes fireable an operation
is performed on the tokens that are referenced by the receptivity. The
operation is specified in the action part of the receptivity.
In the standard case the operation would be to move the token from the
input step to the output step. However, it is also possible to delete and
create tokens and to change the value of the attributes of the tokens. The
latter is useful primarily for initializing the values of a newly created
token. The operations can also be more complex, e.g., an attribute of the
token can be changed at the same time as the token is moved from the
90
5.5 Grafchart the high-level version
input step to the output step, another token placed in the input step can
be deleted or a new token can be created and placed in the output step.
It is also possible to move, not only the token that enables the transition
but also one or several of the tokens refered to in the condition or event
part of the receptivity.
The action move(p) implies that the grafchart marker that is placed in
the input step of the transition and that points on the object token named
p is moved from the input step of the transition to the output step. The
action create(P-token) implies that an instance of a P-token is created.
A grafchart marker, of the class that animates a P-token is also created
and placed at the output step of the transition. The pointer from the
grafchart marker to the P-token is created. The action delete(p) deletes
the grafchart marker that is placed in the input step of the transition
and that points to the object token named p, and deletes the object token
named p.
In Figure 5.32, two tokens are placed in the step preceding the transition,
one token of class P-token and one token of class Q-token. The transition
is enabled with respect to both token classes but it is only fireable with
respect to the token of class Q-token. When the transition fires the token
of class Q-token will be moved from the input step to the output step of
the transition and the token of class P-token will be deleted.
Parallelism
The reason for having a grafchart marker that acts as a pointer to the
corresponding object token is the way parallel structures are handled.
When the transition preceding a parallel-split (and-divergence) is fired,
the grafchart marker is moved from the input step of the transition to
the first step in one parallel branch, and copies of the grafchart-marker is
added in the first step in each of the other parallel branches. The grafchart
markers in all the parallel branches will therefore point to the same object
token according to Figure 5.33. If the value of an attribute is changed in
one of the branches it will directly be visible in all branches.
The transition after a parallel-join (and-convergence) is only enabled with
respect to a token class if all the input steps of the transition contain graf-
chart markers that point to the same object token. When the transition is
fired, one grafchart marker from one of the preceding steps in the paral-
lel branch is moved to the output step, the rest of the grafchart markers
are deleted. Since all grafchart markers, in the parallel branches, point
to the same object token it does not matter which one that is moved and
which are deleted. The parallel-join (and-convergence) situation is shown
in Figure 5.34.
91
Chapter 5. Grafchart
an Object Token
name
attribute1
attribute2
The reason for letting the grafchart marker point to an object token, con-
taining the attributes, and not letting the grafchart marker itself contain
the attributes, is the parallel-join structure. If the grafchart marker would
contain the attributes and if the value of an attribute of one of the graf-
chart markers, in one of the parallel-branches, is modified, it would be
unclear how the parallel-join (and-convergence) should be treated. Which
value of the attribute should be kept and which should be ignored? By
92
5.5 Grafchart the high-level version
PN-transition
A special kind of transition has been introduced in Grafchart-HLV, the
transition is called PN-transition (Petri net transition). A PN-transition
can, unlike a normal transition, have more than one incoming arc and
more than one outgoing arc. The arcs are numbered and the numbers can
be used to specify from which step and to which step the token should be
moved.
A PN-transition is shown in Figure 5.35. The PN-transition is enabled
with respect to the color P since there is a token of class P in the preceding
step connected to arc number 1. The PN-transition is also fireable since
there exists a Q token in the preceding step connected to arc number 2.
When the transition is fired, one token of color P is moved from the left
input step to the output step connected to arc number 1, and one Q token
is moved from the right input step to the output place connected to arc
number 2, as specified in the action part of the receptivity.
a Ptoken
name token22
marker grafchartmarkerx
y 3
Token class "Ptoken"
1 2
For any "p: Ptoken(1)"
There exists "q: Qtoken(2)"
1 2 Event ""
a Qtoken Condition "p.y = q.v"
name token34 Action "move(p,1 ); move(q,2 )"
marker grafchartmarkerz
v 20
Macro steps
As soon as a grafchart marker enters a macro step a copy of the grafchart
marker is placed in the enter-step of the macro step, i.e., the grafchart
marker placed in the macro step and the grafchart marker placed in the
enter-step points at the same object token. Several tokens can be in a
macro step at the same time.
93
Chapter 5. Grafchart
Grafchart
procedure
gp1, a grafchartprocedure
procedure X true
call
Z 4
gp1
94
5.5 Grafchart the high-level version
Parameterization
The parameterization feature is included in the high-level version of Graf-
chart. The sup notation can be used to reference attributes of an object
visible in the current context in the same way as presented earlier, see
Chapter 5.3.
Object Tokens
In the high-level version of Grafchart, the tokens are objects with an iden-
tity. The tokens can, unlike the tokens in the basic version of Grafchart,
carry information. This feature is sometimes refered to as the object token
feature of Grafchart.
inv.attribute1
refers to the attribute1 attribute of the token
In Figure 5.37 a procedure step is shown. Two tokens are placed within
the procedure step, one token of class P-token and one token of class
Q-token. Tokens of class P-token cause calls to a Grafchart procedure
named gp1 whereas tokens of class Q-token cause calls to a Grafchart
procedure named by the proc attribute of the token itself. The grafchart-
procedure gp1 has two attributes, x and z, compare figure 5.36. When the
call to the Grafchart procedure is performed, the x attribute is given the
value of the x attribute of the P-token giving rise to the call, and the z
attribute is given the value 4.
95
Chapter 5. Grafchart
Multi-dimensional Charts
Since a token is an object and since objects are allowed to have methods
also tokens may have methods. This will give a multi-dimensional struc-
ture where a token moving around in a chart may itself contain one or
more charts. This feature is sometimes refered to as the multi-dimensional
chart feature of Grafchart. The feature gives several interesting structur-
ing possibilities.
gp2 gp1
a PToken
name
x 5
proc a grafchart
method a grafchartmethod
procedure gp1
a QToken
name
proc a grafchart
method
a grafchartmethod
procedure gp2
96
5.5 Grafchart the high-level version
a PToken
name
x 5
proc a grafchart
method
a grafchartmethod
procedure gp1
gp1
........
....... "p:Ptoken"
" p.x = 10 ..."
Action text: .....
.. self.x > 5
97
Chapter 5. Grafchart
chart method gp1. Associated with the step where the token is placed, is
an action. In the action the P-token is given the temporary name p and
the x attribute is refered to as p.x. The method has three steps. Associated
with the middle step is an action. When refering to the token attribute x
from within this action the self.x notation is used.
The different levels in a multi-dimensional function chart can communi-
cate with each other through the different dot notations that exist, see
Figure 5.40.
a Grafchart process
a PToken
x 14 2
name
y "true" x 5
proc a grafchart
method a grafchartmethod
1
4 3
procedure gp1
gp1
a Grafchart procedure
name gp1
..... z 56
Initially
... sup.x = 14
1
.......
....... " x inv x"
....... " inv proc"
Formal Definition
The formal definition of the high-level version of Grafchart is presented
in Appendix C.
98
5.5 Grafchart the high-level version
Conceptual Ideas
The ideas introduced in Grafchart-HLV can be used in many types of ap-
plications. The general idea is that there is a system where one or several
parts reside. The parts may be e.g., cars, people, or chemical batches.
The parts are allowed to have individual information, e.g., production-
descriptions, personal thoughts or customer demands.
The concept of Grafchart is the following: information that applies to all
parts in the system is stored either in the base-level function chart or
as global attributes whereas part specific information is stored either
as methods belonging to the token representing the part or as local at-
tributes, i.e., attributes of the token representing the part.
Consider the example of the Russian dining philosophers, [Lakos, 1994].
Four philosophers are sitting around a circular table. In front of each
philosopher there is a plate. Between each plate there is a chopstick, i.e.,
on the table there are four plates and four chopsticks. Each philosopher is
thinking of a problem. Depending on the state of the problem the philoso-
pher would either like to eat or think. If the philosopher would like to
eat, he or she can only do so if the two chopsticks on each side of his plate
are not used by any of his adjacent philosopher. In this application each
philosopher corresponds to a token. The token resides in a chart corre-
sponding to the table and its setting. The problem that the philosopher
is thinking on is represented by another chart stored as a method of the
token.
Another type of application suitable for Grafchart is production lines. In
a production line entities are produced. The entities-under-production are
moving along a conveyor belt. During their transport they pass one or sev-
eral machines. In this application each entity could be represented by a
token. If all entities should be produced in exactly the same way, the infor-
mation about how this should be done can be represented by the base-level
function chart. If the entities differs only very little, the entity-specific in-
formation can be stored as attributes of the corresponding token. From
the base-level function chart it is possible to refer to the entity-specific in-
formation when needed. Production-lines do also exist that are customer
driven, i.e., the machines that produce the entities perform different tasks
depending on the entity. In this case the base-level chart can be made very
general and information about what a machine should do with a certain
entity can be stored as methods of the token. When a token enters a step
that corresponds to a certain machine the correct method is called. In this
application several entities may be under production at the same time,
however, the entities that are under production can not pass each other
on the conveyor belt. This means that the relative order among the tokens
cannot change.
99
Chapter 5. Grafchart
100
5.6 Error Handling
Connection posts
CP1
CP1
CP2
CP2
Error handling
Step fusion sets Grafchart-BV also supports step fusion sets, [Jensen
and Rozenberg, 1991]. Each step in a fusion set represents one view of the
same conceptual step. Using fusion sets a step can have multiple graphi-
cal representations. When one of the steps in the fusion set becomes active
(inactive) all the steps in the set will become activated (inactivated). Fu-
sion sets can conveniently be used to separate normal operation logic from
error handling logic.
101
Chapter 5. Grafchart
EXAMPLE 5.6.1
Consider the tank example presented in Chapter 5.4, Example 5.4.1. The
normal operation logic of this system is presented in Figure 5.26. Assume
that the normal operation can be disturbed by two faults, called X and Y,
[David and Alla, 1992]. When one of the faults occur, all actions should be
reset, i.e., all valves should be closed and all pumps and heaters switched
off. In addition to this an acoustic alarm should be turned on. When the
fault has been repaired the normal operation starts again and the acoustic
alarm is turned off. If the fault was of type X the restart should be done in
the initial state, if the fault was of type Y the restart should be done in the
state normally reached when indicator L0 becomes true. The fault is either
restored by itself or repaired by a service man. The service man can turn
off the acoustic alarm before it has been repaired. This is done by pressing
a button called service arrived. If the fault X occurs twice in less than
a minute, the fact that the fault is restored by itself will not be enough
for the system to return to its normal operation, a manual inspection is
also required. To indicate that the inspection has taken place, the service
man should press the button inspection done.
V1
L1 0. Start
1. Fill to L1
T
2. Heat to T. Start at L0
V2
L0
3. Empty to L0
The Grafchart for the system is presented in Figure 5.44. In this Graf-
chart, the normal execution logic and the error logic are combined into
102
5.6 Error Handling
one Grafchart. As can be seen the Grafchart becomes very large and com-
plex. The transition receptivities for transition T1 - T6 are the same as
the ones presented in Figure 5.26, transition receptivities T8 - T15 are
presented under the function chart.
a grafchart process
name gp1
V1 v11
V2 v12
Q q1
L0 false
L1 false
T 100
T1
Initially
open sup.V1
T2
T7 T10 T13
Initially Initially
start sup.Q Initially Initially
start acoustics start acoustics start acoustics
Initially Initially
stop sup.Q close sup.V1 T8 T11 T14
T5
Initially T9 T12 T15
open sup.V2
Finally
close sup.V2
T6
T7, a transition T9, a transition T10, a transition T12, a transition T13, a transition T15, a transition
event x event not(x) event x event not(x) event y event not(y)
condition last firing < 60 sek condition condition last firing > 60 sek condition inspection done condition condition
103
Chapter 5. Grafchart
a grafchart process
name gp1
V1 v11
V2 v12
Q q1
L0 false
L1 false Error logic
T 100 C3
T7 T10
Normal execution logic Initially Initially
start acoustics start acoustics
Finally Finally
stop acoustics stop acoustics
T1 T8 T11
C1
Initially
open sup.V1
T2
T16 T9 T12
Initially
T18 start sup.Q
C3 C2
C4 T3 T4
T19 Initially Initially T7, a transition
T17 stop sup.Q close sup.V1
C2 Error logic event
condition last firing < 60 sek
T5 C4
Initially T13 Initially T10, a transition
open sup.V2 start acoustics
Finally event
T14
T16, a transition T17, a transition T18, a transition T19, a transition T15 T13, a transition
event event event x event y event
condition true condition true condition condition C1 condition true
104
5.7 Foundations of Grafchart
Petri nets
Objectoriented
Programming
developing the language has been to provide the user with a user-friendly
and graphical high-level language for sequential control. As a side effect,
caused by the connections to Grafcet and Petri nets, the language could
also, to some extent, be used for analysis and validation of systems.
Grafcet
Grafcet, [David and Alla, 1992], has a clear and intuitive syntax. Grafchart
is based on the same syntax even though it has been enlarged by some
extra graphical elements. The syntax of Grafcet has also been very well
accepted in industry. Therefore we believe that it is a good idea to keep
this syntax.
Petri Nets
It is very difficult, probably impossible, to make an informal explanation
of a function chart which is complete and without ambiguities. It is thus
extremely important that the intuition is completed by a formal definition,
[Jensen, 1992]. Both for Petri nets and Grafcet a formal description exists,
[David and Alla, 1992] and [Jensen, 1992]. A similar description language
has been worked out for Grafchart.
In order to detect e.g., deadlock situations, formal analysis methods must
exist. Since Grafchart is based upon Petri nets and since formal analysis
methods exist for Petri nets, it is sufficient to show that a Grafchart
function chart can be transformed into a Petri net and then applied to
the already existing methods. Alternatively, the Grafchart function chart
can be transformed into a Grafcet and the formal methods that have
been developed for Grafcet can be used, [Roussel and Lesage, 1996] and
[De Loor et al., 1997].
105
Chapter 5. Grafchart
Object-Oriented Programming
Object-oriented programming incorporates powerful abstraction facilities
and supports well structured applications. The parameterization and meth-
od and message passing features in Grafchart are abstraction facilities
inspired from similar features found in most object-oriented languages.
When implementing large systems it is very important to have good and
logical structuring possibilities. The object token concept is a step in this
direction.
General Aim
Grafcet was developed with the focus on logical controllers (PLCs). It is
most often used only as a specification language, i.e., as a graphical de-
scription of how the controller is intended to work. The implementation is
then done either in Grafcet or in another language suitable for PLC im-
plementations such as, e.g., relay (ladder) logic diagrams or instruction
lists. Grafchart has been developed without focus on any particular ap-
plication. Grafchart is a general graphical language aimed at sequential
control. Thanks to the advanced features that are included in Grafchart,
the language is suitable to use both at the local control level and at the
supervisory control level. Grafchart is also intended to be a language used,
not only for specifications, but also for the actual implementation. A Graf-
chart function chart is interpreted on-line.
Petri net was developed with the aim to be used for analysis, simulation
and visualization of a process and not for control.
106
5.8 Grafchart vs Grafcet/Petri Nets
Graphical Interface
The graphical interfaces of Grafcet and Grafchart have many similarities,
e.g., the steps , the transitions, the parallel structures and the alternative
structures. These similarities are intentional. However, the Grafchart lan-
guage contains more graphical elements (building blocks) than Grafcet.
The new building blocks introduced in Grafchart are: Grafchart processes,
Grafchart procedures, process steps, procedure steps and exception transi-
tions. The new building blocks do not extend the functionality of Grafchart
compared to Grafcet, but they facilitate the implementation of more ad-
vanced sequence structures. The development of Grafchart from Grafcet
can be compared to the evolution from assembler languages to high-level
programming languages like Java.
The steps in Grafchart-HLV and the places in Colored Petri nets, have
many similarities. They both represent the states of the system and they
may contain several tokens. The fact that the steps in Grafchart have
actions is a major difference from Petri nets. The actions make Grafchart
resemble Grafcet. However, places with actions can be found in a version
of Petri nets called Interpreted Petri nets, [Moalla, 1985], but here the
actions are only expressed with boolean variables.
External Interface
Grafcet and Grafchart have different external interfaces for actions and
receptivities. The external interface of Grafcet consists primarily of boolean
variables. Two action types are supported: impulse actions and level ac-
tions. The level actions are only of interest for binary variables (high/low,
true/false, etc).
The external interface of Grafchart consists of the data types that are sup-
ported by the underlying implementation language. The current toolbox
of Grafchart is implemented in G2 and it supports a lot different vari-
able types, e.g., booleans, numbers, symbols, strings, arrays, structures,
etc. Since the boolean variables are not as important in Grafchart as in
Grafcet, only impulse actions are supported.
107
Chapter 5. Grafchart
DECLARATION
color U: with b | g;
Token class: "blacktoken" color A: with B_attr | G_attr;
color P: product U*A;
For any:
There exists: "b:blacktoken" var x: U;
Event: "" var y: A;
Condition: ""
Figure 5.47 A Grafchart structure (left) and an identical Petri net structure
(right)
Execution
The firing rules that apply to Grafchart are similar, but not identical, to
those of Grafcet.
108
5.8 Grafchart vs Grafcet/Petri Nets
Grafchart understands it in the same way. For Grafcet, many different in-
terpretation algorithms exists. A complete and unambiguous algorithm is
given by [David, 1995]. This algorithm is global, see Chapter 3.2 (Inter-
pretation Algorithm). A global interpretation algorithm does also exist for
Grafchart. However, the algorithm currently implemented is local. When
a new external event occurs, the global algorithm searches through all
receptivities to see which transitions that have become fireable. Since the
implementation of Grafchart is based on activatable subworkspaces such a
search is not performed. When a new external event occurs or a condition
becomes true and the corresponding receptivities becomes true, a proce-
dure called fire is automatically started. This procedure takes care of the
deactivation and activation of steps and the enabling and de-enabling of
transitions. The local algorithm is more efficient and less time demanding
than the global algorithm. The local algorithm is also more suitable than
the global algorithm for applications where the execution is distributed.
EXAMPLE 5.8.1
Imagine a scenario where the execution of a system is implemented by
a Grafchart. The system could, e.g., be a production line where soda bot-
tles are being produced. Three machines are involved in the soda bottling
process. The first machine, called machine A, pours the soda into a bottle.
The second and third machine, called machine B and machine C respec-
tively, work in parallel. Machine B washes the bottles and puts a label
on them, at the same time as machine C wipes off the top of the bottle,
seals it with a cap and specifies its best-before-date. The Grafchart for
controlling the process is shown in Figure 5.48 (upper part).
109
Chapter 5. Grafchart
Machine A
Machine C
Machine B
Supervisory
node
Machine A ......................
......................
......................
...................... ...................... ......................
...................... ......................
becomes true would require that one of the nodes acted as a supervisory
node taking care of the scanning task. In the standard for Sequential
Function Charts, IEC 1131-3, [IEC, 1993], distributed systems are not
dealt with. In the standard it is assumed that an SFC is always executed
within the same node. However, ongoing standardization efforts are also
concerning distribution.
#
The firing of a transition is viewed differently in the Grafchart-HLV and
the Petri net model. When a transition fires in a Grafchart function chart,
the tokens are moved from the input places to the output places. This
means that it is the same tokens carrying the same attributes that are
moving around in the net. In the Petri net formalism, the tokens are not
being moved from input places to output places. Instead the tokens are
removed from the input places and completely new tokens are added to
110
5.8 Grafchart vs Grafcet/Petri Nets
the output places. It is, however, possible to obtain the same firing view,
in Grafchart as in Petri nets, by using the delete and create functions
in the receptivities but it is not the intention that these functions should
be used for this purpose.
Arc Inscriptions
In the Petri net formalism, arc inscriptions are needed to specify how the
different input places should contribute to the enabling of a transition and
how the different output places should be affected when the transition is
fired. Assume a Petri net with a place followed by an and-divergence
situation with two paths. The transition following the place is enabled if
there is a token of class P-token and a token of class Q-token in the place.
When the transition fires the two tokens should be removed from the
input place and a P-token should be added in the left path and a Q-token
should be added in the right path. In High-Level Grafchart, situations
like this can be handled in two different ways. The first solution involves
a structure transformation. The and-divergence case is transformed into
an or-divergence case and an extra empty dummy step is introduced, see
Figure 5.49.
a Ptoken
name token22
marker grafchartmarkerx
y 3
111
Chapter 5. Grafchart
T1 T1
a procedurestep M1
name I
parameters
T2 T2
procedure gp1 T5
M1
Procedure call
T5
T3 T6
T3
O
T6
Grafchart
T4 procedure T4
gp1
112
5.8 Grafchart vs Grafcet/Petri Nets
a a
Grafchart
procedure
gp1 O
b b
a process step
name
c parameters c
procedure M1 M1. M2 M1.M2....MK
gp1
M1 M2 MK
d d
113
Chapter 5. Grafchart
b d
a
e
e
c
f c
a a a a
114
5.8 Grafchart vs Grafcet/Petri Nets
A*
1
a scan interval
Initially A
Always B B*
Finally C
b 1
b
C*
c
true
Firing rules: The firing rules are not exactly identical in Grafchart and
in Grafcet. A step that has to be simultaneously deactivated and activated
remains active in Grafcet. This means that an impulse action associated
with such a step in Grafcet will not be executed whereas an initially
action associated with such a step in Grafchart will be executed. Some
Grafchart structures therefore has to be extended with an extra step in
the corresponding Grafcet, see Figure 5.54.
The activation of the extra step assures that the step containing the im-
pulse action is deactivated. A transition with a receptivity that is always
true follows the extra step. When this transition fires the step with the
impulse action is activated again and its impulse action is executed.
115
Chapter 5. Grafchart
T1 a
Initially A T1 a A*
T2 true
116
5.8 Grafchart vs Grafcet/Petri Nets
Advanced Features
The two features in Grafchart, parameterization and methods, cannot
conveniently be reconstructed in Grafcet or Petri nets. The parameteriza-
tion feature can only be reconstructed by having one Grafcet/Petri net for
each parameter setup, which is of course a bad replacement. The method
feature can be reconstructed by having ordinary macro steps as replace-
ments for the methods. This will give the same functionality but it will
not allow the application to be as well structured and organized.
Analysis
A Grafchart can be transformed into a Petri net and the analysis methods
that exist for Petri nets can be applied. This means that a Grafchart can
be analyzed with respect to, e.g., deadlock situations, see Chapter 9. The
transformation procedure should turn the Grafchart into an autonomous
Petri net, i.e., a Petri net without any actions or receptivities. This means
that it is only the structure of the Grafchart that can be analyzed see
Chapter 9.3.
True formal analysis requires that the step actions and the transition re-
ceptivities are taken into consideration. This is not the case in the analysis
examples presented in this thesis, see Chapter 9. However, true formal
verification support exists for Grafcet, see [Roussel and Lesage, 1996]
and [De Loor et al., 1997], and might be of interest also for Grafchart.
There is always a trade off between the complexity of the analysis methods
and the completeness of the generated results. The more complex meth-
ods, the more complete are the results. Complete results are, of course,
always prefered to narrow ones. However, when the analysis methods be-
come too complex, they will be too time-demanding or too complicated to
use, which will result in no result at all, and a narrow result is, of course,
always prefered to no result at all.
The analysis methods used in the thesis, see Chapter 9 are simple and the
generated result does therefore not answer all analysis related questions
but the generated result can still be of large interest in many applications.
117
Chapter 5. Grafchart
5.9 Implementation
An implementation of Grafchart has been made in G2, an object oriented
programming language, [Gensym Coorporation, 1995]. G2 is briefly de-
scribed in Appendix E. The Grafchart objects are implemented as G2
objects and the connections are represented by G2 connections.
The implementation of Grafchart is based on the G2 concept of activatable
subworkspaces. A workspace is a virtual, rectangular window upon which
various G2 items such as rules, procedures, objects, displays, and interac-
tion buttons can be placed. A workspace can also be attached to an object,
see Figure 5.55. In this case the workspace is called a subworkspace of
that object. When a subworkspace is deactivated, all the items on the
workspace are inactive and invisible to the G2 run-time system.
Subwork-
space
Object
Steps and actions The actions associated with a step are placed on the
subworkspace of the step. The actions are represented by G2 rules. The
subworkspace of the step is only active when the step itself is active, this
means that the rules, placed on the subworkspace, are only executed when
the step is active. The actions that may be performed are the action types
provided by G2. For example, it is possible to assign values to variables, to
start procedures, to create and delete objects, hide and show information,
perform animation actions, etc.
The actions are written in the G2s built in rule language. Sometimes,
however, the syntax of G2 can be somewhat annoying. To facilitate for
the user, the actions are therefore entered as action templates. These are
text strings that during compilation are translated into the correspond-
ing G2 rules. The entire syntax of G2 can be used in the action tem-
plates together with additional constructs of a syntactical sugar nature.
For example, the sometimes long and complicated syntax of certain G2
118
5.9 Implementation
subworkspace of
the step
Action-template
Initially subworkspace of
Step conclude that s10.X = 5 the action-template
Name S10 G2-rule
X
Initially
conclude that the x of s10 is 5
When the transition fires, i.e., when the G2 rule condition becomes true
and/or the event occurs, the G2 rule starts a procedure that takes care
of the activation and deactivation of steps and transitions.
119
Chapter 5. Grafchart
subworkspace of
the transition
G2-rule
a transition
When n>4 then start fire(the
Name T2 generic-transition superiour to
Event this workspace)
Condition n>4
In Figure 5.57 a transition is shown together with its event and condi-
tion attributes. The corresponding G2 rule is placed on the subworkspace
of the transition as shown in the same figure.
120
5.9 Implementation
Grafchart-object
Procedure-step Process-step
takes care of the deactivation and activation of steps and the enabling
and de-enabling of transitions. The local algorithm that is used in the im-
plementation is more efficient and less time demanding than the global
algorithm. In almost all cases the behavior is equivalent to the behavior
of the global algorithm.
EXAMPLE 5.9.1
Figure 5.59 shows a part of a function chart. The function chart has two
steps, named S1 and S2, and two transitions, named T 1 and T 2. Step
S1 is active and step S2 is inactive.
121
Chapter 5. Grafchart
S1
1. deactivate-step
T1 3. de-enable
2. activate-step
S2
T2 4. enable
1. Deactivate-step
(a) If the Grafchart object preceding the transition is a parallel-join
the deactivation will be done for all Grafchart objects preceding
the parallel-join.
(b) If the Grafchart object preceding the transition is a macro step
the deactivation will done for the macro step and the exit step
of the macro step.
(c) If the Grafchart object preceding the transition is a procedure
step the deactivation will be done for the procedure step and
for the exit step of the corresponding Grafchart procedure.
(d) If the Grafchart object preceding the transition is a process-
step, it will not be deactivated.
(e) If the Grafchart object preceding the transition is a step, the
step will be deactivated.
122
5.9 Implementation
2. Activate-step
3. De-enable
4. Enable
123
Chapter 5. Grafchart
(b) The objects receiving the enable message transmit the message
to each succeeding Grafchart object.
i. If, however, the Grafchart object is a parallel-join the enable
call will be sent to each Grafchart object succeeding the
parallel-join.
(c) The Grafchart object is a transition, this transition is enabled.
i. If, however, this Grafchart object preceding the transition
is a parallel-join the transition will only be enabled if all
input places to the parallel-join are active.
EXAMPLE 5.9.2
Consider the function chart in Figure 5.60. Transition T 1 and T 2 are
enabled. If transition T 1 fires, the following will happen.
1. Deactivate S1.
2. Activate the parallel bar P B1, i.e activate the steps S3 and S4.
3. De-enable the transitions T 1 and T 2.
4. Enable the transitions T 3 and T 4. Transition T 5 will not be enabled
since S5 is not active.
S1
T1 T2
PB1
S2
S5 S3 S4
PB2 T3 T4
T5
124
5.9 Implementation
Steps and actions The actions associated with a step are placed on
the subworkspace of the step. The actions are represented by action-
templates. Each action-template is related to a token class. During com-
pilation each action-template is translated to a G2 rules. The G2 rule is
placed on the subworkspace of the action-template, see Figure 5.61.
When a token enters a step its class is compared with the class speci-
fied in the action-templates placed on the subworkspace of the step. If
the class of the token and the class of an action-template are the same
the subworkspace of the action-template is activated, i.e., the G2 rule
is activated. The G2 rule checks if the conditions and requirements for
activation are fulfilled. If this is the case, the action is executed.
subworkspace of
the actiontemplate
G2 rule
actiontemplate
for and Qtoken q that is actioninvoking the
actiono superior to this workspace
Token class "Qtoken"
Action type "FINALLY" when (there exists a grafchartmarkero qgmo
that is animating q such that (qgmo is placedat
For any "q:Qtoken" the genericstepo superior to the workspace of
There exists " p:Ptoken" the actiono superior to this workspace))
Condition" p.y > 10" and (the status of qgmo is final)
Action text " conclude that
q.v = p.y" and (there exists a Ptoken p such that (the
grafchartmarkero that is animating p is placedat
the genericstepo superior to the workspace of
the actiono superior to this workspace))
and (the y of p >10)
then conclude that the v of q = the y of p
125
Chapter 5. Grafchart
When a token enters a step its class is compared with the class specified
in each receptivity-template belonging to the receptivities of the enabled
transitions. This means that a receptivity-template associated with to-
ken class Q is only active if there is a token of class Q that enables the
transition, i.e., if there is a token of class Q in the preceding step of the
transition. If the class of the token and the class of a receptivity-template
are the same the subworkspace of the receptivity-template is activated,
i.e., the G2 rule is activated. The G2 rule checks if the receptivity is true.
If so, the receptivity is fired.
Object-grafchart-object
126
5.9 Implementation
To specify the actions associated with a step the user uses an object called
action-o, to specify the receptivities associated with a transition the user
uses an object called receptivity-o and to specify the name of the Graf-
chart procedure that is to be called from a procedure or process step an
object called procedure-call-o is used. The class hierarchy of these three
template-elements and their icons are shown in Figure 5.63 and 5.64.
Object-grafchart-object
127
Chapter 5. Grafchart
5.10 Applications
Grafchart, both the basic and the high-level version, has been used in
several applications.
Training Simulator
Grafchart-BV has been used to implement a prototype of a training simu-
lator for a sugar crystallization process, [Nilsson, 1991]. In this application
Grafchart is used both to structure the simulation model of the process
and to implement the control system of the process.
128
5.10 Applications
Alarm Filtering
Grafchart-HLV has been used to implement alarm filters. Information
overload due to large numbers of warnings and alarms is a common prob-
lem in, e.g., the process industry. This typically occurs in fault situations
when a primary alarm is accompanied by large numbers of secondary
alarms. Another case is nuisance alarms caused by improperly tuned
alarm limits. One way of handling excess alarms is to use alarm filters.
The task of the alarm filter is to filter out alarms and to aggregate mul-
tiple alarms into high-level alarms. In many cases it is the combination
of multiple alarms that have occurred within a certain time period that
gives the best indication of what is happening in the process.
Grafchart can be used to represent alarm (event) patterns. The approach
is based on the possibility to use a finite state machine as an acceptor
129
Chapter 5. Grafchart
5.11 Summary
Grafchart is the name of a mathematical sequential control model and
a toolbox. Grafchart is based on a syntax similar to that of Grafcet. The
graphical elements are steps, transitions, macro steps, procedure steps,
process steps, Grafchart procedures and Grafchart processes. Grafchart
also includes ideas from Petri nets, high-level nets and object-oriented pro-
gramming. Advanced features like parameterization, methods and mes-
sage passing, object tokens, and multi-dimensional charts, are included
in the language. The language exists in to different versions: one basic
version, mainly based upon Grafcet, and one high-level version including
more ideas from Petri nets and object-oriented programming. Grafchart
is aimed at sequential control application at local and supervisory level.
130
6
Batch Control Systems
131
Chapter 6. Batch Control Systems
132
6.1 Batch Processing
133
Chapter 6. Batch Control Systems
The discussion about batch control systems and the progress in batch pro-
cess control has been hampered by the lack of a standard terminology. In
the last years, there have been three major initiatives with the aim to
provide a common language. The first major effort was an outgrowth of a
Purdue University workshop on batch control in the mid 1980s, [Williams,
1988]. The second was made by NAMUR, [NAMUR, 1992]. The third ma-
jor effort is sponsored by the Standards and Practices division of ISA
(Instrument Society of America), the International Society for Measure-
ment and Control, [ISA, 1995]. The standard is divided into two parts,
Part 1, called S88.01 deals with models, terminology and functionality.
This part of the standard was approved by the main committee of ISA
and ANSI in 1995. Part 2 will deal with data structures and language
guidelines. The ISA S88.01 standard has recently been accepted as an
international IEC (International Electrotechnical Commission) standard
IEC 61512-1, [IEC, 1997].
The first part of the ISA S88 standard describes batch control from two
different viewpoints: the process view and the equipment view, see Fig-
ure 6.1. The process view is represented by the process model and is
normally the view of the chemists. The equipment view is represented by
the physical model and is normally the view of the product engineer or
the process operator.
134
6.3 The Batch Standard ISA-S88.01
Process Equipment
View Procedural Control View
Process Model
A batch process can be hierarchically subdivided as shown in Figure 6.1
(left).
135
Chapter 6. Batch Control Systems
In the process model, the procedure for making a product does not consider
the actual equipment for performing the different process steps.
Physical Model
The physical model of S88 defines the hierarchical relationships between
the physical assets involved in batch manufacturing. The model has seven
levels, starting at the top with an enterprise, a site and an area. In Fig-
ure 6.1 (right) only the four lower levels are shown, with the following
interpretation:
Recipes
To actually manufacture a batch in a process cell the standard proposes
a gradually refinement of the process model based on four recipe types;
general recipe, site recipe, master recipe and control recipe. A recipe con-
tains administrative information, formula information, requirements on
the equipment needed, and the procedure that defines how the recipe
should be produced. The procedure is organized according to the procedu-
ral control model, see Chapter 6.3 (Procedural Control).
136
6.3 The Batch Standard ISA-S88.01
General recipe
The general recipe is an enterprise level recipe that serves as a
basis for the other recipes. The general recipe is created without
specific knowledge of the process cell equipment that will be used to
manufacture the product.
Site recipe
The site recipe is specific to a particular site. The language in which
it is written, the units of measurements, and the raw materials are
adjusted to the site.
Master recipe
The master recipe is targeted to a specific process cell. A master
recipe is either derived from a general recipe or created as a stand-
alone entity by people that have all the information that otherwise
would have been included in the general or the site recipe.
Control recipe
The control recipe is originally a copy of the master recipe which
has been completed and/or modified with scheduling, operational
and equipment information. A control recipe can be viewed as an
instantiation of a master recipe.
The four recipes are gradually refined to the stage where all necessary
aspects for the execution of the recipe on a certain type of equipment are
taken into account. The general and site recipes are equipment indepen-
dent whereas the master and control recipes are equipment dependent. In
order to distinguish between equipment independent and equipment de-
pendent process steps different terminology is used. The terms Procedure,
Unit Procedure, Operation, and Phase are introduced for the equipment
dependent process steps, see Figure 6.1.
Procedural Control
The four recipe levels together with the equipment control constitute the
link between the process model and the physical model, denoted procedu-
ral control, see Figure 6.1. Procedural control is characteristic for batch
processes. It directs equipment-oriented actions to take place in an or-
dered sequence in order to carry out a process-oriented task.
The procedural structure is hierarchical, see Figure 6.2. A procedure can
gradually be broken down into smaller parts.
The procedure is the highest level in the hierarchy and defines the
strategy for accomplishing a major processing action such as making
a batch. It is defined in terms of unit procedures, and/or operations,
137
Chapter 6. Batch Control Systems
Procedure
Unit
Procedure
Operation
Phase
The IEC 1131-3 standard, which was published in 1993, specifies program-
ming languages for controllers. This standard fills an important void since
part 1 of ISA-S88 does not specify languages for configuring the sequen-
tial and batch control functions. Many suppliers have however, already
incorporated the IEC 1131-3 standard in their products.
Sequential Function Charts (SFC) are gaining acceptance for configura-
tion of the procedural part of recipes. The main reasons for this are that
138
6.3 The Batch Standard ISA-S88.01
SFC are graphical, easy to configure and easy to understand. SFC is also
the basis for Procedural Function Charts (PFC), a graphical language for
recipe representation currently being defined in the S88 working group.
Equipment Control
The control recipe itself does not contain enough information to operate a
process cell. On some level it must be linked to the process equipment con-
trol, i.e., the control actions that are associated with the different equip-
ment objects. S88 offers large flexibility with respect to at which level the
control recipe should reference the equipment control. It is also allowed
to omit one or more of the levels in the procedural model. The situation
is shown in Figure 6.3. The dashed levels could either be contained in the
control recipe or in the equipment control. Several examples of how this
can be done will be given in Chapter 8.
Recipe Procedure
Procedure
Unit
Procedure
Operation
Phase Equipment
Phase
139
Chapter 6. Batch Control Systems
Production Production
Recipe Planning and Information
Management Scheduling Management
Process
Management
Unit
Supervision
Process
Control
Recipe Management
The need to have control functions that can manage general, site,
and master recipes implies a need for the recipe management control
activity.
Production Planning and Scheduling
Production of batches must occur within a planned time domain.
Production planning and scheduling is the control activity where
these control functions are implemented. Scheduling is discussed
further in Chapter 6.4.
Production Information Management
Various types of production information must be available and the
140
6.4 Scheduling
6.4 Scheduling
Scheduling is a wide concept that can be broken down hierarchically,
[Fisher, 1990], see Figure 6.5.
Production
planning
Production
scheduling
Dynamic
scheduling
Resource
arbitration
and
allocation
141
Chapter 6. Batch Control Systems
Many different commercial batch control systems exist today. They are
produced and utilized all around the world. Some examples are: FlexBatch
from GSE Systems, OpenBatch from PID Incorporate, VisualBatch from
Intellution, FoxBatch from Foxboro, InBatch from Wonderware, SattBatch
from Alfa Laval Automation, Advant from ABB Industrial Systems, etc.
The batch control system suppliers are well aware of the ISA S88 batch
control standard and their systems do, to greater or lesser extent, depend-
ing on the age of the system, comply with it. Even thought the different
systems have been developed at different independent companies they
142
6.5 Industry Practice
Recipe Structures
The recipe structure in all the different systems is composed of steps and
transitions. The steps are represented by rectangles and the transitions
are represented by horizontal bars or small rectangles, see Figure 6.6.
Step
Transition
The steps visualize the different tasks that should be performed when
producing a batch and the transitions represents a change of task. This
resembles the general ideas in Grafcet.
However, the steps and the transitions do not necessarily appear one after
the other. In most of the systems, a step may be connected to another step
and a transition may follow directly upon another transition. The reason
for this strange syntax is, according to the developers, that not all steps
and transitions in a Grafcet have a meaning. There are cases where the
step is only a dummy-step or the transition represents the-always-true-
condition; these steps and transitions can be omitted without loosing any
functionality. Some examples are given in Figure 6.7.
A recipe is always structured in such a way that the step that should
be activated when the recipe is initialized is placed in the top position
(uppermost position), and the recipe executes from the top position to the
bottom position, see Figure 6.8.
Recipe Execution
The execution of a recipe is normally color-coded. Even though the colors
are not fixed but can be chosen by the operator, the default setting is
always the same. The step(s) that is currently executing is green. The
143
Chapter 6. Batch Control Systems
a a
true b
c
b
Figure 6.7 A commercial batch recipe structure (left) and the corresponding
Grafcet structure (right).
step(s) that has been executed is red and a step that has been halted,
paused or is waiting for any other reason is yellow. The execution of the
recipe structure is thus not visualized by a token that moves around in
the net, like in Grafcet or Grafchart, but with different colors.
EXECUTION ORDER
144
6.5 Industry Practice
Recipe Implementation
The recipes are implemented according to the hierarchical procedural
model. When a recipe is first displayed, each step represents a unit-
procedure. If a step, corresponding to a unit-procedure, is opened-up a
sequence of steps and transitions shows up, compare with macro-steps in
Grafcet. In this sequence the steps correspond to an operation. There is no
special syntax that indicates for the user that a step can be "opened-up".
All commercial systems support three hierarchical levels: unit-procedures,
operations, and phases. In almost all systems it is required that all lev-
els are implemented, even thought this is not required in the standard.
A step that represents a phase can not be opened. The phases are most
often implemented in a textual language.
Plant Status
Even though a single recipe can be represented graphically, the overall
status of the plant is always represented textually. Each recipe is named
by a tag name followed by some information about its status (run/hold/to-
be-started/completed). In Figure 6.9 an example of how the screen can
look for the user is given. In the upper left corner of the screen a textual
view of the plant status is shown. Five batches are under production.
One is completed, two are executing, one is halted and one is not yet
started. Next to the textual view of the plant a recipe structure is shown,
this corresponds to the procedure for the recipe named Recipe-D-001. The
first unit-procedure has executed while the second step is halted. This is
indicated with the colors of the respective step.
Figure 6.9 Textual view of the plant status (upper right corner).
145
Chapter 6. Batch Control Systems
The reason for having a textual representation is, according to the devel-
opers, that it would be to messy to display all recipes at the same time
on the screen. A textual overview is less space demanding and gives thus
a better overview. The user can select one or several of the recipes from
the list and display them graphically.
Resource Allocation
Associated with each recipe is a list of resource requirements. The user
can either specify a resource by directly type in the name of the desired
resource or by specifying a group of resources that are all equally good.
No commercial systems of today visualize the resource allocation.
It is possible for the user to specify when the required resource should
be allocated. Either all resources that are going to be used when produc-
ing a batch can be allocated immediately when the recipe is started or
the resources can be allocated one-by-one just before they are needed for
production. The first method is to prefer if the batch is very sensible and
valuable and therefore not should be exposed for a waiting-period. The
method guarantees that the batch will have the resources when needed.
In the second method, the allocation is done just before the resource is
needed. It might then happen that a resource is not available, it could, e.g.,
be allocated by another batch. In that case the batch either has to allocate
another resource or wait until the desired resource becomes available.
Using the first method, the risk of getting into a deadlock situation is re-
moved. On the other hand the resources are unavailable for other batches
for an unnecessary long period of time. Using the second method, the
operator must manually assure that the production does not run into a
deadlock situation. In no commercial system there is support for deadlock
detection.
Phase Implementation
The language chosen for the phase implementation differs from enterprise
to enterprise and depends on their type of PLCs.
The batch control system including the recipe system is sold by a batch
control system vendor. The vendor helps the enterprise to structure the
supervisory implementation of the recipes. However, the implementation
of the phases, i.e., the actual local equipment control, is done by the en-
terprise themselves.
Interlocks and safety assurances are most often taken care of within the
phase logic.
146
6.6 Summary
Compliance to PLCs
Not all batch control systems are compliant with all PLC types. Certain
batch control systems require that the PLCs are of a certain type. Most
often the PLCs are required to be bought from the same vendor as the
batch control system. However, commercial batch control systems exist
that are PLC-type independent, e.g., OpenBatch from PID Incorporate
and InBatch from Wonderware.
Remarks
The way a recipe is structured in commercial systems reminds of the
structure of Grafcet. Even though the similarities are obvious no explicit
connection exists. No batch system vendor has, as far as we know, expe-
rience or knowledge about the theory of Grafcet and/or Petri nets. The
similarities have occurred by mere accident. The many similarities do
however, confirm that the graphical syntax of Grafcet is very clear and
intuitive.
6.6 Summary
Industrial manufacturing and production processes can be classified as
continuous, discrete or batch. Traditionally the areas of continuous and
discrete processes have been the most research intensive areas. However,
increased demands on production flexibility, small scale production and
customer-driven production have led to an increased interest for batch
processes and batch control. A batch process is neither continuous nor
discrete, yet it has characteristics from both. A batch cell can be made
highly flexible, both with respect to the number of different products it
can produce and with respect to the structure of the plant. The multi-
product, network-structured batch cell is the most flexible but also the
most difficult type of plant to control. The recent batch control standard
ISA-S88.01, formally defines the terminology, models and functionality
of batch control systems. The standard mentions the possibility to use
Grafcet but only at the very lowest level of control. However, there is also
147
Chapter 6. Batch Control Systems
148
7
Batch Control Systems and
Grafchart
The aim of this thesis is to show various ways in which the concepts
of Grafchart can be used in the context of recipe-based batch control.
The aim is not to present a complete batch control system. As will be
shown Grafchart can be used at all levels in the hierarchical procedure
model, from the PLC level sequence control to the representation of entire
recipes. Grafchart also facilitates the linking that has to exist between the
control recipe procedural elements and the equipment control procedural
elements.
A batch scenario, consisting of one batch cell, has been defined and imple-
mented in G2. The batch scenario is used as a test platform to investigate
how Grafchart can be used in a batch control system.
This chapter starts with a presentation of related work. The common point
of the works presented, is that they are all based on Petri nets or Grafcet.
The chapter also contains a presentation of how Grafchart can be used in
a batch control system and, it contains a description of the defined batch
scenario.
149
Chapter 7. Batch Control Systems and Grafchart
The work by Tittus differ from that in this thesis in that it is more fo-
cused upon formal verification and synthesis, see Chapter 1. The aim is to
generate a safe control recipe and no effort is put into the representation
or implementation of the recipes.
The focus of the work by Wllhaf and Engell is modeling and simulation.
They focus upon the mathematical algorithms used to solve the differ-
ential and algebraic equations for simulation of the materials. A large
150
7.2 Grafchart for Batch Control
database for physical and chemical properties of the most common sub-
stances is included in their tool. However, they do not focus upon the
recipe management system and the issue of making the recipes reusable
and flexible.
The aim of the work by Hanisch and Fleck is to join the theoretic work on
resource allocation problems with the need of such strategies in recipe-
control framework (recipe-based control systems), [Hanisch and Fleck,
1996]. They use high-level Petri nets to model both the recipe-based oper-
ations and the resource allocation strategy. The resource allocation module
is implemented separately within the process control system. The strategy
of the resource allocation module is to optimize the productivity. Simula-
tion of the system allows the control engineer to answer questions about
the utilization of resources, bottlenecks and resource dimensions.
Not many tools nor methods exist that allow verification of the recipe
before it is used for control. Hazardous processes exist and motivate the
need for such methods. The idea of the approach of Brettschneider, Gen-
rich and Hanisch, [Brettschmeider et al., 1996], is to model the recipe, the
plant and the device control (equipment control) by means of high-level
Petri nets. By merging the nets, verification and performance analysis
can be performed using the analysis methods of Petri nets.
151
Chapter 7. Batch Control Systems and Grafchart
Physical Model
The physical model of ISA-S88 defines the hierarchical relationships be-
tween the physical units involved in batch control. Only the lower four
levels will be considered as shown in Figure 7.1 (left).
G2 object
Must contain
Attribute
Attribute
Attribute
May contain
Equipment
Module aninstanceof
aninstanceof
May
contain
G2 object G2 object
Equipment Module Equipment Module
May contain Object Object
Attribute
Attribute
Attribute
Attribute
Control
Module
May
contain
Figure 7.1 ISA-S88 Physical Model (left) and its G2 representation (right).
Procedural Model
The procedural model of ISA-S88 is also hierarchical, see Chapter 6.3
(Procedural Control). The structure of the procedural model is shown in
Figure 7.2 (left).
152
7.2 Grafchart for Batch Control
Function chart =
Procedure Procedure
Subworkspace
Subworkspace
consists of an
ordered set of
Macro Step
Unit procedure Unit Procedure Macro Step
Operation Macro Step
Phase
consists of an
ordered set of
Operation
consists of an Subworkspace
ordered set of
Phase Step
consists of an
ordered set of
Step
Figure 7.2 ISA-S88 Procedural Model (left) and its representation in Grafchart
(right).
Recipes
ISA-S88 defines four recipe types: general recipes, site recipes, master
recipes and control recipes. Here, only the master and control recipes are
considered. A recipe contains administrative information, formula infor-
mation, requirements on the equipment needed to produce the recipe and
the procedure that defines how the recipe should be produced. The proce-
dure is organized according to the procedural control model. The master
recipe is targeted to a process cell. Each individual batch is represented
by its control recipe. The control recipe is originally a copy of the master
recipe which has been completed and/or modified with scheduling, oper-
ational and equipment information. A control recipe can be viewed as an
instantiation of a master recipe.
153
Chapter 7. Batch Control Systems and Grafchart
a Grafchart process
Equipment ...
Formula ...
154
7.3 A Batch Scenario Implemented in G2
Procedure
an object token
an object token Equipment ...
Equipment ... Formula ...
Formula ... Procedure a Grafchart method
Figure 7.4 Control recipe as an object token without method (left) or with method
(right).
155
Chapter 7. Batch Control Systems and Grafchart
CHARGE
Method call
interconnected through valve batteries. The cell can produce two products
named D and E using three reactants A, B and C. A schematic of the batch
cell is shown in Figure 7.6.
156
7.3 A Batch Scenario Implemented in G2
The scenario is divided into three major parts: a simulator that simulates
the dynamics of the scenario, a process control system and an operator
interface. Figure 7.7 shows the three parts of the batch cell.
Unit Processes
The batch cell is composed of several unit processes.
Storage tanks The storage tanks contain the raw materials, i.e the
reactants. Since there are three different reactants there are three storage
tanks in the cell, one for each reactant. Each storage tank has a level-
transmitter and a temperature-transmitter. Each storage tank also has
an output on-off valve and pump connected to the outlet of the tank. The
storage tanks are assumed never to be empty. The schematic of a storage
tank is shown in Figure 7.8 (left).
157
Chapter 7. Batch Control Systems and Grafchart
Reactors A reactor has two inlets and one outlet. It has an agitator
and four transmitters: level, temperature, pressure and flow. The outflow
is, as before, controlled by a pump and an on-off-valve. The inflow, and
thereby the level in the reactor, is controlled by control valves using a
PID-controller. A schematic of the reactor is given in Figure 7.9 (left).
The main task of the reactor is to perform chemical reactions. This is
done by heating or cooling the substance inside the reactor. The reactor
has a jacket which can be filled with a hot or cold liquid. The temperature
in the reactor is controlled by two cascade coupled PID-controllers that
adjust the flow through the jacket.
Product tanks The product tanks are used for storing the finished
products. They are assumed never to be full. Each product tank has an
inlet valve and a level transmitter. A schematic of a product tank is shown
in Figure 7.9 (right).
158
7.3 A Batch Scenario Implemented in G2
159
Chapter 7. Batch Control Systems and Grafchart
Operator Interface
The operator interface, see Figure 7.6, provides the operator with a user
friendly interface, through which he or she can get information about the
status of the plant. Through the interface the operator can also interact
with the plant.
By clicking on any of the units the internal structure of this unit is shown.
The operator can open and close the valves manually by clicking on them.
The pumps can be turned on and off manually. Some of the units also
have PID-controllers, these can be operated manually or automatically.
When clicking on any of the sensors a trend-curve of the measured signal
is shown, see Figure 7.11.
Figure 7.11 The operator interface showing the internal structure of a mixer and
a trend curve.
As the batch moves through the plant, its actual position is highlighted.
A unit currently used by a batch is marked with a black dot placed at the
upper right corner. The level indicator of this unit shows the actual level
in the unit. If the batch is using a pipe, i.e. is on its way from one unit to
an other, this pipe is marked with a colour.
Dynamic Simulator
The dynamic simulator is used as a substitute for a real plant. It simu-
lates the mass balances, energy balances and the chemical reactions. All
simulations are done in real-time.
160
7.3 A Batch Scenario Implemented in G2
A+B 2D
C+D E
The total mass balance, the component mass balances and the energy bal-
ance for the reactions are calculated and simulated. A detailed description
of the dynamic simulator is found in Appendix D.
Figure 7.12 The process control system with its equipment objects and their in-
ternal structure.
161
Chapter 7. Batch Control Systems and Grafchart
Recipes
Two reactions can be simulated in the scenario:
A+ B 2D
C+D E
162
7.4 Summary
7.4 Summary
163
8
Recipe Structuring using
Grafchart
164
8.1 Control Recipes as Grafchart Function Charts
Instance
From the steps and transitions within the control recipe the attributes
can be referenced using the sup notation, see Chapter 5.3.
Recipe
Procedure
Recipe Equipment
Phase Phase
References
(method call)
Equipment
Equipment
Step
Phase
165
Chapter 8. Recipe Structuring using Grafchart
The resulting control recipe is shown in Figure 8.3. The different unit pro-
cesses that the batch passes through are indicated by the column-based
organization of the recipe. The recipe starts by an assignment step in
which the resources necessary to produce the recipe are allocated. Two
versions of the recipe have been implemented. One where the operator
manually assigns all the equipment before starting the procedure and one
where the equipment is assigned automatically through a simple search
algorithm immediately before the equipment is needed. After the assign-
ment step the two reactants A and B are filled into a mixer. This is done in
parallel, since the mixers have two inlets. Then the agitation is started.
When the agitation is finished the mixer is emptied and at the same time
a transition
Event
Condition true
166
8.1 Control Recipes as Grafchart Function Charts
the reactor is charged. This is expressed with the Grafchart parallel con-
struct. When the charging is finished, the reaction is started by heating
the batch. Finally, the content of the reactor is transfered to the product
tank and the production of the batch is completed.
Each recipe phase is represented by a procedure step that calls the cor-
responding equipment phase. In Figure 8.3 the attribute table for the
agitate step is shown. The procedure step calls the agitate methods in
the mixer that has been assigned to the batch. This mixer is contained in
the mixer attribute of the recipe. The parameter time is given the value
1. This denotes how long the agitation will take. The agitate equipment
phase consists of two steps where the agitator motor is active until the
defined time has elapsed. The situation is shown in Figure 8.4.
SB SC
SA
Assignment
a procedure-step
Parameters "time 1"
Fill-A Fill-B
Procedure "sup.mixer agitate"
M1 M2
Heat
R1 R2
Discharge Charge
P1 P2 P3
Between the procedure steps in a recipe, transitions are placed. The equip-
ment phases called by the procedure steps are most often written so that
they themselves take care of the initialization and the termination of the
phase. This means that the receptivity of a transition placed between two
procedure steps becomes very simple. In Figure 8.3, the transition recep-
tivity of the transition following the heat step is shown. As can be seen
this receptivity only contains an always-true condition.
167
Chapter 8. Recipe Structuring using Grafchart
Recipe
Procedure
Recipe
Operation
Recipe Equipment
Phase Phase
References
(method call)
Equipment
Equipment
Step
Phase
The resulting control recipe is shown in Figure 8.6. The control recipe
is a straight sequence of recipe operations. Each recipe operation is rep-
resented as a macro step that contains the recipe phases. The phases
are represented as procedure steps that call the corresponding equipment
phases.
168
8.1 Control Recipes as Grafchart Function Charts
In the previous examples, the control recipe has explicit information about
which type of unit processes that the batch should be processed in, e.g., a
mixer, buffer or reactor. Another possibility is to let the control recipe be
completely independent from which unit type it should use. This can be
achieved by defining a number of generic equipment independent opera-
tions. Examples of generic operations could be store, store-with-agitation,
mix, mix-with-agitation, store-under-heating, exothermal-reaction etc. It
is possible to mix two reactants in both mixers, buffers and reactors. How-
ever, it is preferred to mix reactants in a mixer. The mix-with-agitation
operation cannot be performed in a buffer. The store-under-heating oper-
ation can be performed in both buffers and reactors but it is preferred to
use the buffers for this. Hence, for each generic operation a preference
ordering must be given. It is the task of the resource allocation scheme to
find the best suited unit processes for each recipe operation and to assign
this to the recipe when it is needed. The equipment operations are repre-
sented as equipment object methods. These methods call the equipment
phases which also are methods of the equipment objects. This structure
has not been implemented and tested in the batch scenario.
169
Chapter 8. Recipe Structuring using Grafchart
Recipe
Procedure
Recipe Equipment
Operation Operation
References
(method call)
Equipment
Phase
Equipment
Equipment
Step
Phase
The recipe structuring alternatives presented in this section use the high-
level version of Grafchart.
In the previous section, one copy of the master recipe was needed for
each batch that was produced. The reason for this is not that the batches
are produced in different ways or that they use different types of equip-
ment, but that they do not necessarily use the same equipment or have
the same batch-identity number. Since the attributes, in the last section,
were global in the context of the function chart, the same control recipe
cannot be used simultaneously by more than one batch. If, however, the
170
8.2 Control Recipes as Object Tokens
batch specific information is stored locally, e.g., in the tokens, the same
function chart can be used by more than one batch. Information that the
batches share is represented globally, whereas batch specific information
is represented locally. Since the token contains the batch specific informa-
tion, the token represents the control recipe and the function chart that
the token resides in is the common master recipe. This way of structuring
a recipe is shown in Figure 8.8.
Master recipe
Control recipe
a token
name Recipe1
mixer M1
reactor R1
size 0.7
batchid a412
The recipe alternatives presented in this section are all based on recipe
phases and each phase calls the associated equipment phase through a
method call. It is also possible to build up the recipe using operations
instead of phases, in the same way as described in Chapter 8.1 (Recipes
Based on Recipe Operations).
The recipe shown in Figure 8.3 can be structured with object tokens. The
attributes previously contained in the control recipe function chart will
now be contained in the tokens. It is possible to have several tokens in
the same master recipe. Each token corresponds to one control recipe, i.e.,
one batch.
In the recipe two batches are under production. One batch is currently
filling reactant A and reactant B in one of the mixers and the other is
heating the content in one of the reactors. At the moment there is thus
only one mixer (out of two) and one reactor (out of two) reserved by a
batch.
171
Chapter 8. Recipe Structuring using Grafchart
172
8.2 Control Recipes as Object Tokens
The chart can also be extended with more equipment oriented operations
such as cleaning (CIP - clean in place). In Figure 8.10 an extremely simple
master recipe is shown. Here, a CIP-operation must be performed on each
unit after it has been used by a batch.
CIP
Master recipe
Free
mixers
Combined Network
Using the object token structuring possibility combined with resource al-
location it is possible to merge all different master recipes into one single
Grafchart. This chart visualizes the resources sharing that exists between
the batches. The chart can be analyzed with Petri nets analysis methods
to detect if there is a risk for deadlock. The case for two simple master
recipes is shown in Figure 8.11.
Free
mixers
Free
reactors
173
Chapter 8. Recipe Structuring using Grafchart
coloured-recipe-D
coloured-recipe-E
resource allocation
M4B-T1
MIXING REACTION BUFFER STORAGE
M4B-T1A M4B-T1B
New
M4B-S3 batch Create mixers New batch
M4B-S1
Assignment
M4B-T2
Fill-A Fill-B
Create buffers
Agitate
M4B-T3
Create reactors
Assignment
Empty Charge
Deassignment
M4B-T4B
M4B-T4A
Heat
Assignment
Discharge Fill-D
M4B-T5A
Deassignment
M4B-T5B
Fill-C
Assignment
Charge Discharge
Deassignment
M4B-T6B
Heat
Discharge Charge
Deassignment
M4B-T7B
174
8.3 Multi-dimensional Recipes
CP2
Free
CP1 mixers CP1
CP1 CP1
CP4
Free
CP5 buffers CP3
CP5
CP3
CP6
CP6 Free
reactors CP6
CP4
CP5 CP5
CP2
CP2
Figure 8.13 Combined net with all master recipes using connection posts.
The multi-dimensional feature of Grafchart fits nicely into the batch con-
trol problem. In the first recipe structuring alternative, Chapter 8.1, only
one token, representing one batch, could reside in one chart. In the sec-
ond recipe structuring alternative, Chapter 8.2, several tokens, each rep-
resenting one batch, could reside in a chart, provided they were all of
the same type. The tokens shared the structure of the master recipe but
contained specific information about the equipment to use when being
175
Chapter 8. Recipe Structuring using Grafchart
Free
mixers
Free
reactors
Figure 8.14 Combined net with all master recipes using connection posts.
a Recipe_A
a Recipe_B
a Recipe_A
176
8.3 Multi-dimensional Recipes
a recipe-token
Procedure a grafchart-method
Size 2
New recipe-A
New recipe-B
a recipe-a
Mixer m1
Initialization Buffer none
Reactor none
MIXING REACTION STORAGE
Size 2
Production Batch id a415
Assignment
Token class "recipe-token"
Assignment
Batch ready
Empty
Charge
Heat
Discharge Charge
177
Chapter 8. Recipe Structuring using Grafchart
When a token enters the procedure step a call is performed and a method
of the token is started. This method describes how this specific batch
should be produced and constitutes a part of the second level in the multi-
dimensional recipe. The method is implemented as a Grafchart procedure,
see Chapter 5.5. The attributes of the Grafchart procedure contain the
equipment specification of the batch. The different levels of the multi-
dimensional chart communicate through the different dot notations, see
Chapter 5.5 (Multi-dimensional Charts).
Each control recipe, i.e., each token, is represented by an object token and
visualized by a grafchart marker. When a new batch is to be produced a
new control recipe object token is created and a grafchart marker of the
correct type is placed in the initial-step of the function chart. A master
recipe is represented as an object token with attributes and a method. A
control recipe object token is created by copying the master recipe object
token.
The resource allocation of this recipe structuring alternative is done im-
plicitly. Immediately before an equipment is needed a simple search algo-
rithm is executed and the correct equipment is automatically assigned to
the batch.
178
8.3 Multi-dimensional Recipes
New recipe-A
New recipe-B
Spawns recipe
procedure CIP
Occupied
Executes
resources
recipe
179
Chapter 8. Recipe Structuring using Grafchart
Mixer
M1
Buffer Buffer
B1 B2
Reactor Reactor
R1 R2
180
8.4 Process Cell Structured Recipes
Free
Reactor
Reactor
In order to decrease the size of the net macro steps can be used to en-
capsulate the extra states. An example of this is shown in Figure 8.20.
This representation can, however, be confusing, since the token is placed
in the resource-macrostep before the resource is allocated.
Mixer
Free
Reactor
Reactor
Reactor
CIP
181
Chapter 8. Recipe Structuring using Grafchart
In the Petri net field, nets with tokens as real numbers are known as
continuous Petri nets, see Chapter 2.6.
182
8.4 Process Cell Structured Recipes
The process cell structured recipe easily becomes complex if there are
many resources in the plant. This is due to the fact that between every
two units there is a transition. In the process plant shown in Figure 7.6
each mixer is connected to three buffers and two reactors. This means
that there should be five transitions following each mixer-step. In order
to improve the situation, a transition-battery can be introduced. The task
of the transition-battery can be compared to the one of the valve-battery,
see Figure 7.10, i.e., to give a more compact visualization. A resource allo-
cation chart structured with transition batteries is shown in Figure 8.22.
TB1
M1 M2
TB2
B1 B2 B3
TB3
R1 R2
TB4
In the resource allocation chart there are four transition batteries, TB1,
TB2, TB3 and TB4. The four transition batteries are shown in Figure 8.23.
183
Chapter 8. Recipe Structuring using Grafchart
. . M1 . . B1
. . B1 . . R1
. . R1 . . B2
. . B2 . . R2
. . R2 . . B3
. . B3
. . M2
.. . R1
. PT1
. . . R2 . PT2
. PT3
184
8.5 Resource Allocation
ment that the batch will use. If the specified resource is not available
when needed, the recipe execution will pause and wait until it becomes
available. In the second version of implicit resource allocation, the re-
sources are automatically allocated. A simple search algorithm looks for
an available resource of the correct type, and, if found, allocates it to the
recipe.
In explicit resource allocation, resource tokens are used to represent the
resources, i.e., the state of the resources in the plant are graphically pre-
sented for the user. This is the case of the structures in Chapter 8.2
(Recipes Extended with Resource Allocation) (Combined Network), and
Chapter 8.3 (Multi-dimensional Recipes with Explicit Resource Alloca-
tion).
Resource allocation of exclusive-use resources and deadlock analysis have
been looked at in other areas and their results might be useful also for
a recipe management system in the batch control field. This is discussed
further in Chapter 9.
Semaphores
In real-time programming the concept of semaphores are used to obtain
mutual exclusion, [Dijkstra, 1968]. A semaphore is a flag indicating if a
resource is available or not. If a process requests a non-available resource
it is placed in a queue. The processes have different priorities and the
queue is priority-sorted. When the requested resource is released the first
process in the queue can allocate it. For further reading about semaphores
see [Burns and Wellings, 1996].
The resource token in the recipe structures with explicit resource alloca-
tion can be compared to a semaphore. The fact that different recipes could
be given different priorities and that they could be put in a waiting queue
is relevant also for batch processes. One way of approaching this would be
to introduce special FIFO-steps that maintain a queue of tokens. In Fig-
ure 8.24 a small example of a system with mutually exclusive resources
is shown.
Shared Resources
The semaphore construct can also be used for shared resources, i.e., re-
sources that can be used by maximum n simultaneous users. A situation
like this can be implemented in Grafchart. Each sharable resource is rep-
resented by as many tokens as its maximum usage limit, see Figure 8.25.
Sharable resources might also have real-value capacity constraints. This
can be implemented in Grafchart, according to Figure 8.26.
185
Chapter 8. Recipe Structuring using Grafchart
3 reactors
Max. 3 simultaneous
users of e.g.,
the steam system
Situations were the resource has to fulfill certain constraints, e.g., the
resource has to have a volume not less than a certain value, can be imple-
mented in Grafchart using the same structure as in Figure 8.26 extended
with a receptivity checking the constraint.
Other Approaches
An algorithm commonly used for resource allocation in real-time systems
is Banker's algorithm, [Silberschatz and Galvin, 1995]. This algorithm
is discussed in Chapter 9.7.
A Petri net can formally be analyzed with respect to deadlocks, using the
analysis methods described in Appendix B. Petri net analysis of batch
recipes is further treated in Chapter 9.
186
8.6 Distributed Execution
Need Capacity
2
1
b: batch;
r: resource
If b.need <= r.capacity
then
move(b,1);
r.capacity = r.capacity b.need;
move(r,2);
187
Chapter 8. Recipe Structuring using Grafchart
for representing the individual batches, then things become a bit simpler.
It is now possible to store a copy of each master recipe function chart in
each node, and to pass only the object token information together with
information about the current step of an object token, between the nodes.
If the resource allocation should be integrated with the recipe execution
as, e.g., in Figure 8.9 or 8.11, things become more complicated. One possi-
bility is to let one equipment node for each equipment type, be responsible
for the allocation of resources of that type. When a recipe needs to allocate
a resource of a certain type, a request is sent to the resource allocation
node for the equipment type. The batch will wait in the preceding equip-
ment unit until a suitable equipment unit becomes available. Information
about the identity of the new equipment unit is sent back to the equipment
node where the batch is currently waiting, and the transfer to the new
equipment unit can start. A rather elaborate handshaking procedure is
needed to implement this synchronization. Distributed recipe execution of
this nature is available in modern commercial batch control system such
as, e.g., the batch control system in SattLine from Alfa Laval Automation.
188
8.7 Grafchart Structured Recipes vs Industry Practice
cases be space-effective but it can also cause confusion for the user. In
Figure 8.27 a possible sub-sequence of a recipe of a commercial system is
shown. The interpretation of this structure is ambiguous.
Phase A
a
b
c
Phase B
Recipe execution The main and the most important difference is the
token concept in the Grafchart-structured recipes. The fundamental role of
the token is to indicate the step that is currently active. In a commercial-
structured recipe this is indicated by colors. However, as has been shown
in the recipe structures presented earlier in this chapter, the role of the
token can be extended and a token may contain a lot of information. The
same amount of information can not be stored in the colors used in a
commercial-structured system. The fact that a token can contain a lot of
information makes it possible to reduce the size of the representation of
the recipes.
In a recipe of a commercial system, the overall plant status is represented
textually, compare Figure 6.9. The reason for having a textual representa-
189
Chapter 8. Recipe Structuring using Grafchart
Phase A Phase A
a a
b a AND b AND c b
c c
Phase B Phase B
tion is that there does not exist a compact way of representing the status
of all recipes. Using Grafchart and the object token feature, the status of
the plant could easily be represented graphically in a nice way, compare
Figure 8.16. By allowing the token to contain information, the required
logged batch data can be stored in the token in a convenient way.
190
8.8 Other Batch Related Applications of Grafchart
A prototype of the integrated batch plant operation system has been im-
plemented and it has been applied to a simulated batch scenario. Depend-
ing on what kind of activity the user would like to perform, different views
are desirable. The user uses an extended version of the Control Activity
Model of ISA-S88.01 as a navigator metaphor. The integrated batch plant
operation system is implemented in G2.
191
Chapter 8. Recipe Structuring using Grafchart
8.9 Summary
The main application of Grafchart is recipe structuring and resource
management in multi-product, network-structured batch production cells.
Grafchart is well suited for these tasks. By using the features of Graf-
chart in different ways, large variations can be made when structuring
the recipes. They still however, comply with the ISA S88.01 standard. The
simplest way is to represent each control recipe with a Grafchart func-
tion chart with batch specific information represented as attributes of the
function chart. The recipes can also be structured using object tokens.
In this case, control recipes of the same type, move around in the same
chart. Batch specific information is stored within the token. By using the
multi-dimensional structure of Grafchart, the chart in which the tokens
reside can be given a general structure. Tokens of different types, i.e.,
of different master recipes, can now reside in the same chart. The token
contains its own recipe-procedure as a method.
Resource allocation can be made in two ways: implicitly or explicitly. If the
resource allocation is done explicitly, i.e., if each resource is represented
by a token, formal analysis methods can be applied to the net, and prop-
erties like deadlocks can be detected. Resource allocation of exclusive-use
resources and deadlock-analysis have been looked at in other areas, e.g.,
Petri nets, and their results can be useful also for a recipe management
system in the batch control field.
192
9
Recipe Analysis
The main objective when developing Grafchart has been to provide a user-
friendly high-level language for sequential control applications. In doing
so, the work has been inspired by the concepts used in several different
areas, e.g., concepts that are normally used within the context of formal
modeling languages for discrete event systems. Hence, it is easy to get
the conception that Grafchart is also developed with the intention to be a
formal modeling language. This is not the case. However, since Grafchart
is based on Grafcet and Petri nets and since it is possible to transform a
Grafchart into a Grafcet and/or a Petri net, see Chapter 5.8, it is possible
to apply some of the formal methods for, e.g., verification, that have been
developed for Grafcet and Petri nets, also to Grafchart.
There are advantages of having a programming language that mechan-
ically can be transformed to an analyzable format. In this way the con-
troller does not have to be manually modeled before applying the formal
methods, and the risk of introducing errors or inconsistencies is therefore
reduced. This means that the Grafchart implementation can be seen as
an executable controller model. Still, however, the plant that is controlled
by the Grafchart has to be modeled in order for the formal analysis to be
complete.
The aim of this chapter is to show how formal methods for Petri nets can
be used in the context of recipe-based batch control. The methods are used
for deadlock analysis due to improper resource allocation. The approach
is based on transforming the combined Grafchart recipe containing all the
master recipes together with the shared resources into a Petri net. The
size of this Petri net is then reduced and the reachability graph is cal-
culated. By inspecting the reachability graph, deadlock situations can be
found. The reachability graph can also be used to detect situations where
the firing of a transition in a recipe may lead to a deadlock situation. The
analysis results can be used statically to prevent deadlocks from occuring,
or dynamically in order to to avoid deadlocks.
193
Chapter 9. Recipe Analysis
A batch cell similar to the one in Chapter 7.3 is used in this chapter. Two
simplifications are made. The first one concerns the connectivity of the
units in the batch plant. All units in the batch cell are assumed to be fully
connected. This means that it is not necessary for a batch to allocate any
transportation equipment such as pipes, valves or pumps, in order for the
batch to be moved from one unit to another. If this would not have been the
case, the transportation equipment would have to be modeled as resources
that the batch would have to allocate. The second simplification concerns
the units. Units of the same type are all assumed to be equivalent, e.g., it
does not matter which of the mixers that is allocated to a batch if there are
several mixers to choose among. The reason why this assumption is made
is that only a structural analysis is performed. Additional constraints,
expressed through the transition receptivities are not taken into account.
The chapter starts, (Chapter 9.1), with a presentation of the general dead-
lock problem. The consequences that the deadlock problem can have in
a batch cell are discussed. Thereafter two batch recipes are presented
(Chapter 9.2). The recipes are structured with Grafchart and they are as-
sumed to be executed in the same plant. After a general discussion about
the Grafchart to Petri net transformation, the two Grafchart structured
recipes are transformed into Petri nets (Chapter 9.3). The Petri net struc-
tured recipes are analyzed (Chapter 9.4) and different ways of using the
results are presented and discussed. (Chapter 9.5). The chapter also con-
tains a presentation of other analysis approaches, (Chapter 9.7), and a
presentation of the relation between resource allocation and scheduling,
(Chapter 9.8).
The most efficient batch plants are the multi-product, network structured
plants where several batches, of the same or of different types, can be pro-
duced at the same time. The batches share the equipment in the plant.
If the allocation of the equipment is handled improperly a deadlock situ-
ation might occur, e.g., if a batch currently in one unit requires another
unit and if that unit is reserved by another batch that requires the unit
held by the first batch. Analysis can be performed on the recipes in or-
der to look for certain properties, e.g., deadlock situations. The analysis
methods can also be used to look for other properties, e.g., safe, bounded,
home-states, reversible, etc.
Four conditions exist that must be fulfilled for a deadlock situation caused
by improperly handled resource allocation, to occur, [Burns and Wellings,
1996]:
194
9.1 The Deadlock Problem
1. The batches need to share resources that are such that they can only
be used by one batch at a time.
2. Batches exist that are holding a resource while waiting for another
resource.
4. A circular chain of batches exist such that each batch holds resources
which are requested by the next batch in the chain.
195
Chapter 9. Recipe Analysis
Storage
A B C
tanks
An additional mixer,
Mixers to be connected if desired
Reactors
Product
D E F
tanks
196
9.2 Batch Recipes
The batches that can be run in the plant originate from two different
master recipes called recipe-A and recipe-B. Both recipes are structured
with Grafchart (object tokens without methods). Recipe-A is shown in
Figure 9.2 (left). The recipe starts by assigning a mixer to the batch. This
is indicated by the first transition. After the assignment the two reactants
A and B are filled into the mixer, and the mixture is agitated. Thereafter
a reactor is assigned and half of the content in the mixer is transfered to
the reactor. The other half of the batch is left in the mixer. The content in
the reactor is heated and then transfered to another reactor where it is
cooled. Two different reactors, reactorheat and reactorcool, are used for the
heating and the cooling. After the transfer from reactor heat to reactorcool,
reactorheat is no longer needed and it is therefore released. When the
content has been cooled down it is transfered back to the mixer where the
rest of the batch is waiting. Reactorcool is now released. The mixture is
agitated and thereafter discharged. Finally the mixer is released.
MIXER REACTOR REACTOR cool
heat
MIXER REACTOR heat REACTOR cool
Mixer
Mixer
FillA FillB
FillA FillB
Agitate
Agitate
Reactorheat
Reactorcool
Heat
Reactorcool Cool
Reactorheat
Charge
Empty Empty Charge
Reactorheat
Cool Heat
Reactorcool
Agitate Agitate
Discharge Discharge
Figure 9.2 Two Grafchart recipe structures: recipe-A (left) and recipe-B (right).
Recipe-B is shown in Figure 9.2 (right). This batch mixes two reactants
in a mixer, and then transfers half of the content to a reactor for cooling.
197
Chapter 9. Recipe Analysis
When the cooling is ready, the other half of the batch is transfered from
the mixer to a reactor for heating. Finally the content of the two reactors
are transfered back to the mixer for final agitation and discharging.
Since batches of the two recipes are produced in the same plant and there-
fore utilize the same units, they will effect each other. The two recipes can
be combined into one Grafchart where the resource allocation is visual-
ized, compare Chapter 8.2 (Combined Network). This is shown in Fig-
ure 9.3. The number of tokens placed in the initial step in each of the
recipes corresponds to the aim of producing the same number of batches.
Agitate Agitate
ReactorHeat
Heat Cool
Cool Heat
Empty Charge
Charge Empty Empty
Agitate
Agitate
Discharge
Discharge
Both recipes are structured with phases. According to the ISA S88 batch
standard, a phase must always execute within the same unit, see Chap-
ter 6.2 (Procedural Control).
Remark: The batch cell as well as the two recipes are not based on a
real scenario but have been made up in order to illustrate the analysis
concepts as clearly as possible.
198
9.3 Batch Recipe Transformation
Deadlock- ? Deadlock
free
? ?
Deadlock-
Deadlock ? free
199
Chapter 9. Recipe Analysis
x1 alternative branch p1
alternative
branch
t1 t2 t1 t2
x2 x3 p2 p3
parallel branch parallel
t4 t4 branch
t3
p4 p5
x4 x5
t5
t3 t5
Receptivities and actions: An autonomous Petri net does not have any
receptivities associated with the transitions. A Grafchart receptivity can
either cause or prevent a deadlock situation.
false
200
9.3 Batch Recipe Transformation
false
Not deadlockfree
deadlockfree
A Petri net does not have any actions associated with the places. A Graf-
chart action can cause a deadlock situation to occur. An example of this
is given in Figure 9.8. The Grafchart structure in the figure contains two
steps and one transition. The action associated with the first step sets
the transition receptivity to false which means that the transition never
can fire and a deadlock situation has therefore occurred. A correspond-
ing Petri net would not contain the action nor the receptivity and could
therefore not result in the deadlock situation.
201
Chapter 9. Recipe Analysis
As has been shown, actions and receptivities might cause deadlock sit-
uations to occur. These situations cannot be found by analyzing the cor-
responding Petri net. Action and receptivities can also prevent deadlock
situation from occuring. In these cases the corresponding Petri net will
not always be deadlock-free.
Dynamical behavior: The dynamical behavior of a Grafchart and a Petri
net differs with respect to the firing instance of a transition. In Grafchart
an enabled transition fires immediately whereas the firing instance of an
enabled transition in a Petri net is not uniquely given. However, this does
not influence the reachability graph and is therefore of no importance for
the analysis results.
Remark As has been shown it is only the topology, i.e., the graphical
structure, of a Grafchart that can be analyzed. Influences from step ac-
tions and transition receptivities can not be taken into account.
4. The actions are neglected since the influence of an action not can be
analyzed.
5. The receptivities are neglected since the influence of a receptivity
not can be analyzed.
10. Parameterization of receptivities are of no importance because of
(5).
Using the transformation rules, the recipe structure of Figure 9.3 can
be transformed into a Petri net. The corresponding Petri net is shown
in Figure 9.9. Recipe-A is placed to the left in the figure and Recipe-
B to the right. In addition to the transformation rules, the fact that a
phase always executes within the same equipment (no resource allocation
or deallocation allowed), is used. This implies that each procedure step,
corresponding to a phase, can be replaced by one single Petri net place, i.e.,
the procedure step does not have to be replaced by the internal structure
of the corresponding Grafchart procedure.
The Petri net structure shown in Figure 9.9 has two initial places, one
in each recipe. In each initial place one token is placed. If the dotted
202
9.3 Batch Recipe Transformation
transition and dotted arc that closes the loop are disregarded, the tokens
indicate that one batch of each type should be produced. If, however, the
Petri net structure is closed, i.e., if the dotted transition and arc are taken
into account, the tokens placed in the initial-places instead indicate that
at most one batch of each type should be produced at the same time in
the plant. When a batch of, e.g., type A, has been produced, the token can
be returned to the initial place and the production of a new batch of this
type is allowed to start.
Mixer
Reactor_heat
Reactor_cool
Figure 9.9 A Petri net recipe structure corresponding to the combined Grafchart
recipe in Figure 9.3.
The two transformed recipes in Figure 9.9 can now be reduced according
to the reduction rules presented in Appendix B, see Figure 9.10. The
transformed recipe on the left side in the figure corresponds to Recipe-A
and the transformed recipe on the right side corresponds to Recipe-B. The
Petri net structure can be open or closed.
203
Chapter 9. Recipe Analysis
P1 Mixer P5
P9 T4
T1
P2 P6
Reactor_heat
T2 P10 T5
P3 P7
T3 P11 T6
Reactor_cool P8
P4
Figure 9.10 The reduced Petri net recipe structure for to the Petri net recipe
structure in Figure 9.9.
9.4 Analysis
If only one batch of each type should be produced, the system cannot get
into a deadlock situation. This can be shown by drawing the reachability
graph, see Figure 9.11. The dotted lines correspond to the return of the
0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
0 0 1 1 1
1 1 1 0 0
0
T2 0
T3 0
T4 1
T5 0
0 0 0 0 1
1 T1 0 0 0 0 0 T6 0
0 0 0 1 0 0 0
0 1 0 1 1 1 0
0 1 1 1 1 0 1
1 0
0 0
0 0
0 1 1 1 0 0
0 0 0 1 0 1
1 1
1 T4 0 0 0 0 1 T3
0 0 0 0 0 1
1 1
0 0 0 0 0
1 0 0 0 0
0 T5 1 T6 0 T1 0 T2 0
0 0 1 1 1
0 0 1 0 0
1 1 1 1 0
1 0 1 1 1
204
9.4 Analysis
token to the initial place. As can be seen, these lines do only loop back to
already existing states and they can therefore not lead to a new deadlock
situation. In the sequel of this chapter, these lines are left out in all
reachability graphs.
What if we add an extra resource to the plant, e.g., connect the additional
mixer that we have in the plant, see Figure 9.1? The intuitive reaction is
that adding an extra resource cannot lead to a deadlock since deadlocks
occur when there are to few resources. Thus, adding an extra resource
cannot cause the system to get into a deadlock situation. However, by
drawing the reachability graph one can show that this is not true. This
means that informal arguments about behavioral properties are danger-
ous, [Jensen, 1992]. The reachability graph, corresponding to Figure 9.10,
using two mixers, is shown in Figure 9.12.
0
0
0
1
1
0
T3 0 T4
0 0 0
0 2 0
1 1 0
0 1 1
1 0
0 1
T2 0 T4 0 0 T5
0 T3 0
0 0 0
1 1 1 1 0
0 0 0 1 0
0 1 0 1 1
1 1 0
0 0 0
1 0 T4 0 0 T5 0 1 T6 0
T1 1 T2 0 0 0
0 0 0
0
DEADLOCK
0 1 0 1 1 0
0 1 0 1 0 1 1
1 1 0 0 0 0
0 1 0 0
0 0
0 1 1 0
0 0 T5 0 T2 0 0 1
1 T1 0
2 0 0 2
0 1 0
0 1
T3
1 T4 0 0 1
1 1 0 0 1
0 0
0 1 0
1 0 0
0 1 0 T6 0 0
0 1 1
0 T1 1
1 0 0 0 T2 1
0 0 0
1 T5 0 0 1
1 1
0 0
1 0 0
0 0 1
1 0 1
1 T6 0 T1 1
0 0 1
0
1
2
1
1
205
Chapter 9. Recipe Analysis
The deadlock situation that arises when a second mixer is added to the
plant can intuitively be understood by examining Figure 9.10. The two
recipes use reactorheat and reactorcool in reversed order, this means that if
a deadlock situation should occur, it is due to this. When there is only one
mixer in the plant, the mixer assures that a second batch cannot start
until the first batch has finished, and a deadlock situation can therefore
not occur.
Situations where the resource has to fulfill certain constraints, e.g., a
minimum value or a high temperature tolerance, can be implemented
by using the transition conditions in Grafchart-HLV. Examples of this
are given in Chapter 8.5 (Shared Resources). Since the analysis methods
presented do not take the receptivities into account, the specific demands
that a batch can have on a resource are not considered. To solve this
problem, resources with different capacity must reside in different steps.
A drawback with the reachability graph method is that the complexity in-
creases rapidly when the size of the net increases. However, this drawback
is also present in most formal analysis methods for this type of problems.
206
9.5 Using the Analysis Results
2* Recipe-A
+ -- ok ok -- -- ok
2* Recipe-B
2* Recipe-A
+ ok ok ok -- -- ok
1 Recipe-B
1 Recipe-A
+
2* Recipe-B
-- ok ok -- -- ok
1 Recipe-A
+
1 Recipe-B ok ok ok -- -- ok
3M+1Rh+2Rc
2M+1Rh+2Rc
1M+1Rh+2Rc
3M+1Rh+1Rc
2M+1Rh+1Rc
1M+1Rh+1Rc
Figure 9.13 A table showing the possibility of deadlock for different recipes in
different plant configurations, ok deadlock not possible, deadlock possible.
The table can be used as a help when determining how to prevent dead-
lock situations from occurring in a batch plant. According to the table
in Figure 9.13 two batches, one of type A and one of type B, can be run
in the same plant simultaneously with no risk of entering a deadlock
situation if the plant consists of one, two or three mixers together with
one reactorheat and two reactorcool or if the plant consists of one mixer, one
reactorheat and one reactorcool. These combinations of batches versus plant
configurations can be run without any deadlock considerations. However,
if the plant consists of two or three mixers together with one reactorheat
207
Chapter 9. Recipe Analysis
208
9.5 Using the Analysis Results
0
0
0
1
1
0
T3 0 T4
0 0 0
0 2 0
1 1 0
0 1 1
1 0
0 1
T2 0 T4 0 0 T5
0 T3 0
0 0 0
1 1 1 1 0
0 0 0 1 0
0 1 0 1 1
1 1 0
0 0 0
1 0 T4 0 0 T5 0 1 T6 0
T1 1 T2 0 0 0
0 0 0
0
DEADLOCK
0 1 0 1 1 0
0 1 0 1 0 1 1
1 1 0 0 0 0
0 1 0 0
0 0
0 1 1 0
0 0 T5 T2 0 0 1
1 0
2 T1 0 0 0 2
0 1 0
0 1
T3
1 T4 0 0 1
1 1 0 0 1
0 0
0 1 0
1 0 0
0 1 0 0 0
0 T1 T6 1 1
0 1
1 0 0 0 T2 1
0 0 0
1 T5 0 0 1
1 1
0 0
1 0 0
0 0 1
1 0 1
1 T6 0
T1 1
0 0 1
0
1
2
1
1
209
Chapter 9. Recipe Analysis
require that the batch will have to wait for transition T3 to fire. In order
to guarantee that such a wait does not occur, the state represented by
the marking [00100100001]T should be considered a forbidden state and
to avoid arriving in this state, the firing of the two transitions T4 and T2,
leading to this state, must be excluded. From marking [01000100011]T it
is only possible to fire transition T5 since transition T2 has been excluded.
From marking [10000100111]T it is possible to fire transition T5 either
directly or to fire transition T1 and then transition T5. The reachability
graph with the necessary transitions excluded, i.e., the reachability graph
that fulfills the requirement, is shown in Figure 9.15 (right).
0 0
0 0
0 0
1 1
1 1
0 0
T3 0 T4 T3 0 T4
0 0 0 0 0 0
0 2 0 0 2 0
1 1 0 1 1 0
0 1 1 0 1 1
1 0 1 0
0 1 0 1
T2 0 T4 0
T3 0 T5 0 T2 0 T4
0
T3 0 T5 0
0 0 0 0 0 0 0 0
1 1 1 1 0 1 1 1 1 0
0 0 0 1 0 0 0 0 1 0
0 1 0 1 1 0 1 0 1 1
1 1 0 1 1 0
0 0 0 0 0 0
1 0 T4 0 0 T5 0 1 T6 0 1 0 T4 0 T2 0 T5 0 1 T6 0
0
T1 0 1 T2 0 0 0 0 0
T1 0 1 0 0 0 0
0
DEADLOCK
DEADLOCK
0 1 0 1 1 0 0 1 0 1 1 0
0 1 0 1 0 1 1 0 1 0 1 0 1 1
1 1 0 0 0 0 1 1 0 0 0 0
0 1 0 0 0 1 0 0
0 0 0 0
0 1 1 0 0 1 1 0
0 0 T5 T2 0 0 1 0 0 T5 T2 0 0 1
1 0 1 0
2 0
T1 0
0 0 0
T3 2 2 0
T1 0
0 0 0
T3 2
1 1 0 1 1 1 1 0 1 1
T4 0 1 0
0
T4 0 1 0
0 0
1 0 0 0 1 1 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
0 1 0 T6 0 0 0 1 0 T6 0 0
0 1 1 0 1 1
0
0
T1 1
0 T2 1
0
0
T1 1
0 T2 1
1 0 1 0
0 0 0 0 0 0
1 T5 0 0 1
1 T5 0 0 1
1 1 1 1
0 0 0 0
1 0 0 1 0 0
0 0 1 0 0 1
1 0 1 1 0 1
1 T6 0 T1 1 1 T6 0 T1 1
0 0 1 0 0 1
0 0
1 1
2 2
1 1
1 1
Supervisor
The results from the forbidden state analysis can be implemented by a
supervisor using the supervisory control theory (SCT) of Wonham and
Ramadge, [Ramadge and Wonham, 1989]. The theory can be formulated
both in terms of automata and formal languages. A modified version of
SCT has been developed by Charbonnier and Alla, [Charbonnier, 1996].
The modified version is based on Grafcet and makes a clear distinction
between the controller and the supervisor. Yet an alternative approach,
called Procedural Control Theory (PCT), has been developed at Imperial
College, [Alsop et al., 1996].
210
9.5 Using the Analysis Results
Supervisor
Plant
SCT can be used for both verification and synthesis. The verification ap-
proach consists of modeling the open system, i.e., the process, and con-
structing a supervisor manually. Both the open system and the supervisor
are modeled in terms of a formal language. The language of the closed
loop system, i.e., the process together with the supervisor, is then formed.
Finally, it is checked if the closed loop language is controllable. If so, the
user knows that the supervisor guarantees that the process never enters
certain undesired states. What remains for the user to do is to implement
the supervisor.
The synthesis approach consists of modeling the open system, i.e., the
process, and specifying the desired closed loop behavior. The open system
and the closed loop system are both defined in terms of a formal language.
The controllability of the closed loop language is checked and a supervisor
is generated automatically. The supervisor is given in terms of a formal
language. What remains for the user to do is to implement the supervisor.
The verification approach is more common than the synthesis approach. A
major reason for this is the difficulties involved with specifying the closed
loop system completely for users without training in formal languages.
SCT has received a lot of criticism:
211
Chapter 9. Recipe Analysis
SCT has been used for batch applications, [Tittus, 1995] and [kesson and
Tittus, 1998], see Chapter 9.7.
pr
co
Controller Process
extended process
As can be seen, the controller and the supervisor are separated. Also in
the design procedure, the two parts are designed independently from one
212
9.6 Grafchart Supervisor
The events taking place in a batch plant need to be controlled and su-
pervised. The plant can be controlled by a Grafchart controller, i.e., by
a recipe. The plant also needs to be supervised, this can be done by a
Grafchart supervisor.
The task of the supervisor is to assure that the system never reaches a
forbidden state, i.e., to assure that certain transitions in the recipe not
are fired. The transitions that should not be fired vary with the state of
the system. A plant controlled by a Grafchart controller (recipe) and su-
pervised by a supervisor is shown in Figure 9.18. The supervisor receives
enable/disable
controllable events Grafchart generated events
Supervisor
Grafchart pl
co
recipe Plant
controller
213
Chapter 9. Recipe Analysis
214
9.6 Grafchart Supervisor
initially
conclude that OKT1, OKT2, OKT3 = true
conclude that OKT4, OKT5, OKT6 = true
T4 T1
T5 T1 T4 T2
T6 T1 T5 T2 T4 T3
Initially Initially
conclude that conclude that
OKT2 = false OKT5 = false
T1 T6 T3 T4
Initially Initially
conclude that OKT2=true conclude that OKT5=true
T2 T5
T3 T6
215
Chapter 9. Recipe Analysis
p1 Mixer
Mixer
t1 P1 Mixer
t2 P2
Reactor
Agitate p4 Reactor T2 = t3...
Reactor
t3
p5
1 0
T1, a transition
0 T1 1 T2
event mixer_agitate T1 * *
condition * *
T2
Figure 9.20 The train of thought for finding out the transition receptivities in a
supervisor.
The forbidden state method can be used to find the states that should be
avoided and the transitions that should be disabled in order to prevent
a deadlock from occuring. It can, however, also be used to assure other
scenarios, e.g., that a unit is always available for allocation after a certain
216
9.6 Grafchart Supervisor
MIXER REACTOR REACTOR cool
heat MIXER REACTOR heat REACTOR cool
Mixer
t1 Mixer
t11
FillA FillB
FillA FillB
t2
t12
Agitate
Agitate
Reactorheat Reactorcool
t3
t13
t4
t14
Heat
Reactorcool Cool
t5 Reactorheat
t15
Charge
Empty Empty Charge
t6
Reactorheat t16
Cool Heat
t7
t17
t1, a transition t3, a transition t5, a transition t11, a transition t13, a transition t15, a transition
event event event event event event
condition OKT1 condition OKT2 condition OKT3 condition OKT4 condition OKT4 condition OKT5
Figure 9.21 Two Grafchart recipe structures susceptible for events generated by
a supervisor: recipe-A (left) and recipe-B (right).
217
Chapter 9. Recipe Analysis
initially
conclude that OKT1, OKT2, OKT3 = true
conclude that OKT4, OKT5, OKT6 = true
T4 T1
T5 T1 T4 T2
Initially Initially
conclude that conclude that
OKT2 = false OKT4 = false
T6 T1 T5 T3
Initially
conclude that
OKT4 = true
T1 T6 T4
Initially
conclude that
OKT2 = true
T2 T5
T3 T6
Consider once again the plant consisting of two mixers, one reactorheat and
one reactorcool. In the plant two batches, one of type A and one of type B,
218
9.6 Grafchart Supervisor
0
0
0
1
1
0
T3 0 T4
0 0 0
0 2 0
1 1 0
0 1 1
1 0
0 1
T2 0 T4 0 0 T5
0 T3 0
0 0 0
1 1 1 1 0
0 0 0 1 0
State A
0 1 0 1 1
1 1 0
0 0 0
1 0 T4 0 0 T5 0 1 T6 0
T1 1 T2 0 0 0
0 0 0
0
DEADLOCK
0 1 0 1 1 0
0 1 0 1 0 1 1
1 1 0 0 0 0
0 1 0 0
0 0
0 1 1 0
0 0 T5 0 T2 0 0 1
1 T1 0
2 0 0 2
0 1 0
0 1
T3
1 T4 0 0 1
State B
1 1 0 0 1
0 0
0 1 0
1 0 0
0 1 0 T6 0 0
0 1 1
0 T1 1
1 0 0 0 T2 1
0 0 0
1 T5 0 0 1
1 1
0 0
1 0 0
0 0 1
1 0 1
1 T6 0 T1 1
0 0 1
0
1
2
1
1
The reachability graph based supervisor, see Figure 9.19, contained fifteen
states. The structure of the supervisor can be reduced so that it contains
only four states. The reduced supervisor is shown in Figure 9.24.
In this supervisor, it is assumed that the two states named stateA and
stateB can be detected. By using the same type of reasoning as presented
219
Chapter 9. Recipe Analysis
T1 T2
Initially Initially
conclude that conclude that
OKT5 = false OKT2 = false
T3 T4
T5
in Figure 9.20 the real states that correspond to the two states in the
reachability graph can be deduced, see the following table:
Reachability graph state Real state
heat
220
9.7 Other Analysis Approaches
StateA corresponds to the six upper rows in the previous table and stateB
corresponds to the six lower rows. The receptivities in the reduced su-
pervisor can now be rewritten using these conditions. The receptivity of
transition T1 is shown in Figure 9.25.
T1, a transition
Event
Condition ((recipeA mixer_empty AND recipeA reactorheat _charge)
OR recipeA reactor heat _heat)
AND
((recipeB mixer_fillA AND recipeB mixer_fillB)
OR recipeB mixer_agitate)
Bankers Algorithm
An algorithm commonly used for resource allocation in real-time systems
is Banker's algorithm. The algorithm is used for deadlock-avoidance,
[Silberschatz and Galvin, 1995]. When a new process enters the system it
must declare the maximum number of instances of each resource type that
221
Chapter 9. Recipe Analysis
it might need. This number may not exceed the total number of resources
in the system. When a process requests a set of resources, the system
must determine whether the allocation of these resources will leave the
system in a safe state. If so, the resources are allocated, otherwise, the
process must wait until some other process releases enough resources.
Ideas from this algorithm might be useful for a deadlock-detection system
within a recipe management system.
222
9.7 Other Analysis Approaches
Plant
T Specification S
Supervisor
The T -module removes the circular wait between resources in the trans-
porting system by ordering all transport devices and guaranteeing that
all transport devices in a connection line are booked in this order. The
booking order is specified by a Petri net. This Petri net is synchronized
with the recipes, i.e., transitions with the same label acts as if they were
the same transition (i.e. they all fire simultaneously, but only if the input
places in all Petri nets can be fired). By assuring that no circular wait
can occur, the T -module is deadlock free, and a deadlock can therefore
not occur within the transporting system.
223
Chapter 9. Recipe Analysis
9.9 Summary
A recipe structured with Grafchart can be transformed into a correspond-
ing Petri net to which already existing Petri net analysis methods can be
applied. Using, e.g., the reduction techniques and the reachability graphs,
characteristics like deadlock-freeness can be investigated. As shown in
this chapter it is only the topology of the Grafchart structured recipe
that can be analyzed, influences of step actions or transition receptivities
cannot be included in the analysis. The results of the deadlock analysis
can be used in different ways. Static reasoning deals with the question of
which combinations of number of batches and number of units that can be
safely started in the plant at the same time. The answer to this question
can, e.g., be stored in a table. Dynamic reasoning is about determining,
depending on the status of the plant, which units that are unsafe to al-
locate and therefore not should be reserved by a batch, i.e., to find the
unsafe states. To assure that the system never reaches an unsafe state
a supervisor can be used. In the chapter it is shown how the supervisor
can be constructed from the reachability graph and how the size of the
supervisor can be reduced.
224
10
Conclusions
225
Chapter 10. Conclusions
use Grafchart not only for simple local level control applications, but also
for more demanding applications on the supervisory control level. Since
Grafchart is based on Grafcet and Petri nets, it is possible to transform a
Grafchart program into a Petri net and/or a Grafcet. Hence, it is possible
to apply the formal analysis methods developed for Petri nets and Grafcet
also to Grafchart.
Grafchart is a general-purpose language that has been used in several
different application. The topic of this thesis is recipe-based batch con-
trol. In the thesis it has been shown how Grafchart can be used for recipe
structuring and recipe analysis. By using the features of Grafchart in
various ways, recipes can be given different structures with different ad-
vantages and disadvantages. All structures comply with the international
batch standard IEC 61512-1 (also refered to as ISA S88.01). To test and
evaluate the different recipe structures a real-time simulation model of a
batch cell was used. The different features introduced in Grafchart have
many advantages in the context of recipe-based batch control.
Several commercial batch control systems exist today. They all have a
similar approach to recipe structuring, resource allocation and user pre-
sentation. The advantages of using Grafchart compared to some of these
systems, regarding these features are presented in the thesis. Grafchart
allows, e.g., the operator to have a graphical view of the overall status
in the plant as well as of the resource allocation. Analysis of the recipes
can be performed in order to look for possible deadlock situations caused
by improper resource allocation. By using Grafchart it is also possible to
implement all layers in the recipe procedure using the same language.
226
10.1 Future Research Directions
Implementation Improvements
The G2 implementation of Grafchart can still be viewed as a prototype.
Several modifications are possible. It would be relatively easy to change
the local interpretation algorithm into a global algorithm. With this mod-
ification the semantics of Grafchart would become closer to the Grafcet
semantics. The syntax for step actions and receptivities needs improve-
ments. New language elements could be considered. The main hierarchi-
cal construct of Grafchart, the macro step, is very procedural in nature. A
macro step may only have one entry point, i.e., one enter step. A result of
this is that it becomes cumbersome to represent truly hierarchical steps
with multiple entry points. This is often practical to have when Grafchart
is used for representing state machines. A possibility would be to define
a new super step that may have multiple entry and exit points, similar
to the super state of Statecharts.
227
Chapter 10. Conclusions
Batch Scheduling
The current recipe management system performs dynamic resource al-
location. By applying analysis methods one can find out when and why
deadlock situations can occur. Statical deadlock prevention or dynamical
deadlock avoidance can be used in order not to get caught in an unde-
sired deadlock situation. However, the task of allocating the resources in
an optimal way, most often with respect to time, is not considered. This
task should instead be assured by a scheduling algorithm.
228
10.1 Future Research Directions
to represent the recipe procedures, the equipment control logic, and the
equipment monitoring system.
229
11
Bibliography
230
RZN, K.-E. and C. JOHNSSON (1996b): Object-oriented SFC and ISA-
S88.01 recipes. ISA Transactions, 35, pp. 237244.
RZN, K.-E. and C. JOHNSSON (1997): Grafchart: a Petri net/Grafcet
based graphical language for real-time sequential control applica-
tions. In SNART97The Swedish National Real-Time Systems Con-
ference, Lund.
BASTIDE, R., C. SIBERTIN-BLANC, and P. PALANQUE (1993): Cooperative
Objects: A concurrent, Petri-net based, object-oriented language. In
Proceeding of IEEE Conference on Systems, Man and Cybernetics. Le
Touquet, France.
BATTISTON, E., F. DE CINDIO, and G. MAURI (1988): OBJSA: A class of high
level nets having objects as domains. In ROZENBERG, Ed., Advances in
Petri Nets 1988, vol. 340 of Lecture notes in computer science, pp. 20
43. Springer Verlag, Berlin Heidelberg, New York.
BERTHELOT, G. (1983): Transformation et analyse de rseaux de Petri:
Application aux protocoles. PhD thesis, Nice University.
BERTHELOT, G. (1986): Checking properties of nets using transforma-
tions. In Lecture notes in Computer Science, vol. 222, pp. 19 40.
Springer Verlag.
BRETTSCHMEIDER, H., H. GENRICH, and H. HANISCH (1996): Verification
and performance analysis of recipe based controllers by means of dy-
namic plant models. In Second International Conference on Computer
Integrated Manufacturing in the Process Industries. Eindhoven, The
Netherlands.
BURNS, A. and A. WELLINGS (1996): Real-time systems and programming
languages. Addison-Wesley.
CASSANDRAS, C. (1993): Discrete Event Systems: Modeling and Perfor-
mance Analysis. Irwin.
CHARBONNIER, F. (1996): Commande supervise des systmes vne-
ments discrets. PhD thesis, Institut National Polytechnique de Greno-
ble.
CHARBONNIER, F., H. ALLA, and R. DAVID (1995): The supervised control of
discrete event dynamic systems: A new approach. In 34th Conference
on Decision and Control. New Orleans.
DAVID, R. (1995): Grafcet: A powerful tool for specification of logic
controllers. IEEE Transactions on Control Systems Technology, 3:3,
pp. 253268.
231
Chapter 11. Bibliography
DAVID, R. and H. ALLA (1992): Petri nets and Grafcet: Tools for modelling
discrete events systems. Prentice-Hall International (UK) Ltd.
DE LOOR, P., J. ZAYTOON, and G. VILLERMAIN-LECOLIER (1997): Abstrac-
tions and heuristics for the validation of Grafcet controlled system.
JESA European Journal of Automation, 31:3, pp. 561580.
DESROCHERS, A. A. and R. ALJAAR (1995): Applications of Petri nets in
manufacturing systems: Modelling, control and performance analysis.
IEEE Press.
DIJKSTRA, E. (1968): Cooperating sequential processes. In GENUYS, Ed.,
Programming languages. Academic Press N.Y.
ENGELL, S. and K. WLLHAF (1994): Dynamic simulation for improved
operation of flexible batch plants. In Proc. CIMPRO 94, pp. 441455.
Rutgers University, New Jersey, USA.
FISHER, T. G. (1990): Batch Control Systems: Design, Application, and
Implementation. Instrument Society of America, Research Park, NC.
FLEISCHHACK, H. and U. LICHTBLAU (1993): MOBY - A tool for high level
Petri nets with objects. In Proceeding of IEEE Conference on Systems,
Man and Cybernetics. Le Touquet, France.
GAFFE, D. (1996): Le modle Grafcet: Rflextion et intgration dans une
plate-forme multiformalisme synchrone. PhD thesis, Universit de
Nice-Sophia Antipolis.
GENRICH, H. J., H.-M. HANISCH, and K. WLLHAF (1994): Verification of
recipe-based control procedures by means of predicate/transition nets.
In 15th International Conference on Application and Theory of Petri
nets, Zaragoza, Spain.
GENSYM COORPORATION (1995): G2 Reference Manual, Version 4.0. Gen-
sym Coorporation, 125 Cambridge Park Drive, Cambridge, MA 02140,
USA.
GUNNARSSON, J. (1997): Symbolic Methods and Tools for Discrete Event
Dynamic Systems. PhD thesis, Linkping University.
HANISCH, H.-M. and S. FLECK (1996): A resource allocation scheme for
flexible batch plants based on high-level Petri nets. In IEEE SMC,
CESA96. Lille, France.
HARPER, R. (1986): Introduction to standard ML. Technical Report. Dept.
of Computer Science, University of Edinburgh. ECS-LFCS-86-14.
HO, Y. (1991): Discrete Event Dynamic Systems: Analyzing Complexity
and Performance in the Modern World. IEEE Press, New York.
232
HOLLOWAY, L. and B. KROGH (1990): Synthesis of feedback control logic
for a class of controlled Petri nets. IEEE Transactions on Automatic
Control, 35:5, pp. 514523.
HOLLOWAY, L. and B. KROGH (1994): Controlled Petri nets: A tutorial sur-
vey. In 11th International Conference on Analysis and Optimization
of Systems - Discrete Event Systems. Springer-Verlag. number 199
in Lecture Notes in Control and Information Science, pages 158-168,
DES94, Ecole des Mines de Paris, INRIA.
IEC (1988): IEC 60848: Preparation of function charts for control
systems. Technical Report. International Electrotechnical Commissio.
IEC (1993): IEC 61131 programmable controllers - part 3: Programming
languages. Technical Report. International Electrotechnical Commis-
sion.
IEC (1997): IEC 61512-1: Batch control, part1, models and termonology.
Technical Report. International Electrotechnical Commission.
ISA (1995): ISA S88.01 batch control. Instrument Society of America.
JENSEN, K. (1981): Coloured Petri Nets and the invariant method.
Theoretical Computer Science, North-Holland, 14, pp. 317336.
JENSEN, K. (1990): Coloured Petri nets: A high level language for system
design and analysis. In ROZENBERG, Ed., Advances in Petri Nets 1990,
vol. 483 of Lecture notes in Computer Science, pp. 342416. Springer
Verlag, Berlin Heidelberg, New York.
JENSEN, K. (1992): Coloured Petri Nets. Basic Concepts, Analysis Methods
and Practical Use., vol. 1, Basic Concepts. Springer-Verlag.
JENSEN, K. (1995): Coloured Petri Nets. Basic Concepts, Analysis Methods
and Practical Use., vol. 2, Analysis Methods. Springer-Verlag.
JENSEN, K. (1997): Coloured Petri Nets. Basic Concepts, Analysis Methods
and Practical Use., vol. 3, Practical Use. Springer-Verlag.
JENSEN, K. and G. ROZENBERG (1991): High-level Petri Nets. Springer
Verlag.
JOHNSSON, C. (1997): Recipe-Based Batch Control Using High-
Level Grafchart. Licentiate thesis ISRN LUTFD2/TFRT--
3217--SE. Dept. of Automatic Control, Sweden. Available at
http:://www.control.lth.se/ lotta/papers.html.
JOHNSSON, C. and K.-E. RZN (1994): High-level Grafcet and batch
control. In Symposium ADPM94Automation of Mixed Processes:
Dynamical Hybrid Systems. Brussels, Belgium.
233
Chapter 11. Bibliography
JOHNSSON, C. and K.-E. RZN (1998g): Petri net analysis of batch recipes
structured with Grafchart. In FOCAPO98Foundations of Computer
Aided Process Operations.
JOHNSSON, C. and K.-E. RZN (1999a): Grafchart and batch recipe
structures. In Interphex99. New York, NY, USA.
234
LAKOS, C. and C. KEEN (1994): Loopn++: A new language for object-
oriented Petri nets. Technical Report R94-4. Dept. of Computer
Science, University of Tasmania.
LOPEZ GONZLEZ, J. M., J. I. LLORENTE GONZLEZ, J. M. SANTAMARIA
YUGUEROS, O. PEREDA MARTINEZ, and E. ALVAREZ DE LOS MOZOS (1994):
Graphical methods for flexible machining cell control using G2. In
Proc. of the Gensym European User Society Meeting, Edinburgh,
October.
MEALY, G. (1955): A method for synthesizing sequential circuits. Bell
System Technical Journal, 5:34, pp. 10451079.
META SOFTWARE CORPORATION, Cambridge, MA,USA (1993): Design/CPN
Tutorial for X-Windows. version 2.0.
MOALLA, M. (1985): Rseaux de Petri interprts et Grafcet. Technique
et Science Informatique, 14:1.
MOLLOY, M. (1982): Performance analysis using stochastic Petri nets.
IEEE Trans. Computers, C-31:9, pp. 913917.
MOORE, E. (1956): Gedanken experiments on sequential machines.
Automata Studies, pp. 129153. Princeton University Press.
MURATA (1989): Petri nets: Properties, analysis and applications. Pro-
ceedings of the IEEE, 77:4, pp. 541 580.
MURATA, T. and J. KOH (1980): Reduction and expansion of live and safe
marked graphs. IEEE Transactions on Circuit Systems, 27:1, pp. 68
70.
MURATA, T., N. KOMODA, K. MATSUMOTO, and K. HARUNA (1986): A Petri
net-based controller for flexible and maintainable sequence control
and its application in factory automation. IEEE Transaction Ind.
Electron., 33:1, pp. 18.
NAMUR (1992): NAMUR-Emphehlung: Anforderungen an Systeme zur
Rezeptfaheweise (Requirements for Batch Control Systems). NAMUR
AK 2.3 Funktionen der Betriebs- und Produktionsleitebene.
NILSSON, B. (1991): En on-linesimulator fr operatrsstd, (An on-line
simulator for operator support). Report TFRT-3209. Department of
Automatic Control, Lund Institute of Technology.
OZSU, M. (1985): Modelling and analysis of distributed database concur-
rency control algorithms using an extended Petri net formalism. IEEE
Transaction Software Engineering, SE-11:10, pp. 12251240.
235
Chapter 11. Bibliography
236
SIMENSEN, J., C. JOHNSSON, and K.-E. RZN (1997a): A multiple-view
batch plant information model. In PSE97/ESCAPE-7. Trondheim,
Norway.
SIMENSEN, J., C. JOHNSSON, and K.-E. RZN (1997b): A multiple-view
batch plant information model. Computers and Chemical Engineer-
ing, 21:1001, pp. 1209 1214.
SONNENSCHEIN, M. (1993): An introduction to Gina. In Proceding of
IEEE Conference on Systems, Man and Cybernetics. Le Touquet,
France.
SUAU, D. (1989): Grafcet color: Conception et realisation dun outil de
generation de simulation et de commande temps rel. PhD thesis,
Universite de Monpellier.
TITTUS, M. (1995): Control Synthesis for Batch Processes. PhD thesis,
Chalmers University of Technology.
TURBAK, F., D. GIFFORD, and B. REISTAD (1995): Applied semantics of
programming languages.. Unpublished Draft.
VALETTE, R., M. COURVOISIER, J. BEGOU, and J. ALBUKERQUE (1983): Petri
net based programmable logic controllers. In 1st Int. IFIP conference:
Comp. appl. in production and engineering, pp. 103116.
VISWANATHAN, S., C. JOHNSSON, R. SRINIVASAN, V. VENKATASUBRAMANIAN,
and K.-E. RZN (1998a): Automating operating procedure synthesis
for batch processes: Part 1. Knowledge representation and planning
framework. Computers and Chemical Engineering, 22:11, pp. 1673
1685.
VISWANATHAN, S., C. JOHNSSON, R. SRINIVASAN, V. VENKATASUBRAMANIAN,
and K.-E. RZN (1998b): Automating operating procedure synthesis
for batch processes: Part 2. Implementation and application. Comput-
ers and Chemical Engineering, 22:11, pp. 1687 1698.
VISWANATHAN, S., V. VENKATASUBRAMANIAN, C. JOHNSSON, and K.-E. RZN
(1996): Knowledge representation and planning strategies for batch
plant operating procedure synthesis. In AIChE annual meeting,
Chicago, USA.
WILLIAMS, T. (1988): A reference model for Computer Integrated Man-
ufacturing (CIM). In International Purdue Workshop on Industrial
Computer Systems, ISA.
YAMALIDOU, E. C. and J. C. KANTOR (1991): Modeling and optimal control
of discrete-event chemical processes using Petri nets. Computers
Chem. Engng, 15, pp. 503519.
237
Chapter 11. Bibliography
238
A
Abbreviations
239
B
Petri Net Reduction Methods
Four reduction rules exist that preserve the properties: live, bounded,
safe, deadlock-free, with home state and conservative, [Murata and Koh,
1980].
240
Figure B.1 shows a simple case of place substitution. It is clear from the
figure that if transition T1 is fired then, sooner or later, transition T2 will
be fired and therefore place P2 can be removed. If place P2 is marked then
this token should be put in place P3 after substitution. If there are several
output places of transition T2, all the possible cases must be considered
and several different nets must be studied from now on.
P1 P1
T1 T12
R1
P2
T2
P3 P3
1. The marking of this place never forms an obstacle to the firing of its
output transitions.
2. Its marking can be deducedP from the marking of the other places
by the relation M ( Pi ) k6 i( k M ( Pk)) + , where k is a rational
number 0 and is a rational number.
P1 P1
R2
T1 P2 T1
P3 P3
241
Appendix B. Petri Net Reduction Methods
T1 T3 T1 T3
T5 R2
P1 P2 P1 P2
T2 T4 T2 T4
P1 P2 P1 P2
R3
P3 P3
242
C
Formal Definition of
Grafchart
Syntax
The syntax focuses on the notations used to encode a programming
language. Consider a program, that indicates that the variable C
1 should be increased by 2 if x < 10 and increased by 5 if x 10.
Such a program can be written in many different notations:
as a Pascal program
program Increase-C (C,x)
begin
var C= integer;
x = real;
begin
C:= 1;
if x < 10 then
C := C+2
else
C := C+5;
end;
end
243
Appendix C. Formal Definition of Grafchart
x1
T1
x2 Initially
conclude that C = 1
T2 T3
Initially x3 x4 Initially
conclude that C = C+2 conclude that C = C+5
T4 T5
x5
T1, a transition T2, a transition T3, a transition T4, a transition T5, a transition
Although the notation used in the two programs are very different
they are both a description of the abstract phrase: increase the vari-
able C 1 by 2 if x < 10 and by 5 if x 10. The syntax describes
the relationship between a notation and an abstract phrase.
If the language is a graphical language the notation is mainly graph-
ical. The graphical elements together with the notation for step ac-
tions and transition receptivities constitute the syntax for Grafchart.
Semantics
The semantics specifies the mapping between the syntax of a pro-
gramming language and what the syntax means. A programming
language syntax has no meaning without an interpretation algo-
rithm used for interpreting the syntax. Consider for example the
Grafchart function chart shown in Figure C.1. The result of the pro-
gram will be totally different depending on if e.g., the execution
order is top-to-bottom or bottom-to-top, i.e., if step x1 or step x5 is
considered the initialstep.
The same programming language syntax can have many possible
meanings. The semantics describes the relationship between the pro-
gramming syntax and its meaning.
Pragmatics
The pragmatics focuses on how the meaning is computed, i.e, how
is the syntax and semantics implemented.
244
C.1 Notation
C.1 Notation
attr1 25
attr2 m1
attr3 sup.reactor
>
|{z} r2
during execution
Methods:
OM {agitate, heat}
O M1 agitate
O M2 heat
245
Appendix C. Formal Definition of Grafchart
Useful functions
Expr( b) gives the value of b.
Expr( attr1 ) 25
Expr( attr2 ) m1
Expr( attr3 ) sup.reactor
246
C.2 Grafchart the Grafcet version
where:
V r is the set of receptivities, V r { R 1, R 2 , }.
The set can be divided into two disjoint subsets, V ext and
V int . V ext is the set of receptivities containing variables
originating from the plant. V int is the set of receptivities
containing variables corresponding to the internal states
of the Grafchart.
V r can also be divided into three, not necessarily disjoint,
subsets.
V r V rX V rM V rGP
247
Appendix C. Formal Definition of Grafchart
{action}
{XP R , X F O , }
248
C.2 Grafchart the Grafcet version
where:
V ri , V ai , X i , T i are defined as V r , V a , X , T , for a Grafchart.
M i is the finite set of macro steps, M i { Mi,1, Mi,2, }.
The macro steps are not allowed to be infinitely recursive.
The actions associated with a macro step Mi, j M i are
given by the set action( Mi, j ) V aM i .
V rM i {V ri1 V ri2 }.
V aM i {V ai1 V ai2 action( Mi1) action( Mi2)
}.
P procedure,i is the finite set of Procedure steps, P procedure
{ P1 , P2 }.
P process,i is the finite set of Process steps, P process
{ P1 , P2 }.
GP i are the set of Grafchart procedures that can be called
from Mi.
Enteri is the enter step of the macro step, Enteri X i .
Exiti is the exit step of the macro step, Exiti X i .
where:
V ri , V ai , X i , T i are defined as V r , V a , X , T for a Grafchart.
M i is the finite set of macro steps, M i is defined as for a
Grafchart.
249
Appendix C. Formal Definition of Grafchart
R i {event, condition}
event( R i )
any G2 event expression
condition( R i) any boolean G2 expression
Ai {actiontype, actiontext}
250
C.2 Grafchart the Grafcet version
EXAMPLE C.2.1
In order to illustrate how the formal definition can be used an example is
presented. Figure C.2 shows a Grafchart for which the formal definition
is given in this example.
x1 gp1x1
gp1T1 e
T1 a
gp1x2
x2
Initially A
gp1T2 b
Grafchart
T2 b procedure gp1x3
a process step
gp1
name P2 x3 P2
procedure gp2 Finally C
T3 c
a procedure step
P1 gp2x1
name P1
procedure gp1 gp2T1 e
gp2x2
T4 b
x4
Initially C gp2T2 a
Grafchart
procedure gp2x3
T5 ^| d gp2
T1, a transition T3, a transition T5, a transition gp1T1, a transition gp2T1, a transition
event event event d event event
condition a condition c condition condition e condition e
where:
V r {V rX V rM V rGP }
V rX { R 1, R 2 , R 3 , R 4 , R 5 }
event( R 1) condition( R 1) a
event( R 2) d condition( R 1) b
event( R 3) condition( R 1) c
event( R 4) condition( R 1) b
event( R 5) d condition( R 1)
251
Appendix C. Formal Definition of Grafchart
V a {V aX V aM V aGP }
V aX { A1 , A2 , A3 }
actiontype( A1) Initially actiontext( A1) A
actiontype( A2) F inally actiontext( A2) C
actiontype( A3) Initially actiontext( A3) C
T {T 1, T 2, T 3, T 4, T 5}
X P R ( T 1) x1 X F O ( T 1) x2 ( T 1) R 1
X P R ( T 2) x2 X F O ( T 2) { x3, P2} ( T 2) R 2
X P R ( T 3) x3 X F O ( T 2) P1 ( T 3) R 3
X P R ( T 4) { P1, P2} X F O ( T 4) x4 ( T 4) R 4
X P R ( T 5) x4 X F O ( T 5) x1 ( T 5) R 5
M
P procedure { P1}
Procedure( P1) gp1
P process { P2}
Process( P2) gp2
GP { gp1, gp2}
V rGP {V r gp1 V r gp2 }
V aGP {V a gp1 V a gp2 }
I x1
252
C.2 Grafchart the Grafcet version
In order for the formal definition for the Grafchart function chart shown
in Figure C.2 to be complete, also the two Grafchart procedures named
gp1 and gp2 have to be formally defined.
event( R 1 gp1 )
, condition( R 1 gp1 )
e
event( R 2 gp1 ) , condition( R 2 gp1 ) b
Va gp1
X { gp1x1, gp1x2, gp1x3}
T { gp1T 1, gp1T 2}
X P R ( gp1T 1) gp1x1 X P R ( gp1T 2) gp1x2
X F O ( gp1T 1) gp1x2 X F O ( gp1T 2) gp1x3
( gp1T 1) R 1 gp1 ( gp1T 2) R 2 gp1
M
P procedure
P process
GP
Enter gp1x1
Exit gp1x3
event( R 1 gp2 )
, condition( R 1 gp2 )
e
event( R 2 gp2 ) , condition( R 2 gp2 ) a
253
Appendix C. Formal Definition of Grafchart
V a gp2
X { gp2x1, gp2x2, gp2x3}
T { gp2T 1, gp2T 2}
X P R ( gp2T 1) gp1x1 X P R ( gp2T 2) gp1x2
X F O ( gp2T 1) gp1x2 X F O ( gp2T 2) gp1x3
( gp2T 1) R 1 gp2 ( gp2T 2) R 2 gp2
M
P procedure
P process
GP
Enter gp2x1
Exit gp2x3
#
The formal definition for Grafchart - the grafcet version, is similar to the
formal definition for Grafcet presented in Chapter 3.3.
G < V r , V a , X , T , I >
What differs in the two definitions are the macro steps M, the procedure
steps P procedure, the process steps P process, and the Grafchart procedures
GP , included in the Grafchart definition.
Another difference is the meaning of V r and V a . In Grafcet they are vari-
ables specifying the receptivities and the actions respectively. In Grafchart
they are the receptivities and the actions, i.e., they are the corresponding
G2 statements.
254
C.3 Grafchart the basic version
where:
defines all the types that are allowed in the application.
G is the main function chart implemented by a Grafchart
process.
GP is the finite set of stand alone procedures imple-
mented by Grafchart Procedures, GP { GP1 , GP2 , }.
O is the finite set of objects, O { O 1, O 2 , }.
where:
is a set of types. It defines the different types that are
allowed in the Grafchart process.
V r is the set of receptivities associated with the transi-
tions. V r can be divided into two, not necessarily disjoint,
subsets.
V r V rX V rM
255
Appendix C. Formal Definition of Grafchart
T {T o T exception}
256
C.3 Grafchart the basic version
where:
is the set of types allowed in the Grafchart procedure.
V ri is the set of receptivities associated with the transi-
tions. V ri can be divided into three, not necessarily dis-
joint, subsets.
V ri {V rX i V rM i V rGP i}
V ai {V aX i V aM i V aGP i V aGPi}
257
Appendix C. Formal Definition of Grafchart
258
C.3 Grafchart the basic version
{action}
x X : [action( x) V aX ]
{XP R , X F O , }
t T : [ ( t) V rX ]
259
Appendix C. Formal Definition of Grafchart
where:
is the set of types allowed in the macro step.
V ri is the set of receptivities associated with the transi-
tions. V ri can be divided into two, not necessarily disjoint,
subsets.
V ri {V rX i V rM i V rGP i}
V ai {V aX i V aM i V aGP i V aMi}
260
C.3 Grafchart the basic version
{A ttr, Proc }
{A ttr, Proc }
R i {event, condition}
261
Appendix C. Formal Definition of Grafchart
Ai {actiontype, actiontext}
EXAMPLE C.3.1
In order to illustrate how the formal definition can be used a Grafchart-
BV application is presented and its definition is given. The Grafchart
application is a batch recipe, see Figure C.3. The batch recipe is supposed
to be executed in the batch cell shown in Figure 7.6.
262
C.3 Grafchart the basic version
GP
The definitions of the Grafchart process G and the objects stA, stB, m1,
r1, and ptD are:
(1) The Grafchart process G, see Figure C.3, is described by the tuple:
where
V r {V rX V rM
V rM
V rX { R 1, R 2 , R 3 , R 4 , R 5 , R 6 , R 7 }
263
Appendix C. Formal Definition of Grafchart
R1 : R2 :
R3 : R4 : R5 :
R6 : R7 :
264
C.3 Grafchart the basic version
V a {V aX V aM V aG }
V aG
V aM
V aX { A1 , A2 }
The actions, V aX , is shown in Figure C.5.
A1 :
A2 :
265
Appendix C. Formal Definition of Grafchart
T {t1 , t2 , t3 , t4 , t5 , t6 , t7 }
To T
T exception
X P R ( t1) x1 X F O ( t1) x2 ( t1 ) R1
X P R ( t2) x2 X F O ( t2) {p1 , p2 } ( t2 ) R2
X P R ( t3) {p1 , p2 } X F O ( t3) p3 ( t3 ) R3
X P R ( t4) p3 X F O ( t4) {p4 , p5 } ( t4 ) R4
X P R ( t5) {p4 , p5 } X F O ( t5) p6 ( t5 ) R5
X P R ( t6) p6 X F O ( t6) {p7 , p8 } ( t6 ) R6
X P R ( t7) {p7 , p8 } X F O ( t7) x3 ( t7 ) R7
M
P procedure {p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 }
The set of procedure steps is shown in Figure C.6.
P1 : P2 :
P3 : P :
4
P5 : P :
6
P7 : P :
8
Figure C.6 The set of procedure steps for the Grafchart process G.
266
C.3 Grafchart the basic version
A ttr(p3 ) {time}
Expr( time) 1
Proc ( p3) {sup.mixer agitate}
A ttr(p4 ) {}
Proc ( p4) {sup.mixer discharge}
A ttr(p5 ) {source}
Eval ( Expr( source)) Eval ( sup.mixer in) m1
Proc ( p5) {sup.reactor charge}
A ttr(p6 ) {temperature}
Expr( temperature) 60
Proc ( p6) {sup.reactor heat}
A ttr(p7 ) {}
Proc ( p7) {sup.reactor discharge}
P process
I { x1 }
267
Appendix C. Formal Definition of Grafchart
(2) The object m1, see Figure C.7 is defined by the 3-tuple:
M1 {, A ttr, OM }
where:
(3) The object R1, see Figure C.8, is defined by the 3-tuple:
R1 {, A ttr, OM }
where:
268
C.3 Grafchart the basic version
The definitions of stA, stB, and ptD are similar to the ones for m1 and
r1.
269
Appendix C. Formal Definition of Grafchart
Figure C.9 The object method mixer agitate method belonging to the mixer m1.
The object method mixer agitate method, see Figure C.9, is defined by:
where:
{integer}
V r {V rX V rM V rGP }
V rGP
V rM
V rX { R 1 }
The receptivity is shown in Figure C.10.
event( R 1)
condition( R 1) "active-time-larger-than(this workspace,sup.time)"
270
C.3 Grafchart the basic version
V a {V aX V aM V aGP V a,mixer a m }
V a,mixer a m V aGP , V aM
V aX { A1 , A2 }
The actions are shown in Figure C.11.
actiontype( A1) Initially
actiontext( A1) conclude that self.agitator.active true
actiontype( A2) F inally
actiontext( A2) conclude that self.agitator.active false
X { x1 , x2 }
action( x1) { A1 , A2 }
action( x2)
T {t1 }
To T , T exception
X P R ( t1 ) x1 X F O ( t1) x2 ( t1 ) R 1
M
P procedure
P process
GP
Enter { x1 }
Exit { x2 }
A ttr {time}
A 1:
A2:
271
Appendix C. Formal Definition of Grafchart
where:
defines the types allowed in the application.
G is the main function chart implemented by a Grafchart
Process.
GP is the finite set of stand alone procedures imple-
mented by Grafchart Procedures, GP { GP1 , GP2 , }.
O is the finite set of objects, O { O 1 , O 2, }.
T C is the finite set of token colors, T C {T C1 , T C2 , }.
where:
, V r , V a , X , T , M , P procedure, P process, I , and A ttr are
defined in the same way as for a Grafchart process G in
Grafchart-BV.
T C is the set of token colors allowed in the Grafchart
process.
272
C.4 Grafchart the high-level version
where:
, V ri , V ai, X i , T i , M i, P procedure,i, P process,i, GP i , Enteri,
Exiti and A ttr are defined in the same way as for a Graf-
chart procedure GPi in Grafchart-BV.
where:
, A ttr, and OM are defined in the same way as for an
object, O, in Grafchart-BV.
where:
is the set of types allowed within the token color.
A ttr is the set of attributes associated with the token
color.
attri A ttr : [{T ype( Eval ( Expr( attri )
T ype( Expr( attri ))} ]
There are default values associated with the attributes.
OM is the set of object methods associated with the token
color, OM { O M1, O M2, }.
An object method, O Mi, is defined in the same way
as a Grafchart procedure.
273
Appendix C. Formal Definition of Grafchart
{action}
x X : [action( x)) V aX ]
{X P R , X F O , }
274
C.4 Grafchart the high-level version
where:
, V ri , V ai, X i , T i , M i ,P procedure,i, P process,i, Enteri, Exiti , and
A ttr are defined as for a macro step Mi for Grafchart-BV.
T C i is the set of token colors defined for the macro step.
{ ProcC all }
{ ProcC all }
275
Appendix C. Formal Definition of Grafchart
Token class:
Action type:
For any:
There exists:
Condition:
Action text:
276
C.4 Grafchart the high-level version
277
Appendix C. Formal Definition of Grafchart
Token class:
For any:
There exists:
Event:
Condition:
Action:
278
C.4 Grafchart the high-level version
Token class:
Parameters:
Procedure:
279
Appendix C. Formal Definition of Grafchart
(h) A procedure call PC, see Figure C.14, is defined by the 4-tuple:
C.5 Remarks
The Grafchart syntax definition is based upon tuples. This kind of syntax
definition is suitable for graphical languages, e.g., Grafcet and Petri nets.
Grafchart mainly has a graphical syntax and a tuple-based definition of
the language has therefore been chosen. However, Grafchart does also
contain textual parts, e.g., the actions and the receptivities. In order to be
consistent, these are also defined using tuples. For textual languages it is,
however, more common to use the extended Backus-Naur form (EBNF).
280
D
Dynamic Simulator
A+B 2D
C+D E
The total mass balance, m( t), the component mass balances, x( t), and the
energy balance, T ( t), see Figure D.1, for the reactions are calculated.
Figure D.1 Mass balance, component mass balance and energy balance.
281
Appendix D. Dynamic Simulator
dm( t)
Win Wout
dt |{z} | {z }
incoming mass f low outgoing mass f low
m(0) mo
The component mass balance tells how much there is of a specific sub-
stance within a unit, it is given in percentage of the total mass. Unlike
mass, chemical components are not conserved. If a reaction occurs inside
a system, the mass of an individual component will increase if it is a
product of the reaction or decrease if it is a reactant. The mass fraction,
x( t), changes continuously and is therefor given by a differential equation
together with an initial condition.
dx( t) Win MV
( xin x) + r
dt | m {z } | m{z }
in out produced
x(0) xo
282
D.3 Energy Balance
dT ( t) Win 1 1
( Tin T ) + Qp Qc
dt m cp m cp m
T (0) to
Qp Hreac V r
Cooling heat, Qc :
Qc H Ac (T Tc )
m
Ac kw
A
The cooling heat is the energy that is removed due to, e.g., a cooling jacket.
H is the heat transfer, A is the area of the reactor, kw is the wall coefficient
for the reactor and is the density of the content in the reactor.
dTc ( t) Wic 1
( Tic Tc ) + Qc
dt mc cp mc
283
Appendix D. Dynamic Simulator
E2
r2 K 2 e R(T +273) cC c D
xC x D
K 2 e R(T +273)
E
MC MD
K 1 and K 2 are reaction constants, E1 and E2 are the activation energies,
R is the gas-law constant, T is the temperature in C, ci , xi and Mi are
the concentration the mass fraction and the mole weight of substance i,
is the density.
284
D.6 Implementation
D.6 Implementation
The objects are defined in a simulation class hierarchy, see Figure D.3.
The top class, volume, has two subclasses, tube-sim and non-tube-sim.
tube-sim corresponds to the pipes in the cell whereas non-tube-sim cor-
responds to the units. The class names are extended with -sim to indicate
that these classes are used in the dynamic simulator.
On the subworkspace of each class the equations specific for this class
are placed. Equations that are common to all units are placed on the
subworkspace of non-tube-sim, these are e.g. the equations for the vol-
ume, the level, the component-mass-balances, the energy-balances, the
total mass balance and the reaction-rates. In Figure D.4 two of the eight
equations associated with the class mixer-sim are shown.
To each class a number of attributes are associated. The attributes com-
mon to all classes are defined in the class volume, whereas attributes
specific to only one class are defined within the class itself. Attributes
shared by the classes are e.g. the name, the mass fraction of each sub-
stance, the volume and the level, the reaction rates of the two reactions
and the temperature. Attributes specific to a class are, e.g., the number
of inpipes.
When the program is started the equations are calculated and the differ-
ential equations are updated periodically. The results are shown as values
of the attributes to the objects. In Figure D.5 the simulation view of the
285
Appendix D. Dynamic Simulator
batch scenario is shown together with the attribute table of one of the
mixers. The table contains the values of the simulated parameters.
286
D.7 Notation and Constants
287
Appendix D. Dynamic Simulator
Constant
cp 4180 J /(kg K )
density 1000 kg / m3
wall-area-coef. 40 m
R 8314 J /(kmol K )
mol-weights:
Ma 50 kg / kmol
Mb 60 kg / kmol
Mc 40 kg / kmol
Md 50 kg / kmol
Me 40 kg / kmol
reaction-constants:
k-a-and-b-to-d 2 107 m3 /(kmol sek)
k-c-and-d-to-e 7 1010 m3 /(kmol sek)
activation-energy:
e-a-and-b-to-d 69.418 106 J / kmol
e-c-and-d-to-e 75.00 106 J / kmol
reaction-energy:
h-a-and-b-to-d 6.99 107 J / kmol
h-c-and-d-to-e 75900 J / kmol
288
E
An Introduction to G2
289
Appendix E. An Introduction to G2
290