Campus Monterrey
School of Engineering and Sciences
Development of an Informatic tool to model, control and simulate Interpreted Petri nets
A thesis presented by
An´ıbal Cid Gaona Bedolla
Submitted to the
School of Engineering and Sciences
in partial fulfillment of the requirements for the degree of Master of Science
in Engineering
Monterrey, Nuevo Le´on, December, 2020
Dedication
To my parents, that inspired and encouraged me to study. Thanks for all the love in my life and for your unconditional support and trust.
To my family, for always believe in me.
To my teachers, to help me build as a student.
To Oscar Carbajal, for clearing out doubts in myself and my family about studying this mas- ter’s degree. Thanks for his guide in such a complex moment.
To Carlos Renato, for being my Principal Advisor, accepting me in the project, his guidance and patience. I enjoy a lot working with him.
To Jose Manuel Chavez, for being my principal partner and friend in this professional experi- ence. Thanks for your help and collaboration.
Thanks for all your unconditional confidence, support, patience, and encouragement. You were my main motivation for pushing through this work.
iii
Thanks to the Tecnol´ogico de Monterrey support in tuition and the CONACYT for the scholarship support.
The research leading to these results has received funding from CONACYT Program for Education, project 288470.
iv
Development of an Informatic tool to model, control and simulate Interpreted Petri nets
by
An´ıbal Cid Gaona Bedolla Abstract
The demand and applications of automation in large manufacturing systems is increas- ing nowadays. Automated process can be modeled as Discrete Event Systems such as Petri nets (PN). In these Regulation control framework is an approach to apply control based on Interpreted Petri nets (IPN). In order to apply the regulation control theory, it is necessary to model the plant and specification as IPN, next the controller is synthesized as an IPN as well. For the practical application of these methodologies, a software toolbox was developed in this thesis project. The toolbox capabilities are the modeling of IPN plants, modeling of IPN specifications, the composition of IPN, calculation of control IPN using the Regulation approach, and simulation applied to IPN.
v
Abstract v
1 Introduction 1
1.1 Problem Statement and Context . . . 1
1.2 Objectives . . . 4
1.3 Toolbox capabilities . . . 5
1.4 Thesis structure . . . 6
2 Theoretical Framework 7 2.1 Petri nets . . . 7
2.2 Regulation control Framework . . . 10
3 Plant and Specification model construction 15 3.1 Data structure . . . 15
3.2 Plant Modeling . . . 18
3.3 IPN Composition . . . 21
3.4 Automatic Plant Modeling . . . 25
3.5 Specification . . . 25
3.6 Specification in GUI . . . 32
4 Control Synthesis 34 4.1 Control calculation in GUI . . . 34
4.2 Automatic Control calculation . . . 36
4.3 PLC codes in GUI . . . 38
4.4 Automatic PLC code generation . . . 45
4.5 Closed loop Computation . . . 46
5 Simulation 47 5.1 Simulation in GUI . . . 47
5.2 Simulation in Command Window . . . 52
6 Conclusions 55 6.1 Future work . . . 56
Bibliography 57
vi
Chapter 1 Introduction
1.1 Problem Statement and Context
Large-scale manufacturing systems are experiencing increase in demand and applications. In these systems, automation is widely used for performing repetitive tasks and processes, rep- resenting thus an important field of study. New applications and technologies are developed every day, while the industry is eager to implement them for their high impact in reducing costs and increasing production.
Programming controllers is required to implement automation in large scale manufac- turing systems. The development of these control programs may be a complex task. Commu- nication between workstations, coordination among several machines, and correct coding are some of the challenges the engineers face when applying automation.
To solve these challenges, the engineers and machine operators frequently apply heuris- tic techniques. However, practitioners at different plants may develop and apply different heuristics. One of the disadvantages of these heuristic rules for programming controllers in automation is that if the processes change then the control program has to be modified and nothing ensures that the resulting controller will properly work, since the heuristic rules only work under certain conditions. Another disadvantage is that these rules are not general, and therefore can not be straightfowardly implemented in other plants and systems. Moreover, the practice of automation is frequently performed by a trial and error aproach, verifying in this way that the implemented controller drives the plant as required. This strategy is susceptible to human errors and, in the end, causes that the set-up time for a machine, production line, or industrial system to increase in days or weeks.
For the above reasons, it has been proposed in the literature to apply mathematical tech- niques to calculate a solution to these problems. The automation of coding is an opportunity area of development. Theoretical research and practical applications need to bring closer to each other to reduce setup-time to minutes or hours.
Very often, industrial automation applications can be modeled as Discrete Event Sys- tems (DES). For example, systems that evolve according to the occurrence of events as pre- sented in [3] and [7]. DES have been widely studied in the last decades. In particular, Petri nets were developed to analyze concurrent DES, i.e. systems in which several components can partially or completely evolve in parallel [7]. In order to control a DES modelled by a Petri net, several techniques have been proposed in the literature, such as Supervisory Control
1
Figure 1.1: [6] Regulation framework [8] and Generalized Mutual Exclusions Constraints [2].
Supervisory Control is a methodology based on finite state automata [8]. In this, events are associated to symbols, thus an event sequence or trajectory forms a word, and a set of trajectories compose a language. The set of all the plant possible trajectories is called the language of the system. In this methodology, the specification is a language as well that describes the set of safe trajectories. Then, the goal of the supervisory Control Theory is to design a controller (an automaton) that constrains the system to evolve inside the specification language. An important limitation of the Supervisor control is the system size that can be ana- lyzed with. Since Supervisory Control uses automata, the states number grows exponentially with respect to the the number of components in the system (e.g., the number of machines and actuators in the automation system). For this reason, this framework only works with systems with a limited amount of components. The Supervisory Control theory has been extended to systems modelled by Petri nets [1], allowing to model large systems. However, the analysis is still based on the regular language theory, which implies large computational efforts and conceptual complexity for the engineers.
On other hand, Generalize mutual exclusions [2] is a control technique that was specially developed for Petri nets. This technique imposes linear bounds on the places marking. This control approach is very efficient an intuitive, however, its application scope is limited, since after imposing those bounds, more problems are likely to appear.
Another approach to control DES is the Regulation control approach [9]. This approach is being developed by the research group, in order to provide a formal and practical tool to engineers for the efficient automation of industrial systems. In this approach, the control goal is to make the system to perform required tasks, which are specified with a high level description, rather than imposing a safe behavior. The regulation control approach supposes that both plant and specification are represented as Interpreted Petri nets (IPN). The controller in the regulation framework is calculated as an IPN. Figure 1.1 shows the control architecture used in the regulation control framework, whose goal is to make the plant output to be equal to the specification output (otherwise stated, the output error is enforced to be null) [6]. The controller knows the information of the plant output and the specification state. If the output error is not null, the controller indicates command signals to enforce certain plant transitions to fire, in order to make the output error to be null. The controller only enables specification transitions when the output error becomes null.
Another factor to consider in the design of controllers for automation systems modelled
CHAPTER 1. INTRODUCTION 3
Figure 1.2: TCT software to apply Supervisory Control
as DES, is the existence of software tools to model and simulate the systems and to synthesize the controllers. TCT is a software tool developed by Prof. Wonham and his team in order to model plants and compute supervisors in the framework of SCT [8]. The software tool is shown in figure 1.2. There exist several software programs to design and simulate Petri nets behavior. In [4] a comparative table of different software programs was presented. The table is shown in figure 1.3. However, despite the large amount of software tools for analyzing PN, there does not exist a software tool to design, control, and simulate IPN using the regulation control approach.
The problem addressed in this thesis work is the development of an informatic tool that allows to model an automation system as IPN, to define a required specification as an IPN, to simulate an IPN system, and to synthesize a controller in the regulation control framework.
Figure 1.3: Comparative table of PN sofware, the features evaluated are: 1) easy to use, 2) allow text boxes, 3) rename elements, 4) weighted arcs, 5) not only straight arcs, 6) time management in transitions, 7) hide and shown information layers, 8) simulation step by step.
1.2 Objectives
General objective: To develop a software tool that implements existing methodologies and algorithms of the regulation control framework, as the modeling proposed by V´azquez in Tracking control of electro-pneumatic systems based on Petri nets[10], specification definition proposed by Guevara in Automatic specification generation for tracking control in interpreted petri nets [5], synthesis of regulation controllers proposed by Ram´ırez-Prado, Santoyo and Ram´ırez-Trevi˜no in [9], simulation, and translation of IPN to PLC code.
CHAPTER 1. INTRODUCTION 5
Specific objectives:
1. To implement the methodology described by V´azquez in Tracking control of electro- pneumatic systems based on Petri nets[10] for modeling automation systems as IPN.
2. To develop a software tool to implement the synchronous composition of IPN described in chapter 2.
3. To implement the modelling methodology reported by V´azquez in Tracking control of electro-pneumatic systems based on Petri nets[10] for electro-pneumatic actuators, proximity sensors, and vacuum assemblies in an automatic program.
4. To implement the methodology for defining specifications, reported by Guevara in Au- tomatic specification generation for tracking control in interpreted petri nets [5] ,as IPN.
5. To implement the synthesis algorithms for regulation controllers described by Ram´ırez- Prado, Santoyo and Ram´ırez-Trevi˜no in [9].
6. To implement an algorithm for the translation of IPN to PLC code.
7. To develop a MATLAB app that integrates all the methodologies and algorithms imple- mentations.
1.3 Toolbox capabilities
This thesis work aims to develop a toolbox to support the synthesis of regulation controllers in IPN. The toolbox capabilities are listed below:
• To build IPN models through a draw in GUI.
• To model IPN by indicating its elements. {G, M0, ΣI, ΣId, ΣO, λI, λId, ϕ} in the MAT- LAB command box.
• To compose large IPN of industrial systems indicating the number of pneumatic actua- tors, vacuum assemblies and proximity sensors.
• To compose large industrial systems by using the composition function to several IPN previously defined.
• To calculate an specification IPN using an Excel file
• To build specification IPN models through a draw in GUI.
• To model IPN by indicating its elements {G, M0, ΣI, ΣId, ΣO, λI, λId, ϕ} in the MAT- LAB command box.
• To calculate IPN controllers using regulation control approach using GUI and MATLAB command window.
• To translate from an IPN to a PLC language(IL) using GUI and MATLAB command window.
• To translate from an IPN to a PLC language(ST) using GUI and MATLAB command window.
• To simulate graphically the behavior of an IPN using GUI.
• To simulate the behavior of an IPN, observing the information in tables using the MAT- LAB command window.
1.4 Thesis structure
The thesis structure is composed as follows: In chapter 2 some basic concept of Petri nets, Interpreted Petri nets and regulation framework are presented. In chapter 3 the modeling tools of plant and specification are described, as well as the data structure used in the IPN variables and the synchronous composition function. The control calculation tools and the PLC codes are presented in 4. The Simulation environments are explained in 5. Finally conclusions and future work are discussed in 6.
Chapter 2
Theoretical Framework
Some basic concepts and definitions on Petri nets will be recalled in this chapter.
2.1 Petri nets
Petri nets are a mathematical model to represent concurrent DES.
Definition 2.1.1. [5] A Petri net (PN) structure is a bipartite digraph represented by a 4-tuple G = {P, T, I, O} where:
• P = {p1, p2, ..., pn} is the finite set of places
• T = {t1, t2, ..., tm} is the finite set of transitions.
• I : P × T → Z≥0 is a function representing the weighted arcs connecting places to transitions.
• O : P × T → Z≥0 is a function representing the weighted arcs connecting transitions to places.
The graphical representation of the PN elements is: places are represented by circles, transitions by rectangles and arcs by arrows as shown in figure 2.1 . The incidence matrix of G is a P × T matrix C defined as: C[i, j] = C(pi, tj) = O(pi, tj) − I(pi, tj), ∀pi ∈ P, tj ∈ T . The symbol •tjdenotes the set of places pisuch that I(pi, tj) 6= 0. Similarly tj• denotes the set of places pi such that O(pi, tj) 6= 0.
Figure 2.1: Petri Net (PN)
7
Analogously, the symbol •pj denotes the set of transitions ti such that O(pj, ti) 6= 0.
Similarly pj• denotes the set of transitions ti such that I(pj, ti) 6= 0.
Definition 2.1.2. [10]
An Interpreted Petri net (IPN) system is a 8-tuple Q = {G, M0, ΣI, ΣId, ΣO, λI, λId, ϕ}
where:
• G is a P N structure.
• M0 : P → Z≥0 is the IPN initial marking, representing the number of tokens in each place in the initial state. The tokens are graphically represented as dots inside the circles.
• ΣI is the input alphabet. Its elements are said to be input symbols.
• ΣIdis the identity alphabet. Its elements are said to be identity symbols.
• ΣOis the output alphabet. Its elements are said to be output symbols.
• λI : T → 2ΣI is the transition input-labelig function. A single transition can be associ- ated with more than one input symbol. If the transition has at least one associated input symbol then the transition is said to be controllable, otherwise it is uncontrollable.
• λId : T → ΣId∪ {} is the transition identity-labeling function, where is associated to transitions that are not associated with any identity symbols. Transitions can only be associated with one identity symbol which can not be shared with other transitions. For example, ∀ ti, tj (i 6= j) ∈ if λId(ti) = λId(tj) then λId(ti) = λId(tj) = .
• ϕ : P → 2ΣO is the places output-labeling function. A single place can be associated with more than one output symbol.
It is necessary to point out that identity symbols can be neither input nor output symbols.
However input symbols can also be output symbols.
The current state of an IPN is characterized by its marking distribution M : P → Z≥0
that describes the token distribution in the IPN places. The current marking M is a column vector of length |P | such that M(j) indicates the number of tokens in place j.
The marking evolution of an IPN is determined by the firing of the transitions (i.e., the occurrence of the events represented by such transitions). To fire a transition two conditions must hold:
• The transition must be marking enabled. tj is said to be marking enabled at certain marking M if ∀pi ∈ •tj, M(i) ≥ I(pi, tj).
• The transition must be labeling enabled. tj is said to be labeling enabled at certain state if all the symbols in λI(tj) are indicated. A symbol a its indicated if its associated with at least one place pi and M(i) > 0. Another option is that a its indicated by an external agent (a controller, a switch or an user).
CHAPTER 2. THEORETICAL FRAMEWORK 9
If both conditions are met then the transition tj is said to be enabled. Only enabled transitions can be fired. If transition tj fires, the marking moves from M to another one M0, which can be computed as:
M0 = M + C˜tj
where ~tj is a firing vector, with ~tj[j] = 1 and ~tj[i] = 0 for i 6= j. This is denoted as M −→ Mtj 0 The function ϕ is represented by a matrix ϕ : |ΣO|×|P |. The symbols aiare enumerated as ΣO = {a1, a2, ..., a|ΣO|}, then the matrix ϕ(i, j) = 1 if the symbol ai is associated with the place pj, otherwise it is 0. The output vector at marking M is defined as
y = ϕM where y[i] > 0 indicates that symbol aiis active at M .
Definition 2.1.3. [10] A firing sequence is a transitions sequence σ = t1t2...tmsuch that there exist markings M1, M2, ..., Mm+1 fulfilling M1
t1
−→ M2, M2 −→ Mt2 3, ..., Mm −→ Mtm m+1. The sequence length |σ| = m is the number of transitions fired in σ.
The Parikh vector ~σ of a sequence σ is a vector of length |T | where ~σ[j] = k if tj is fired k times in σ.
The firing of σ leads the current marking M to a new marking M0that can be computed as
M0 = M + C˜σ This is denoted as M −→ Mσ 0.
Another useful concept in IPN framework is the synchronous composition. The com- position of IPN is a binary operation that combines two IPN into a single one. Compositions are used to compute larger IPN. The composition merge transitions in different IPN with the same identity labels.
Definition 2.1.4. [10] (Synchronous Composition). Consider Q1 = {G1, M01, Σ1I, Σ1Id, Σ1O, λ1I, λ1Id, ϕ1} and Q2 = {G2, M02, Σ2I, Σ2Id, Σ2O, λ2I, λ2Id, ϕ2} two IPN. The Synchronous Composition of Q1
and Q2 denoted as Q3 = Q1||Q2 produces and IPN Q3 = {G3, M03, Σ3I, Σ3Id, Σ3O, λ3I, λ3Id, ϕ3} computed as follows:
1. Define P3 = P1∪P2, M03 = M01∪M02, Σ3I = Σ1I∪Σ2I, Σ3Id = Σ1Id∪Σ2Id, Σ3O= Σ1O∪Σ2O and ϕ3 = ϕ1∪ ϕ2.
2. Define the relation F ⊆ T1∪ T2that relates transitions with the same identity symbol.
F = {(ti, tj)|λ1Id(ti) = λ2Id(tj) 6= }. Define the transition with the same identity symbol cT = {ti ∈ T1∪ T2|∃tj ∈ T1∪ T2, (ti, t2) ∈ F ∨ (tj, ti) ∈ F } If F 6= θ, define a new transitions set nT = {t1, ..., t|F | and a function A : F → nT , which maps every pair of transitions with same identity symbol to a new transition. If F = θ then nT = θ.
3. Define T3 = (T1∪ T2∪ nT )\cT 4. Define λ3I such that
λ3I(t) =
λ1I(t) if t ∈ T1\cT λ2I(t) if t ∈ T2\cT
λ1I(ti) ∪ λ2I(tj) if t ∈ nT, where A(ti, tj) = t
5. Define λ3Id such that
λ3Id(t) =
λ1Id(t) if t ∈ T1\cT λ2Id(t) if t ∈ T2\cT
λ1Id(ti) if t ∈ nT, where A(ti, tj) = t 6. Define I3 such that
I3(p, t) =
I1(p, t) if p ∈ P1, t ∈ T1\cT I2(p, t) if p ∈ P2, t ∈ T2\cT
I1(p, ti) + I2(p, tj) if t ∈ nT, where A(ti, tj) = t
0 otherwise
7. Define O3 such that
O3(p, t) =
O1(p, t) if p ∈ P1, t ∈ T1\cT O2(p, t) if p ∈ P2, t ∈ T2\cT
O1(p, ti) + O2(p, tj) if t ∈ nT, where A(ti, tj) = t
0 otherwise
If Q1and Q2transitions does not share identity symbols then Q3results in a unconnected union of Q1and Q2. The synchronous composition is commutative and associative.
2.2 Regulation control Framework
The Regulation control framework introduced in [9] aims to control DES modeled by an IPN.
The specification and controller are also IPN.
Definition 2.2.1. [5] (Plant). The plant is a safe-event detectable IPN Q = {G, M0, ΣI, ΣId, ΣO, λI, λId, ϕ}
. It is assumed that two different plant places can not generate the same output symbol, the input and output alphabets are disjoint.
Definition 2.2.2. [5] (Specification). Given a plant as defined above, a specification is a Q = { ˘˘ G, ˘M0, ˘ΣI, ˘ΣId, ˘ΣO, ˘λI, ˘λId,ϕ, Ω}. Where Ω is a matrix that associates specification˘ output labels and plant output labels. With this matrix a sequence of output symbols in the specification can be mapped to a sequence of output symbols on the plant and viceversa.
Definition 2.2.3. (Controller). Given a plant and a specification as defined above, a regulation controller is a ˆQ = { ˆG, ˆM0, ˆΣI, ˆΣId, ˆΣO, ˆλI, ˆλId, ˆϕ}. The controller input symbols are a subset of the plant output symbols and the controller output symbols are a subset of the plant input symbols .
CHAPTER 2. THEORETICAL FRAMEWORK 11
Definition 2.2.4. (Closed loop system). Consider a plant Q, a specification ˘Q and a controller Q as defined above then the closed loop system is definedˆ
Qcl = Q|| ˘Q|| ˆQ
In the closed loop the controller interacts with both the specification and the plant. In order to compute the IPN controller, it is necessary to calculate a matrix Π and Parikh vectors
−
→σk. The matrix Π is a | ˘P | × |P | matrix, which associates each specification marking with a plant marking that produces the same output. The Parikh vectors contains firing vectors whose occurrence drive the plant through the markings associated with Π. The calculation of Π and Parikh vectors −→σk is performed by an Integer Programming Problem (IPP), the calculation algorithm is described below:
Algorithm 1: Calculation of Matrix Π and Parikh vectors −→σk Input: IPN plant model Q and specification ( ˘Q, Ω)
Output: Matrix Π, Parikh vectors −→σk
1 Solve the following IPP
2
min
|P |
X
i=1
| ˘P |
X
j=1
Π[i, j] +
| ˘T |
X
k=1
|T |
X
n=1
−
→σk[n]
subject to
3
Π ˘M0 = M0
4
˘
ϕ = ΩϕΠ
5 ∀ ˘tk ∈ ˘T
Π ˘C[•, k] = C−→σk
6
−
→σk ∈ Z|T |≥0 7 ∀i, ∀j
Π[i, j] ∈ Z≥0 8 ∀ ˘pk∈ ˘P , ∀tj ∈ ˘T \λI(tk) = θ
1PI(•, j) ≥ 1 + I(•, j)TΠ(•, k)
Once the matrix Π and Parikh vectors−→σk are calculated, it is possible to calculate the firing sequences that produce the computed Parikh vectors. Notice that the Parikh vectors
−
→σk do not indicate the transitions firing order. The computed firing sequences need to be controllable to ensure the plant will reach the markings associated with Π. The computation of the firing sequences can be achieved by applying a search algorithm to partially explore the reachability graph, such as the A*.
Once the sequence σkis calculated, the IPN controller can be calculated as described in [10]. The control calculation algorithm is shown below.
CHAPTER 2. THEORETICAL FRAMEWORK 13
Algorithm 2: Calculation of IPN control ˆQ
Input: IPN plant model ˆQ , specification ( ˘Q, Ω), Matrix Π and controllable sequences σk, ∀ ˘tk ∈ ˘T Output: IPN controller ˆQ
1 for every ˘tk ∈ ˘T do
2 Let beM˘k−1, ˘Mksuch thatM˘k−1−→ ˘t˘k Mk. The computed sequence σkis splited in sequences σk = σk1σ2k...σkr, in such a way that every starting transition in σikis controllable and the number r is the biggest possible. Let us define markings Mk0, Mk1, ..., Mkrsuch that
ΠM˘k−1= Mk0 σ
1
−→ Mk k1 σ 2
−→ ...k σ r
−→ Mk kr= Π ˘Mk
3 Define the set of places as ˆPk= { ˆp1, ..., ˆpr}, the set of transitions ˆTk = { ˆt0, ˆt1, ..., ˆtr}, and the initial marking as ˆM0k(ˆp) = 0 ∀ˆp ∈ ˆPk
4 Define the set of arcs as
Iˆk(ˆp, ˆt) =
(1 if ˆp = ˆpj, ˆt = ˆtj, j ∈ {1, ..., r}
0 otherwise
5
Oˆk(ˆp, ˆt) =
(1 if ˆp = ˆpj, ˆt =tj−1ˆ , j ∈ {1, ..., r}
0 otherwise
6 Define the input labeling function of transitions as
λˆkI( ˆt0) = θ, ˆλkI( ˆtj) = {a ∈ ΣO|a ∈ ϕ(p), Mjk(p) > 0}∀j ∈ {1, 2, ..., r}.
7 Define the identity labeling function of transitions as
λˆkId( ˆt0) = ˘λId( ˘tk), ˆλkId( ˆtj) = ∀j ∈ {1, 2, ..., r − 1} and ˆλkId( ˆtr) = τk0, where τk0 is a new symbol.
8 Define the labelling function of places as ˆϕk( ˆpi) = λI(σki(1))∀i ∈ {1, 2, ..., r}
9 Define the alphabets ΣˆkI =
r
[
j=1
λˆI( ˆtj), ˆΣkO=
r
[
j=1
ˆ
ϕ( ˆpj), ˆΣkId= ˆλId( ˆt0) ∪ {τk0}
10 Define the PN structure ˆGk = { ˆPk, ˆTk, ˆIk, ˆOk}
11 Define the IPN controller
Qˆt˘k = { ˆGk, ˆM0k, ˆΣkI, ˆΣkId, ˆΣkO, ˆλkI, ˆλkId, ˆϕk}
12 end
(13) for every ˘pj ∈ ˘P do
(14) Denote the indexes of the input and output transitions of ˘pj asI˘Ij = {α1, α2, ..., αr} and ˘
IOj = {β1, β2, ..., βs}
(15) Define set of places as ˆPj = { ˆp1} and the set of transitions Tˆj = { ˆt1I, ˆt2I, ..., ˆtrI} ∪ { ˆt1O, ˆt2O, ..., ˆtsO}
(16) Define the set of arcs as ∀i ∈ {1, 2, ..., r}, ˆIj( ˆp1, ˆtiI) = 0 and ˆOj( ˆp1, ˆtiI) = 1.
∀i ∈ {1, 2, ..., s}, ˆIj( ˆp1, ˆtiO) = 0 and ˆOj( ˆp1, ˆtiO) = 1
(17) Define the initial markings as ˆM0j( ˆp1) = 1 if ˘M0( ˘pj) = 1, ˆM0j( ˆp1) = 0 otherwise.
(18) Define the alphabets ˆΣIj = θ, ˆΣOj = θ and ˆΣIdj = {τα0|α ∈I˘Ij} ∪ { ˘λId( ˘tβ)|β ∈I˘Oj}
(19) Define the labeling functions as ˆλIj(ˆt) = θ∀ˆt ∈ ˆTj, ˆϕj( ˆp1) = θ, ˆλIdj( ˆtiI) = {τα0i}∀i ∈ {1, 2, ..., r}and ˆλIdj( ˆtiO) = ˘λId( ˘tβi)∀i ∈ {1, 2, ..., s}.
(20) Define the PN structure ˆGj = { ˆPj, ˆTj, ˆIj, ˆOj}
(21) Define the IPN controller
Qˆp˘j = { ˆGj, ˆM0j, ˆΣIj, ˆΣIdj, ˆΣOj, ˆλIj, ˆλIdj, ˆϕj}
(22) The controller is computed as Q =ˆ ˆ
Qt˘1|| ˆ Qt˘2||...||
ˆ Q
t˘
|˘T ||| ˆ Qp˘1|| ˆ
Qp˘2||...|| ˆ Q
p˘
|˘P|
Chapter 3
Plant and Specification model construction
The plant and the Specification IPN models are needed to calculate the system control. The developed software application provides functions to facilitate the Plant and Specification modeling.
The first problem is to describe the behavior of an industrial plant as an IPN model, some restrictions about the elements of the plant are imposed, which will be discussed in this chapter. For practical purposes, the plant switches and exterior signals are left out of the plant modelling used in specification and control calculation. This because the methodology used in the toolbox [10] consider that (after aplying control) can lead the plant to display any set of exit signs. Therefore, in this chapter it will be assumed that neither switches nor proximity sensors are included in the plant model.
On the other hand, the specification is a sequence of sensors that the process has to activate. In [5] it is explained that a specification can be indicated by a table of the required sensor sequence, in this work it is assumed that the specification table is delivered in an Excel file. Thus, an algorithm that translates the Excel file to an IPN model specification is implemented.
3.1 Data structure
Before the plant and specification models are defined, it is necessary to indicate how the data structure is defined for storing an IPN. For every IPN model used in the framework, a MATLAB structure is defined. The structure allows dot indexing to access several fields.
Every Matlab IPN has, at least, the following fields:
• M0 This is the IPN initial marking, defined as a column vector with the same length as IPN places, M0(i) is equal to the number of tokens at the i-th place at the initial marking distribution.
• M This is also a column vector with the same length as M0 , the difference is that in M the current marking is represented, this field is used during the simulation, where the marking evolves as a result of firing several transitions.
15
Figure 3.1: IPN model
• I This is a matrix of dimensions |P | × |T | that represents the weights of the arcs con- necting places to transitions.
• O This is a matrix of dimensions |P | × |T | that represents the weights of the arcs connecting transitions to places.
• AO This a char matrix that stores the output alphabet, the number of rows correspond to the number of labels LO. A different label is stored at every row. This matrix contains the information of ΣOas seen in chapter 2.
• LP This is a matrix of dimensions |LO| × |P |. If the i place is associated to the j label, the matrix in the position (j, i) has the value of 1, otherwise it is 0.This matrix contains the information of Φ as seen in chapter 2.
• AI This a char matrix that stores the input alphabet, the number of rows correspond to the number of labels LI. A different label is stored at every row. This matrix contains the information of ΣI as seen in chapter 2.
• LT This is a matrix of dimensions |LI| × |T |. If the i transition is associated to the j label, the matrix in the position (j, i) has the value of 1, otherwise it is 0.This matrix contains the information of λI as seen in chapter 2.
• AID This a char matrix that stores the identity alphabet, the number of rows correspond to the number of labels LId. A different label is stored at every row.This matrix contains the information of ΣIdas seen in chapter 2.
• LTI This is a matrix of dimensions |LId| × |T |. If the i transition is associated to the j label, the matrix in the position (j, i) has the value of 1, otherwise it is 0.This matrix contains the information of λId as seen in chapter 2.
For example the IPN shown in the figure 3.1 is saved in a variable IPN0 in MATLAB.
This variable has all the previous fields described before. Thus, dot indexing is used to access any field, for example: IPN0.M0, IPN0.O, IPN0.I etc.
The matrices saved in each file are listed as follows:
• IPN0.M0
1 0 1 0
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 17
• IPN0.M Equal to IPN0.M0
• IPN0.I
1 0 0 0 0 1 0 1 0 0 0 1
• IPN0.O
0 0 1 1 0 0 0 0 1 0 1 0
• IPN0.AO
0A0
0B0
0C0
0b0
• IPN0.LP
1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1
• IPN0.AI
0 a0
0b0
• IPN0.LT
1 1 0 1 0 0
• IPN0.AID
τ
• IPN0.LTI
0 0 1
The use of this structure simplifies the use of the Toolbox, since it provides an equal data structure to every IPN used inside the informatic tool. For every IPN, the fields inside that variable are always the same. In this way, given an IPN stored in a variable IPNx, the initial marking will be stored in the field M0 and it will be accessible by using IPNx.M0.
Figure 3.2: Definition of an IPN model in the MATLAB GUI
3.2 Plant Modeling
In industrial applications, there are several types of machines and plant elements. In order to synthesize a controller, an IPN model has to capture the information of the elements’ behavior and properties. In [10] an approach for modeling sensors, pneumatic actuators, and vacuums assemblies is introduced. These models are useful to represent electro-pneumatic systems, which are widely used in the industry. However, there are more industrial components whose models were not developed in that work.
New machines and tools are developed every day, this causes the need for new IPN models to be developed. For this reason, the developed informatic tool includes a MATLAB GUI (Graphical User Interface) that allows the modeling of new machine elements or systems.
In the figure 3.2 the GUI is presented, the first tab of the GUI is IPN, this tab contains useful tools to define an IPN, the elements (places, transitions and arcs) are selected from the right side of the board and are drawn on the left whiteboard.
In figure 3.3 the tools and buttons of the IPN tab are presented, there are three general buttons (Select, Window and Delete) and three sub-tabs (Place, Transition, and Arc).
The three general buttons functions in 3.4 are described below.
The Select button enables the selection of an element in the board, this element could be a place, a transition, or an arc. When the element is selected its properties will be shown in the IPN tab where they can be modified. Moreover, once an element is selected, it can be dragged to a new position on the board. If the element is connected to another elements (a place that is connected to arcs for example) the connection will be maintained.
The Window button enables the selection of several elements. This buttons function is used to move and delete several elements at once.
The Delete button erases the selected elements and their connections.
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 19
Figure 3.3: IPN Tab
Figure 3.4: From left to right, Select, Window and Delete buttons.
The three sub-tabs allow the drawing of different elements. It can be used to draw places, transitions, and arcs. The Place sub-tab allows to draw places. For this, first click the Place sub-tab, next click the Place icon (circle) in figure 3.5, later click on the board to define new places.
In the place sub-tab, you can see the properties of the last added (or selected) place. The Output symbols and initial marking can be modified.
Figure 3.5: Place sub-tab
The transition sub-tab contains a transition button, as shown in 3.6, to draw transitions, the orientation of the transition (vertical or horizontal) is selected by a switch that is vertical by default, the identity, and input symbols can be modified in this sub-tab.
The arc sub-tab contains a button to draw arcs as shown in figure 3.7, after clicking the button, a pre arc is defined by first selecting a place and later a transition (similarly, a post arc is defined by first selecting a transition and later a place). The weight of the arc can be modified in the sub-tab.
The sub-tab Arc also allows to define arcs by indicating the nodes to be connected by
Figure 3.6: Transition sub-tab
Figure 3.7: Arc sub-tab the arc and clicking the Add button as in figure 3.8 .
Figure 3.8: Add arc in sub-tab
Another function of the arc sub-tab is the possibility of creating node points to curve the arc: by clicking the ”o” button a node is added. By dragging the nodes the arc is curved as shown in figure 3.9.
After drawing an IPN, it can be saved in the MATLAB workspace by using the Generate button shown in figure 3.10, the IPN desired name is written in the blank space, and a variable with that name is created in the workspace.
The variable in the workspace is a structure as defined before, but also has a special field Drawas seen in figure 3.11. This field stores all the information required for drawing the IPN.
The field Draw contains all the IPN drawing properties inside several sub-fields. The IPN0 variable is an IPN.
Further chapters will provide information on how to use this model to compose larger
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 21
Figure 3.9: Curve arc using nodes
Figure 3.10: IPN drawn and the Generate Button systems.
3.3 IPN Composition
Another feature in the toolbox is the IPN Composition. This feature takes a group of Petri nets and calculates its synchronization. The synchronization, as seen in chapter 2 takes two or more Petri nets and combines them into another IPN. This procedure can be executed inside and outside the GUI. The Composition tab in the GUI is shown in figure 3.12. This tab allows the composition of several IPN into a single IPN.
The algorithm calculates the IPN according to the synchronization definition seen in chapter 2.
In this example, the IPN to compose are J0 and J1. These IPN are shown in the figure 3.13 and figure 3.14 respectably.
The IPN names are introduced in the box ’IPNs to compose’ separated by a comma.
The name of the IPN calculated as the synchronization is introduced in the box ’Result IPN name’. With J0 and J1 the example is shown in figure 3.15.
Figure 3.11: MATLAB variable IPN0 structure
Figure 3.12: Composition Tab in GUI
When the button ’Compute’ is pushed the composition is calculated. The resulting IPN J2is shown in figure 3.16.
J2is also saved in the MATLAB workspace.
The composition tab contains two checkboxes. The ’Group’ and ’Load Result’ check- boxes. If the ’Group’ checkbox is marked, the IPN composed will be stored as fields in the resulting IPN. In figure 3.17 the J2 fields are displayed. J0 and J1 are stored as fields inside J2variable.
If the ’Load Result’ checkbox is marked the calculated IPN will be displayed on the board.
Outside the GUI the composition procedure can be implemented through the command window. There are two commands to compose IPN: Qsincro and groupIPN. To compose IPN using the first function Qsincro, the command X = Qsincro(A,B) is used. Both A and B are IPN. In the variable X it is stored the resulting IPN. X do not contain neither A nor B as fields.
To store A and B as fields in the resulting IPN it is necessary to use groupIPN. The syntax to use groupIPN is: X = groupIPN(A,B). X is the composition of A and B and also A and B are
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 23
Figure 3.13: J0 IPN
Figure 3.14: J1 IPN
Figure 3.15: Composition tab to compose J0 and J1
Figure 3.16: J2 IPN
Figure 3.17: J2 fields
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 25
Figure 3.18: IPN modeled by the command Plant2PetriNet
stored in X as fields. This function also allow more than two inputs at the same time.
The composition functions can be used to compose different elements of some industrial plant into a single machine or system.
3.4 Automatic Plant Modeling
Industrial systems and production lines have hundreds of components and elements. Pneu- matic actuators and proximity sensors are components that are commonly found in automated systems. However modeling a plant with a large number of components is a tough process.
To solve this, the toolbox provides a useful command to build the IPN model of this kind of system.
The command Plant=Plant2PetriNet(neu,val,sw,N) generates an IPN structure. Plant that contains neu number of pneumatic actuators, val number of vacuum assemblies and sw number of switches and proximity sensors. N is a prefix in all the labels of Plant. For example the command Plant=Plant2PetriNet(1,1,2,’P’) will build the IPN in figure 3.18.
3.5 Specification
The IPN plant model and the specification IPN model are required to synthesize a regulation controller.
The specification is a sequence of plant sensors signals that represents the desired be- havior of the plant. Storing this data as an IPN is a nontrivial problem. In the paper, [5]
a methodology to build the specification is proposed. According to such methodology, the practitioner or operator delivers the specification in a Table file. In this toolbox, a function to translate a table in an Excel file to an IPN is provided. The function is based in [5] even though exist some differences that that will be pointed out later.
The specifications are build for a specific plant. Therefore the plant is needed to calculate the specification IPN.
Figure 3.19: TaskLvl0
The command is [Specification,Signals] = table2specificationIPN(P,T), where Specifi- cationis the variable where the Specification IPN model is stored. Signals is a variable where the signals of the Plant are related with physicals signals in the PLC. P is the plant IPN. T is the name of the Excel file in the MATLAB work folder.
The Excel file is organized as follows:
• TaskLvl0 The first Excel sheet contains the main operation sequences, as figure 3.19 shows, every row in the table indicates an operation sequence.
The first column is the Workstation column, in this column the name of the workstation corresponding to the operation sequence row is written. The same workstation can have different operations sequences but only one can be executed at a time. Multiple operations sequences will require multiple rows. It is important that in the first operation state, the initial plant labels are assigned. For example if the plant in the initial marking active { signal0, signal1,...}. Those signal have to be assigned to the first operation.
In the second column, the name of the operation sequence is written, these names are exclusive and cannot be repeated.
The third column describes the sequence of operations. Here, the sequence of the oper- ations is described, i.e., the sensor signals that are active when the operations have been performed. These signals are separated by commas. There are three types of variables used to characterize the operations: plant signals, shortcuts and sub-tasks. The plant signals are the plant output labels that the operator requires to observe after the execu- tion of the operation in the Plant in each step of the operation sequence. The shortcuts are variables that represent a group of plant signals, and the sub-tasks represent small operation sequences previously defined. Usually, the first place in this sequence is re- served for the home state of the workstation. Home is a variable that indicates the initial marking of the workstation, the actual plant signals are indicated in the Shortcuts Ex- cel Sheet. If the operator requires the presence of a group of signals to represent an operation, these must be indicated in curly brackets, e.g. {signal1,signal2,...}.
The fourth column is the event conditions column. In this column the required signals to move from one state to the following one are annotated. For example in 3.19 the
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 27
Figure 3.20: TaskLvl1
signal P SW 1.ON is required to move from Home to P P a1.B. It is important to notice that this Excel column could be empty. The syntaxis requires three data to define a condition, the triplet is (origin-state,final-state,condition), where origin-state is an operation in the operation sequence defined in the third column and final-state is the next step in the sequence.
The condition variable can be a logical proposition with operators AND, OR. The condi- tions must be specified as (a1*a2*...*an)+(b1*b2*...*bn)+... The * symbol indicates AND logic and the + symbol indicates OR logic.
Several triplets can be indicated, for example, (origin-state1,final-state1,condition1),(origin- state2,final-state2,condition2)...(origin-staten,final-staten,conditionn).
The fifth column is the Flag signals column. These flags are used for communication between different workstations. The syntaxis to assign a flag is (state,flag). To assign multiple flags it is necessary to write (state1,flag1),(state2,flag2).... .
• TaskLvl1 This Excel sheet is used to define subtasks. A subtask is a short operation sequence that is contained in one or several tasks. The use of subtasks reduces the writing of long sequences. The subtasks table is similar to the tasks table, but with subtask name column instead of the task name.
In figure 3.20 the table of the subtask is presented. The exact name of the subtask must be used in the operation sequence of the first Excel sheet.
• Shorcuts The subtask table function is to abbreviate operations sequences. In the case of the Shortcut table its function is to abbreviate signals groups. This table do not exist in [5].
A shortcut is a word that represents a group of signals, it is usually used as an indicator of home places where it is necessary to indicate all the actuators states. In figure 3.21 the shortcut table is presented, in the name column the shortcut is named, as in the subtask, the shortcut name has to be used exactly in the sequence of the main operation.
In the second column, the shortcut description is indicated, the group of plant labels is indicated between (brackets), and every label is separated by a comma.
• Signals In this Excel Sheet the variables are related to physical input or outputs. This table do not exist in [5]. This Excel sheet contains 4 columns. The first column Input
Figure 3.21: Shortcut table
Figure 3.22: Signals table
Signal Name contains the Plant Output Signals that are related to sensors connected with the PLC physical inputs, the second column contains that PLC variables. It is recommended to always save a physical input for the Reset Button.
The third column contains Plant input transition labels that represent the activation of a solenoid valves, the fourth column represents the PLC physical address related to those solenoid valves.
In 3.22 an example of this sheet is shown.
The algorithm to calculate the IPN of the Specification is shown in figure 3.23. This algorithm is the MATLAB function implemented in the Toolbox. The MATLAB function also contains differences with the algorithm presented in [5]. The function to perform this operation is: [Specification,Signals]=table2specification(T).
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 29
Figure 3.23: Flow Diagram of Workstation IPN calculation
The variable T is the name of the Excel file. The Excel file must be in the MATLAB folder. The output variable Specification is the specification IPN. The Signals is a 1 × 4 cell array that is not included in [5]. All of the cells are array matrices. The first matrix stores the output plant labels of the Signals sheet, if the operator adds a Reset button in the Excel file, the label Reset is added in this matrix. The second cell stores a matrix that contains physical inputs of the PLC. These inputs correspond to the first matrix labels. These two first cells have the same number of rows. Each label and Reset button has associated a physical input. The third matrix stores the input plant labels of the Signals sheet. The forth cell stores a matrix that contains physical outputs of the PLC. These outputs correspond to the third matrix labels.
These two cells have the same number of rows. Each label has associated a physical output.
Let us explain the procedure for the translation of the Excel file to an IPN, depicted in figure 3.23. First of all, a loop for every Workstation i is defined. In the same way a loop for every task in the workstation i is defined.
For every task j, a set of places Ptaskj is defined, every operation in the task is related to one place. Every place is labeled with the operation signals related to that place. In this point [5] labels the places with assigned flags. In the toolbox this step is performed later.
A loop is defined for every condition k in the condition statement of the task j. A transition is created in the set Tconditionkfor every OR inside the condition statement. Arcs are drawn between the initial place of the condition and all the transitions in Tconditionk. Similarly arcs are drawn between the transitions in Tconditionkand the final place of the condition. The transitions in Tconditionkare labeled with all the signal specified in the condition statement.
In case that consecutive places in Ptaskj do not have transitions that connects them, new transitions will be created. Arcs from place p-1 in Ptaskj to the new transition are drawn. Arcs form the new transition to places p in Ptaskj are drawn. In this point [5] connects last and first operation places, in the toolbox this step is performed later, this change is to use the function with subtask tables.
For every flag in the flag column, the place associated with that flag is labeled with the flag signal.
In case that some operation includes a group label or a shortcut, the place associated with that group label is labeled with the individual labels. This step do not appear in [5].
For the function, the group label {signal1,signal2} is only one label at the beginning. This step creates two labels (signal1 and signal 2) and assigns those labels to the corresponding operation place.
If the final place in Ptaskj and the first place of Ptaskj are not connected by a transition between them the transition is created and the arcs are drawn.
If this is the first task of the Workstation, the IPN built is stored in the Spec variable, otherwise it is synchronized with the Spec variable and store again in the Spec variable. This steps do not appear in [5] given that are related to programming operations.
After finishing all the tasks in a Workstation, a place phome is added. Arcs from this place to all the output transitions of the first places of the Workstation tasks are added. Arcs from all the input transitions of the first places of the Workstation tasks to phome are added.
The phome is labeled with the set of labels of the first places of the Workstation tasks com- bined. The first places of the Workstation tasks are deleted. This place initial marking is set to 1. The other places in the workstation initial markings are set to 0.
If this is the first Workstation the IPN stored in Spec is stored in Specification variable,
CHAPTER 3. PLANT AND SPECIFICATION MODEL CONSTRUCTION 31
Figure 3.24: Flow Diagram of subtask IPN calculation
otherwise it is synchronized with the Specification variable and store again in the Specification variable. This steps do not appear in [5] given that are related to programming operations.
The next step in the calculation of the Specification IPN is the subtask translation. The flow diagram of this process is shown in figure 3.24.
A loop is created for every subtask. Another loop is created for every place with the subtask label.
The steps 6-17 of the main algorithm are repeated. An arc from the input transition of the place with the subtask label to the first place of the subtask is drawn. And arc from the last place of the subtask to the output transition of the place label is drawn. The last step is to delete the place labeled with the subtask label. This ends the place with the subtask label loop.
In [5] for every subtask a IPN is build. Then is connected parallel to every place with
the subtask label. The toolbox instead builds an IPN for every time a place is labeled with the subtask label. The IPN are not connected parallel, instead the IPN replace the labeled places.
One feature included in the translation from the Excel file to IPN is the automatic la- beling. The automatic labeling function takes the labels associated with the place phome and relabels the workstation IPN places.
The premise of the automatic labeling is that in phome labeling are defined the initial state of all actuators.
Automatic labelingworks with element labels. Elements labels are defined as the labels that have the following endings: {.A,.B,.ON,.OFF}. There are element labels because those labels define the current state of that element (an extended or retracted pneumatic actuator for example). This labels have always a pair label. For example Label0.A is pair with Label0.B.
Every operation step has to be assigned with exactly one label of every pair of labels. For the second operation step to the last, automatic labeling applies the following algorithm:
• From the set of labels assigned to the previous operation, identify the labels that belong to a pair of labels.
• For every label identified in the previous place, if their pair is not assigned to the current operation, assign the identified label in the current operation.
This feature is not included in [5].
The last step of the function [Specification,Signals] = table2specificationIPN(P,T) is to to calculate the matrix Ω and to update the Specification output alphabet. Matrix Ω is as defined previously in chapter 2. Matrix Ω is stored in the variable omega. The variable omega is saved in a field with the name omega in the specification IPN. Omega is a matrix of dimensions |S(LO)| × |P (LO)|. Where S(LO) is the number of labels in the specification output alphabet and P (LO) the number of labels in the plant. If the i label in specification output alphabet is associated with the j label in plant output alphabet, the matrix in the position (i, j) has the value of 1, otherwise, it is 0.
An updated output alphabet is needed. As said in chapter 2 the labels in the specification output alphabet represent the signals that the process requires to observe in the plant. Thus the labels in both alphabets must be different. The matrix Ω function is to associate both alphabets whereby the omega calculation and the specification output alphabet update take place in one function. The update function add a symbol ’#’ at the beginning of every label in Specif ication.AO. In this way Specif ication.AO and P.AO labels are not mistaken.
3.6 Specification in GUI
A specification can also be directly defined as an IPN, by using the tools provided in the GUI.
As shown in figure 3.2, the toolbox includes a ”Specification” checkbox. If the checkbox is activated, the user has to write the plant name associated with that Specification and the IPN model will be saved in MATLAB workspace and also the matrix Ω will be calculated and saved as a field in the specification IPN. The Specification built with this process will be stored in a variable named by the IPN Name box value shown in 3.25.
This process is recommended only for small specifications. Another option to compute the IPN model of the Specification is to use the Spec Gen GUI tab. As seen in figure 3.26, the