Lecture 9 - Czech Technical University in Prague

Download Report

Transcript Lecture 9 - Czech Technical University in Prague

Lecture 9
Petri Net
Reaction tank – an application
example
Petri Net
9.1 Petri Net - introduction
9.2 Petri Net - history
9.3 Petri Net and state diagram
9.4 Petri Net and PLC in Industrial Control
9.5 Petri Net - terminology
9.6 Petri Net - formal definition
9.7 Petri Net - types
9.8 Petri Net - primitive structures
9.9 Petri Net - properties
9.10 Petri Net - interpretation for Industrial Control
Reaction tank scheme
Raw material
Water for cooling
Steam for
heating
Product
Reaction tank
– an application example
Reaction tank – problem
Reaction tank - scheme
Technological conditions
Variables list
Petri net for reaction tank control –
places and transitions
Petri net for reaction tank control
Reaction tank control - Petri net
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
Reaction tank control - Petri net
P1,…….P5 places
(circle)
T1,…….T6 transitions
(rectangle)
oriented connection - edge (line,arc)
token, mark
(filled point)
• Static character – structure of the net
• Dynamic charecter – movement of the mark
through the net
9.1 Petri Net - introduction
• Mathematical tool suitable for analysis
and modelling of discrete events
systems
• Grafical tool (comprehensive)
• Very helpful and favourite tool both for
theoretical research
and for practical design of control
systems
Petri Net - introduction - 2
• PN – Petri Net
• SIPN – „Steuerung Interpretierte Petri
Netz“ (Germany)
• It is possible to simply express and model
– Parallel behaviour
– Resource sharing
– Real time relationships
Petri Net – introduction - 3
• This introduction deals with the graphical aspect
of Petri Net for system description, not the
algebra of Petri Net.
• While the mathematical properties of Petri Net
are interesting and useful, the beginner will find
that a good approach is to learn to model
systems by constructing them graphically, aided
in construction and analysis by computer
software for simulation and analysis of Petri
Nets.
10.2 Petri Net - history
• Author: Carl Adam Petri – Ph.D. dissertation
thesis in 1962 on the topic Formal methods in
dicrete events modelling (communication
betweeen sequential machines - automatons)
• See Ref. [1]
• Further development at MIT – Massachusets
Institute of Technology (seventies of the
previous century)
Petri Net - history - 2
• Since then, Petri Nets and their concepts have
been extended and developed, and applied in a
variety of areas:
Office automation, work-flows, flexible
manufacturing, programming languages,
protocols and networks, hardware structures,
real-time systems, performance evaluation,
operations research, embedded systems,
defence systems, telecommunications, Internet,
e-commerce and trading, railway networks,
biological systems…… !
9.3 Petri Net and state diagram
• State diagram suitable for typical
sequential systems (one event following
another event in clear order, only a few
alternative pathes, no paralell pathes)
• Petri nets suitable for parallel processes
and communications
• SW for Petri net applications makes
possible to create and run model in
modular way
9.4 Petri Net and
PLC in Industrial Control
• There are very efficient graphical tools
(languages) at disposal today for PLC
programming which are very similar to the Petri
Nets formalism (they are based on it)
• Two terms directly onnected with Petri Nets:
• GRAFCET (Graphe Fonctionenel de Connexion
Etapes Transitions - France, origin: 1975-1977)
– since 1987 International standard (IEC 848)
• SFC (Sequential Function Chart)
– according to the international standard
IEC 1131-3 (standard for PLC programming)
9.5 Petri Net - terminology
• A Petri Net is a collection of directed arcs
connecting places and transitions. Places
may hold tokens.
• The state or marking of a net is its
assignment of tokens to places.
• Here is a simple net containing all
components of a Petri Net:
Petri Net - terminology - 2
Simple net
weight
Petri Net - terminology - 3
• Arcs have capacity (weight) 1 by default; if other
than 1, the capacity is marked on the arc.
• Places have infinite capacity by default.
• Transitions have no capacity, and cannot store
tokens at all.
• With the rule that arcs can only connect places
to transitions and vice versa, we have all we
need to begin using Petri Nets.
• A few other features and considerations will be
added as we need them.
Petri Net – terminology - 4
Petri net models consist of two parts:
1. the net structure that represents the
static part of the system
2. a marking that represents the overall
state on the structure. State can change this represents dynamic behavior of the
system.
Petri Net - terminology - 5
The token distribution among the places of a
Petri net is called its marking.
When one or more tokens reside in a place,
the place is said to be marked, otherwise it
is unmarked.
The number of tokens at a place represents
the local state of the place.
The marking of the net represents the
overall state of the system.
Petri Net - terminology - 6
• A transition is enabled when the number of
tokens in each of its input places is at least
equal to the arc weight going from the place to
the transition.
• An enabled transition may fire at any time. When
fired, the tokens in the input places are moved to
output places, according to arc weights and
place capacities. This results in a new marking
of the net, a state description of all places.
Petri Net - terminology - 7
Example
This Petri net has:
• 2 places: p1, p2
• 1 transition: t1
• p1 has one token: f(p1) = 1
• p2 has 0 tokens: f(p2) = 0
Petri Net - terminology - 8
Firing a Transition
When a transition tj fires
• Each pi that has an edge from pi to tj
removes a token from pi
• Each pj that has an edge from tj to pj adds
a token to pj
Petri Net - terminology - 9
Petri net before t1 fires:
Petri net after t1 fires:
Petri Net - terminology - 10
A transition must be enabled before it fires:
There is a token in each pi that has an edge
to the transition
• An enabled transition may or may not fire
(it can be another condition asociated with
the transition)
Petri Net – terminology - 11
Petri net before t1 fires:
Petri net after t1 fires:
Petri Net - terminology - 12
• A place can contain non-negative whole
number of marks
• At the moment of transition firing
(activation, skipping) the marks are
withdrawn from input places and added to
the output places of the transition
• Oriented edges connect places and
transitions
Petri Net - terminology - 13
• initial marking (marks displacement in the
places before the first skip) describes the
initial state of the system
• system development is represented by
transfer of the marks in the net on the
basis of activating of the transitions (skip)
• every new marking of the system
represents a new state of the system
Petri Net - terminology - 14
Transition enabling - example
wheels
P9
car body
P8
4
T3
P11
car
• weight of the P9 - T3
edge is 4
motor
P10
• place P9 contains only 3
3 tokens
• transition T3 is not
enabled (for one car we
need four wheels)
• transition T3 cannot be
fired
9.6 Petri Net - formal definition
A Petri Net is a 5 tuple PN = (P,T,F,W,M0),
where
9.7 Petri Net - types
Original Petri Nets
• Only 1 token can be removed/added from a
place when a transition fires
(i.e., the weight is always 1)
Weighted Petri Nets
• Generalized the original Petri net to allow
multiple tokens to be added/removed when a
transition fires.
• The edges are labeled with the weight (i.e.,
number of tokens)
• If there is no label, then the default value is 1
Petri Net - types - 2
Weighted Petri net
before t1 fires:
Weighted Petri net
after t1 fires:
Petri Net - types - 3
Other Types of Petri Net
Petri nets have been extended over the
years in many directions including
time,data, and hierarchy.
Time Extended Petri Nets
Coloured Petri Nets
Hierarchical Petri Nets
Time Extended Petri Net
First developed in the mid 1970s
• For real systems it is often important to describe the
temporal behavior of the system, i.e., we need to model
durations and delays.
• There are 3 basic ways to introduce time into the Petri
net. Time can be associated with:
– tokens
– places
– transitions
The first introduction of time in Petri nets is in the Timed
Petri net model
C. Ramchandani, “Analysis of Asynchronous concurrent
systems by timed petri nets”, MIT MAC-TR-120, 1974.
In this model, a time duration is associated with each
transition.
Time Extended Petri Net - 2
• The firing rules in this model are that the transition must
fire as soon as it is enabled, and firing a transition takes
a fixed, finite amount of time.
• The notion of instantaneous firing of transitions is not
preserved in the Timed Petri net model.
• When a transition becomes enabled, the tokens are
immediately removed from its input places.
• After the time delay, tokens are deposited in the output
places.
• The result is that the state of the system is not always
clearly represented during the process.
• // Note. There are many other extensions to Petri Nets
that consider time.
Coloured Petri Net
Developed in the Late 1970s ( K. Jensen, “Colored Petri
nets and the invariant method”, Theoretical Computer
Science, volume 14, 1981, pp. 317-336.)
• Tokens often represent objects (e.g. resources, goods,
humans) in the modeled system
• To represent attributes of these objects, the Petri net
model is extended with coloured or typed tokens.
each token has a value often referred to as `colour'.
• Transitions use the values of the consumed tokens to
determine the values of the produced tokens
a transition describes the relation between the
values of the `input tokens‚ and the values of the `output
tokens'
• It is also possible to specify `preconditions' which take
the colours of tokens to be consumed into account.
Hierarchical Petri Nets -1
Developed in the Late 1980s
• Specifications for real systems have a
tendency to become large and complex
• An abstraction mechanism, hierarchical
structuring, is used to make constructing,
reviewing, and modifying the model easier
• The hierarchy construct is called a subnet
Hierarchical Petri Net - 2
• A subnet is an aggregate of a number of places,
transitions, and subsystems
• Such a construct can be used to structure large
processes
• At one level we want to give a simple
description of the process (without having to
consider all the details).
• At another level we want to specify a more
detailed behavior.
• Each subnet is represented with a rectangular
box that encapsulates part of the Petri Net
model
Hierarchical Petri Net - 3
• Each subnet is represented with a
rectangular box that encapsulates part of the
Petri Net model
9.8 Petri Net - Primitive structures
Primitive structures - 2
• Sequence is obvious - several things
happen in order.
• Conflict is not so obvious. The token in P4
enables three transitions; but when one of
them fires, the token is removed, leaving
the remaining two disabled. Unless we can
control the timing of firing, we don't know
how this net is resolved.
Primitive structures - 3
• Concurrency, again, is obvious; many
systems operate with concurrent activities,
and this models it well.
• Synchronization is also modeled well
using Petri Nets; when the processes
leading into P8, P9 and P10 are finished,
all three are synchronized by starting P11.
Primitive structures - 4
• Confusion is another not so obvious construct. It
is a combination of conflict and concurrency. P12
enables both T11 and T12, but if T11 fires, T12 is
no longer enabled.
• Merging is not quite the same as synchronization,
since there is nothing requiring that the three
transitions fire at the same time, or that all three
fire before T17; this simply merges three parallel
processes.
• The priority/inhibit construct uses the inhibit arc to
control T19; as long as P16 has a token, T19
cannot fire.
Primitive structures - 5
Example:
Enabling and activation - effective conflict
between transitions T1a T2
hungry human A
dinner
P1
P2
T1
P4
full human A
hungry human B
P3
T2
P5
dirty dishes
P6
full human B
Primitive structures - 6
Conflict development between transitions T1 and T2 –
version A
hungry human A
dinner
P1
P2
T1
P4
filling human A
hungry human B
P3
T2
P5
dirty dishes
P6
filling human B
Primitive structures - 7
Conflict development between transitions T1 and T2 –
version B
hungry human A
dinner
P1
P2
T1
P4
filling human A
hungry human B
P3
T2
P5
dirty dishes
P6
filling human B
10.9 Petri Net- properties
We can ask some interesting questions about the
Petri Nets (i.e., we can ask interesting questions
about the models of a particular system)
Some properties of interest include:
• Terminate
Does the Petri Net terminate?
• Immediately Reachable
Is a state reachable when a transition fires?
• Reachable
Is a state eventually reachable?
Petri Net- properties -2
• Live
In all states, is there at least one
transition that can fire?
• Partial deadlock
Is there a state in which at least one
transition that can never fire?
• Deadlock
Is there a state in which none of the
transitions can fire?
Petri Net- properties -3
• Safe
In all states, does each place contain at
most one token?
• Bounded
In all states, is there a limit to the
number of tokens that can be in one
place?
• Conservative
Is the total number of tokens in the
Petri Net constant?
9.10 Petri Net - interpretation for
Industrial Control
• Petri net can expres the desired control
system behaviour (SIPN)
• Another condition must be fulfilled before
transition firing, e.g.: some event
asociated with the transition must occure
Places ……actions of the control system
(outputs of PLC)
Transitions …conditions (e.g. from sensors,
inputs of PLC)
Reaction tank - problem
• typical partial task from food industry or
chemical industry
• analogue variables, e.g. temperature,
level, pressure, are monitored via binary
sensors (only limit values of this analogue
variables - it is cheaper
• concurency of activities in technological
process
• SIPN application
Reaction tank scheme
Raw material
Water for cooling
Steam for
heating
Product
Technological conditions for
control system (e.g. PLC)
Specific reaction is to be run in the reaction
tank at the temperature hold between
<T1,T2>. Steam is used for heating
(double cover of the tank). Cold water is
used for cooling (radiator tube inside of the
tank). The liquid is mixed with the mixer
during the reaction.
In the initial state: all valves are closed,
both heating, cooling and mixing do not
work.
Technological conditions - 2
• Start of the process via Start button
• The tank is filled up to the high level
sensor and the mixer is started
• The mixer is running until the reaction is
fulfilled
• According to the comming raw material
temperature steam heating or water
coolling is starting up
Technological conditions - 3
• If the comming raw material temperature
matches the desired interval <T1,T2>,
neither heating nor cooling is started
• If the desired temperature is reached
when heating or cooling, the heating or
cooling is shut down. The reaction is
completed.
• The liquid from the tank is drained (low
level sensor)
Variables list
inputs (of PLC)
• STA…….Starting button (the reaction is
to start má začít: STA=1)
• H_LS….. High level of the raw material
sensor (the level is above the high sensor:
H_LS=1)
• L_TS….. Low temperature of the raw material
(T<=low limit T1 : L_TS=1)
• H_TS…..High temperature of the raw
material (T>=high limit T2 : H_TS=1)
• L_LS….. Low level of the raw material sensor
(the level is under the low sensor: L_LS=1)
Variables list
outpus (of PLC)
• V1_S….. Valve for raw material input
(V1_S=1: open the valve)
• M……... Mixer motor
(M=1: start the mixer)
• V2_TP… valve for heating steam input
(V2_TP=1: open the valve)
• V3_P….. Valve for product output
(V3_P=1: open the valve)
• V3_CHV..Valve for cooling water input
(V3_CHV=1: open the valve)
Limit values identification
• Analogue variables are often monitored via
binary sensors (cheaper)
• There are two types of limit values in
industrial processes control – operating and
critical
• operating:H - High
L- Low
• critical: HH - High High
LL - LowLow
• These limits are highlighted on the operator
panel (for better overview )
Petri Net (PN) for reaction tank control places - and output variables values
• P1 (standstill): V1_S=0, V2_TP=0, V2_TP=0,
V3_P =0, V3_CHV =0, M=0
• P2 (filling):
V1_S=1
• P3 (coolling): V3_CHV=1
• P4 (heating): V2_TP=1
• P5 (draining): V3_P=1
• P6 (mixing): M=1
Petri Net for reaction tank control transitions - and input variables
values
•
•
•
•
•
•
STA, (start):
T1
H_LS.NotL_TS , (filled, cool):
T2
L_TS, (low temperature of the raw material):
T3
L_LP, (low level of the product ):
T4
H_LS.H_TS, (filled, warm):
T5
NotH_TS, (not enough high temperature of the raw
material
T6
• H_LS.NotH_TS.L_TS, (filled, temperature between
<T1,T2>
T7
PN for reaction tank control -1
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control -2
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control - 3
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control - 4
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control - 5
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control - 6
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control -7
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control - 8
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control - 9
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control -10
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control - 11
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
PN for reaction tank control -12
P1
T1
P2
T5
T2
T7
P3
P4
P6
T3
T6
P5
T4
Reference
[1] Petri, C.A., Kommunikation mit
Automaten. Petri, C.A., Bonn: Institut für
Instrumentelle Mathematik, Schriften des
IIM Nr. 2, 1962, Second Edition:, New
York: Griffiss Air Force Base, Technical
Report RADC-TR-65--377, Vol.1, 1966,
Pages: Suppl. 1, English translation
Reference - 2
• http://robotica.pardini.net/Documentos/Petri01.p
df
• www.hait.ac.il/staff/leonidm/1F99L15.htm
• http://www.ite.his.se/ite/utbildning/kurser/auc111/
pdf/pn_informal.pdf
• http://www.techfak.unibielefeld.de/~mchen/BioPNML/Intro/pnfaq.html
• A Petri Net Tool: DNAnet (Free software for
students)