Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom....

59
1 Automatismos Automatic Systems 5º Ingeniero de Telecomunicación Transparencias de la asignatura Fabio Gómez-Estern. ES Ingenieros. 2008 Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 2 Lesson 1 Index Introduction Evaluation of modelling tools Tables and phase diagrams Reduced state graph Petri Networks Introduction Description Modelling examples Advantages and comparison with other tools

Transcript of Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom....

Page 1: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

1

Automatismos Automatic Systems

5º Ingeniero de Telecomunicación

Transparencias de la asignatura

Fabio Gómez-Estern. ES Ingenieros. 2008

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 2

Lesson 1 Index

� Introduction

� Evaluation of modelling tools

� Tables and phase diagrams

� Reduced state graph

� Petri Networks

� Introduction

� Description

� Modelling examples

� Advantages and comparison with other tools

Page 2: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

2

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 3

Introduction

Systemsdescription

� A system description consists of the development

of a model of the system itself. Two types of

models can be distinguished:

� Structural models: defining the parts of the system

� Functional models: defining how the system works

� Petri Networks (PN) are intended for studying logic

sequential systems from a functional point of view

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 4

IntroductionSeparation between Operating and Control Parts

� Most Logic Sequential Systems can be represented

and divided into two Subsystems

� Operating part (OP): makes the process run by

transforming the input variables into output variables,

and issuing reports. It comprises the elements inside

process (Sensors, motors, actuators, valves, etc.)

� Control part (CP): From the established set points, and

the reports, it provides adequate orders for commanding

the behavior

Page 3: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

3

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 5

IntroductionSeparation between Operating and Control Parts

OperativePart

Reports

CommandsControl

Part

Inputs

Outputs

Set p oints, references

External outputs, if required

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 6

IntroductionFinite Automata: mathematical definition� Definition of Automaton : “Device capable of emulating or following

certain movements”.

� Formally, a finite automaton is a Discrete System defined by the quintuplet <E,S,Q,d,l>� Finite set of input symbols: E={E i}

� Finite set of output symbols: S={Sj}

� Finite set of internal states: Q={Qk}

� Transition function between states in terms of inputs and previous states: dddd:Q x E → Q

� Output function, in terms of inputs and states

l:Q x E → S

Page 4: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

4

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 7

IntroductionTable representation of finite Automata

� Consider a finite Automaton with E={a,b} and S={x,y}.The prescribed behavior is: the output at an instant “k”

should be S(k)=xif and only if the last three inputs follow the sequence “a-b-a” and S(k)=yotherwise.

� Q={Qa,Qab,Qbb} are the significant states of the problem

� Qa: last input was “a”

� Qab: last 2 inputs were “a-b”

� Qbb: last 2 inputs were “b-b”

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 8

Evaluation of ToolsPhase diagrams and tables

� The procedure is: Build a table associating the states with the inputs in order to indicate the corresponding outputs and the new states.

� Graphical representation in phase diagrams.

Phase table Phase diagram

Page 5: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

5

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 9

Evaluation of ToolsPhase diagrams and tables – Example: Cart System

� When button M is pressed, the cart moves right (d), until B is rechaed. Once there, it starts moving left (i) until A is reached, and then stops.

� E={M,A,B}

� S={i,d}

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 10

Evaluation of ToolsTable and phase diagrams - criticism

� They are exhaustive descriptions, as they gather all data

of all possible combinations of inputs and states.

� Industrial systems are characterized by

� Large number of inputs and outputs.

� Largely unspecified. Many I/O pairs (E x Q) have no physical meaning.

� These methods have little practical use. They are difficult

to implement when the number of inputs increases.

Page 6: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

6

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 11

Evaluation of ToolsReduced state graph

� It introduces the concept of Receptivity.

� When the system is in a specific state, it is only receptive

(or sensitive) to a small subset of external events capable

of inducing a state transition.

� Hence, there is no need to analyze all possible

combinations of inputs for every single state.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 12

Evaluation of ToolsReduced state graph - Examples

� The RG (Reduced State Graph) is a graph where the logical condition that triggers a transition between 2 states is described as any logical function of the inputs.

� Moving Cart Example

� The resulting description is simpler, direct, and more intuitive.

Page 7: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

7

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 13

Evaluation of ToolsReduced state graph – Examples continued� Two carts come and go. They are synchronized at the right ends. Both carts must have reached (B,D) in order to start moving backwards.

A small specification change (e.g. add a new cart) may affect the description significantly.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 14

Evaluation of ToolsReduced state graph – Examples continued

� Three carts come and go, synchronized at the right ends.

� The number of states grow at a rate of 2N+1-1, where N is the number of carts.

� All combinations of events are evaluated taking into account the order of occurrence, though it might be irrelevant.

Page 8: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

8

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 15

Evaluation of ToolsReduced state graph – Examples continued

end(A)

end(B)

end(B)

end(A)

� Two simultaneous actions A and B, followed by C, are composed of subtasks.

DRAWBACK: All possible finishing order of subtasks Should be considered

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 16

Evaluation of ToolsReduced state graph – Criticism

� Advantages� When introducing the concept of receptivity, the system

description is significantly simplified.

� The information used for modelling is minimum and necessary.

� Drawbacks� When there are concurrent evolutions, this method requires

the evaluation of all possible chronological orderings of external events.

� Local changes may result in total redefinitions of the description.

� It is not suitable for a descending description (“top-down”).

Page 9: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

9

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 17

Petri NetsIntroduction http://www.daimi.au.dk/PetriNets/

� Created by German Prof. C.A. Petri in the 60’s.� Structure

� A Petri Network or (Petri Net) is a mathematical tool (with it associated graphical representation) that allows to model the behavior of a large variety of systems, being of special interest in the logical sequential and concurrent systems.

� It consists of an oriented graph, with two types of nodes: Places and Transitions, joined together arternatively by Arcs. The Places are represented by circles, and the Arcs by segments.

� The Arcs are oriented and they connect Places with Transitions and vice-versa, but never 2 Places or 2 Transitions at a time.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 18

Petri Nets (PN)Introduction (continued)

� Petri Nets permit to model and analyze the Control Subsystem (CP) of discrete systems with concurrent evolutions.

� In order to use them in application modelling, they must be endowed with an interpretation, by assigning physical meaning to the evolution conditions of the network and to the actions triggered by that evolution.� Petri Net → Structure

� Interpretation → Physical Significance

� The evolution of a PN without interpretation is said to be autonomous.

Page 10: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

10

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 19

Petri Nets Introduction (continued)

� Behavior:� A Place may contain a nonnegative number of Marks. Each mark is represented by a dot in the Place.

� The set of Marks associated, at a given time, to the places, is denoted the Network Marking.

� For the functional description of a PN, the following associations are made,� Places → actions or outputs� Transitions → events (as functions of inputs and actions)

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 20

Petri Nets Introduction (continued)

� Behavior:� The dynamics of the PN is represented by the evolution of its marking.

� The basic rules conducting the evolution of the marking are,� A Place Li is an input Place of the Transition Tj, if there exists an Arc

oriented from Li to Tj.� A Place Li is an output Place of the Transition Tj, if there exists an Arc

oriented from Tj to Li.� A Transition is enabledif all its input places are marked.� An enabled Transition is fired if the event associated with it is verified.

A Firing of a transition consists of removing marks from each of its input Places, and adding marks to each of its output Places.

Page 11: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

11

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 21

Petri Nets

Description model. Structure

� Autonomous PN:� When analyzing autonomous PN we must observe its structure and behavior.

� Structural model of a PN� Generalized PN: a quadruplet R=<P,T,a,ba,ba,ba,b> such that

� P: Finite nonempty set of Places.� T: Finite nonempty set of Transitions.� aaaa: P x T → N Pre-incidence function� bbbb: T x P→ N Post-incidence function

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 22

Petri Nets

Description model. Graphical Representation

� Oriented Graph with 2 types of nodes:� Places (circles), to which “long-lasting”actions are associated.

� Transitions (line segments), to which “instantaneous” actions are associated.

� The Arcs join places with transitions and vice-versa.

� The marks reside in places and they represent their active state.

Page 12: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

12

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 23

Petri Nets

Description model. Graphical Representation

� Each Arc is labelled with a nonnegaive integer aaaa(p,t) or bbbb(p,t) called weight of the Arc.

� There exists and Arc oriented from Place Pi to Transition Tj � aaaa(pi,tj) >0.

� There exists and Arc oriented from Transition Tk to Place Pl � bbbb(tk,pl) >0

� As a general rule, a non-labelled Arc has weight 1 and if weight>1, it must be labelledwith the corresponding weight.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 24

Petri Nets Description.

� For a generalized Petri Net, R=<P,T,a,ba,ba,ba,b>, tXXXXT, pXXXXP; the following sets are defined:� Set of input places ot t:

�t={ pXXXXP / aaaa(p,t)>0 };� Set of output places of t:

t� ={ pXXXXP / bbbb(t,p)>0 };� Set of input transitions of p:

�p={ tXXXXT / aaaa(p,t)>0 };� Set of output transitions of p:

p� ={ tXXXXT / bbbb(t,p)>0 };

Page 13: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

13

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 25

Petri Nets Description.

� Example:�t1={pa,pb};t1�={pc,pd};

�ph={t4,t8};

ph�={t6,t7};

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 26

Petri Nets Description. Behavior� Marking: the Marking M is a mapping P→N that links an integer number (of Marks) to each Place.

� Marked Petri Net: A pair <R,M0>, where M0 is theinitial Marking.

� Enabled Transition: Transition t is enabled for the Marking M ����each input Place has, at least, aaaa(p,t) marks.

p XXXX�t , M(p)≥aaaa(p,t)� Evolution of Markings: the firing of an enabled Transition implies the removal of aaaa(p,t) Marks from each Place p XXXX�t and the addition of bbbb(t,p) Marks to each place p XXXXt�.

Page 14: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

14

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 27

Petri Nets Description. Markings evolution. Examples

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 28

Petri Nets Description. Properties (Deadlocks)� Live Transition: (for a given initial Marking M0). If, for all marking M reachable from M0, there is a marking, successor of M, from which the Transition can be fired.

� Live Petri Net: (for a given initial Marking M0), if all its transitions are live for that Marking.

� Bounded Petri Net: (for a given initial Marking M0). There is a constant k>0 such that any marking reachable from M0 is such that no place has more than k Marks.

� Binary Petri Net: (for a given initial Marking M0). If any Marking reachable from M0 is such that no place has more than 1 Mark.

Page 15: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

15

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 29

Petri Nets Description. Properties. Example

� Is this a Live Petri net?� Is this a Binary Petri Net?

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 30

Petri Nets Description. Properties.

� Live is too hard a property.

� “Liveness” levels. L(M0)=set of possible firing sequences from M0.

Page 16: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

16

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 31

Petri Nets Description. Properties.

� Marking Related Properties� Conformed Petri Net: If it is Live and Binary� Conflicting Transitions: some simultaneously enabled transitions are in conflict if they are descendants from the same Place and this does not have enough number of Marks to fire them simultaneously.

� A conflict is made effective if the events associated to the transitions are verified simultaneously. An effective conflict corresponds to ambivalences in the description.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 32

Petri Nets Description. Properties. Example.

Not LiveNot BinaryConformed

•Are there conflicting transitions?•And in the previous PN? Where?

Page 17: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

17

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 33

Petri Nets Description. Matrix representation.

A PN may be represented by means of two matrices. Assuming |P|=n and |T|=m, then we define� Pre-incidence matrix C-=[Cij

-]n*m with Cij-=aaaa(pi,tj)

� Post-incidence matrix C+=[Cij+]n*m with Cij

+=bbbb(tj,pi)

� Ordinary PN: The one whose incidence functions values are 0 or 1.

aaaa(pi,tj) XXXX{0,1}, bbbb(tj,pi) XXXX{0,1}, tXXXXT, pXXXXP

� Pure PN: the one where no place is simultaneoulsy input and output place of the same transition.

aaaa(pi,tj) bbbb(tj,pi)=0 for all (i,j)

The matrix representation of a PN may be simplified by using a unique incidence matrix

C=C+-C-

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 34

Petri Nets

Description. Matrix representation.

� Matrix representation of an ordinary pure PN

Page 18: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

18

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 35

Petri Nets Matrix representation. Marking & Evolution

� The marking vector of an ordinary and pure PN is a column vector of |P|=n elements in the form M(pi), where each element represents the number of existing marks in each place. Therefore, in the last example

M0T=(1 0 0 0 0 0 0 0 1)

� Marking evolution rule: if transition t is enabled by the Marking Mi and t is fired, the new parking Mj for each place, p is evaluated as

Mj(p)=Mi(p)+b(t,p)-a(p,t)

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 36

Petri Nets Matrix representation. Firing sequences

� A firing sequence (ssss) from a marking M0 is represented by the sequence of transitions such that the firing of each of them leads to a marking that guarantees the enablement of the next transition in the sequence

M0 – t1 –→M0 –t2 –→ M0 –t3 –→… – tr –→Mq����M0 – ssss –→Mq

� In the last example, the sequence of firings s=s=s=s=t8t6t1t3t2t4t6 is applicable

M0T=(1 0 0 0 0 0 0 0 1) – ssss1 –→M7

T=(0 1 0 0 0 0 1 0 0)

Page 19: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

19

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 37

Petri Nets Matrix representation. Firing sequences

� Characteristic vector associated to a sequence of firings: the vector ssssXXXXNm whose i-th element is the number of times that transition t has been fired in the sequence.

� For instance, the characteristic vector associated to the sequence s=s=s=s=t8t6t1t3t2t4t6 would be

ssss8T====(1 1 1 1 0 2 0 1)

� A Marking M is reachable from an initial marking M0

���� there exists a sequence of firings applicable from M0 that transforms M0 into M. llllssss/ M0 -ssss-→ M

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 38

Petri Nets Matrix representation. State equation

� Let be C the pre-incidence matrix of a pure and marked Petri Net. From the definition of C and the marking evolution rule the following Petri net state equation is derived.

Mk = Mk-1 +C*Uk=M0 +C*s, if M0 -s-→M

� Where� Mk marking after the k-th firing

� Mk-1 marking after the (k-1)-th firing

� Uk=vector with all zero elements except the i-th, if ti fires at instant k

Page 20: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

20

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 39

Petri Nets Interpretation

� We have previously seen a Petri Net (generalized) as a mathematical structure, a marking and some evolution rules (dynamical properties). Un order for a PN to represent a real-world system, it is necessary to associate it with an interpretation which is defined as� Physical meaning of firing conditions� Actions generated by the evolution of the marking

� The internal state of a PN will be always given by the marking.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 40

Petri Nets Interpretation

� Interpreted Petri Nets:� In order to give interpretation to a Petri Net it is necessary to define the following elements

� Set of inputs: X={x1,x2,…xe}

� Set of outputs: Y={y1,y2,…ys}

� Set of impulse outputs: Z={z1,z2,…zq}

� Some other useful definitions� External Condition (Ci): a combinational logic function of the input (and output) variables of the system.

� Event (Ei): a change in the logic state of an external condition.

Page 21: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

21

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 41

Petri Nets Interpretation

� Interpreted Petri Nets:� Two types of interpretation

� Actions generated associated to places.

� Actions generated associated to transitions.

� As a general rule� Transitions: Events, external conditions, impulse outputs

� Places: Level outputs

� If the activation of an output is linked to external conditions, it is said to be a conditioned output.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 42

Petri Nets Interpretation

� An interpreted PN:� A marked PN� An application T->E (events)� An application T->C (external conditions)� An aplication T->Z (impulse outputs)

� An application P*C->Y (level outputs)

� Three rules of marking evolution in interpreted Petri Nets1. Firing of enabled transition ti: iff Ci&Ei.2. When a transition is fired, all its associated impulse outputs are

generated.3. If a place p is marked and the associated external conditions are

satisfied, all level outputs are activated.

Page 22: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

22

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 43

Lesson 2 Functional modelling of concurrent systems

� Table of contents:� Concurrency.

� Shared resources and mutual exclusion

� Task Synchronization

� Classical modelling examples

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 44

Petri NetsTypical configurations

� Places:� A place with several input/output arcs

is called “OR-node”. There are two particular cases of OR-nodes:� Selection: 1 input arc and several output

arcs� Attribution: several input arcs and 1 output

arcs

� Transitions:� A transition with several input/output

arcs is called “AND-node”. There are two particular cases of AND-nodes:� Distribution: 1 input arc and several output

arcs� Junction: several input arcs and 1 output

arcs

General OR-node Selection Attribution

General AND-node Distribution Junction

Page 23: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

23

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 45

Petri NetsTypical configurations

� OR-node: when one of the 3 transitions is fired (either 1st, or 2st or 3rd) the corresponding output place is selected.

� OR-node: when one of the 3 transitions is fired (either 1st, or 2st or 3rd) the output place is granted (attributed) the right to execute.

� AND-node: when the transition is fired, the execution (mark) is distributed between one place AND another AND another…

� AND-node: when the transition is fired, the execution threads join together in a unique output place.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 46

Petri NetsTypical scenarios: Timing in Petri Nets

� Assume the system must stay in a specific place for a fixed time interval. An external Timer will be used. The timer starts when the place is activated (when its input transition is fired)

� The same timer may be associated to several transitions (if they are not conflicting)

Page 24: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

24

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 47

Petri NetsTypical scenarios: Counting in Petri Nets

� Assume that the system must stay in a specific state until a certain number of events of one type have occurred.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 48

Petri NetsModelling examples: moving carts

Two carts Three carts

Page 25: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

25

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 49

Petri NetsModelling examples: simultaneous actions

2 simultaneousactions

2 simultaneousactions withsubactions

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 50

Petri NetsAdvantages and comparison of tools

� Clear advantages in concurrent systems� Descriptions are less complex. In the

moving carts example, the number of places is 4N vs. 2N+1-1 states for the reduced state graphs (for N=10, 40 places vs. 2047 states). This is due to the fact that the state is determined by the marking.

� It is much simpler to introduce local variations.

Page 26: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

26

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 51

Petri NetsModelling of complex systems - Concurrency

� Concurrency refers to the simultaneous execution of processes, making it harder to visualize the concept of state.

� In Petri Nets, concurrency is modelled by means of transitions with more output places than input places (distribution), thus increasing the total number of marked places.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 52

Petri NetsModelling of complex systems – Mutual exclusion

� Mutual exclusion refers to resources that can only be used by a single process or a limited number of them.

� In Petri Nets, mutual exclusion is modelledby means of places with more output transitions than input transitions(selection).

Page 27: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

27

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 53

Petri NetsModelling of complex systems – Synchronization

� Synchronization refers to the need for coordinating the endings of a set of processes.

� In Petri Nets, synchronization is modelledby means of transitions with several input places (distribution). They may represent task endings (junction) or synchronization points (wait points before a start).

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 54

Petri NetsModelling of complex systems – Alternating tasks

� Two processes (each modelled as Petri subnet) could alternate without any need for a common resource, and it can occur between more than two processes. For example, an alternating behavior is desired between Process A, B and C. Sequence: A->B->C->A->B->C

Page 28: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

28

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 55

Petri NetsModelling of complex systems – Modularity

� A set of sequences represented by a Petri subnet may be reused at several points of a network, by simply considering that the return point of the sequence must be remembered.

� Moreover, the function call will not be executed while the module is running.

� With this tool, modularity is gained, and smaller size designs are achieved

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 56

Petri NetsModelling of complex systems – Modularity

Rep

eate

d se

quen

ce

Page 29: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

29

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 57

Petri NetsModelling of complex systems – Modularity

Rep

eate

d se

quen

ce

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 58

Petri NetsModelling of complex systems – Examples

� Shared resource between two carts� A: Must wait in Ea until common tregion is

free. Wait time in D Ta: 100s� Same as A but with priority and Tb=50s

Page 30: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

30

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 59

Petri NetsModelling of complex systems – Examples

� Shared resource between two cartsCOMMENTS1) Initial condition: two carts at rest in Ca and Cb.

2) The central place models the access to the shared resource and it represents its idle state.

3) The output transitions of the resource are in conflict if they request it simultaneously. In order to solve the ambiguity, priority is given to cart B.

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 60

Petri NetsModelling of complex systems – Examples� Producer-consumer problem

Producer Consumer

Page 31: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

31

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 61

Petri NetsModelling of complex systems – Examples� Alternating sequences

� Surface treatment via immersion

� 2 treatment tanks (double time)

� 2 subcicles with operator acknowledgement

Load Ungrease Treatment Vashing Unload

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 62

Petri NetsModelling of complex systems – Examples� Alternating sequences

Page 32: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

32

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 63

Petri NetsModelling of complex systems – Examples� Readers and writers

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 64

Petri NetsModelling of complex systems – Examples� Philosophers dinner

Page 33: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

33

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 65

Examples of Petri Nets

� AGVs

� Access to Bank premises

� Lift

� Hybrid Car

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 66

Examples of Petri Nets: AGVs

Page 34: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

34

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 67

Examples of Petri Nets: Bank acces control

� Access control to Bank Facilities

P: Push button for exiting

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 68

Two tanks system

Page 35: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

35

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 69

Hybrid vehicle

� TARGET: Design an automatism for controlling of a hybrid car

� The fuel engine (1) and the electrical one (3) are connected to the motor tree of the vehicle via thesame transmission (2).

� A module of power electronics (4) decides when to use the electrical motor and/or the fuel one, andwhen to recharge the batteries (6) based on certain parameters of operation.

� The vehicle can work in three ranges of speeds,

� Low (signal VB)

� Medium (VM)

� High (VA)

� Additional signals:

� Braking (input) FR � Signals related to the battery:

� BC: batteries are completely charged

� BB low charge.

� Outputs:

� MG=1: Fuel engine ON. MG=0: Fuel engine off

� ME=1: Electric engine ON. ME=0: Electric engine off

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 70

Hybrid vehicle� I/O architecture

VBVMVAFRBCBB

PLCMG

ME

� Behavior� Driving force: The electrical motor may change its operating condition, between generator

and motor at any time, although the gasoline motor will have to remain connected a 2 minimum of min (120 seg) once activated.

� Velocity Modes:� For low speeds (VB) the driving force must be, if possible, obtained exclusively from the

electrical engine, as long as the battery this sufficiently charged. If the battery level is low (BB) the combustion motor should be connected, making the electrical motor work in generator mode and activating the charge of batteries.

� For medium velocities (only fuel engine and electrical motor in generator mode, chargingbatteries). If batteries reach a maximum level (BC=1), they will stop charging and thedriving force will be shared between electrical and fuel engines.

� For High velocities (VA) both fuel and electrical engines will be active. If at a givenmoment, the battery level goes too low (BB) the electrical engine will switch to generatormode.

� Braking:� In any of the previous cases, if the braking signal (FR) is activated, we must implement

regenerative braking by switching the electrical engine into “generator” mode for storingmode the extra kinetic energy in the batteries.

Page 36: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

36

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 71

Hybrid vehicle: solution (GRAFCET)

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 72

Industrial Manipulator

� Implement as an alternative sequence:� First pick part from box A� Then Box B� Then Box C� Restart

� Activate HIMOTOR between LS2 and LS4

Page 37: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

37

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 73

Industrial

Manipulator

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 74

Lift Control Example� Three stages. On each of them

� Outer Lift Call Push buttons, that must be also lit Lift is busy (3 inputs)

� Correct position indicator for opening (3 inputs)

� Cabin sensor/buttons� Open and Closed door sensors (2 inputs)

� Presence detector, indicating person under door (1 input)

� Push buttons for selecting the target floor (in parallel with outer push buttons). Must be lit when lift is moving

� Outputs (9)� Lamps indicating that the lift is busy (1 output)� Lamps indicating the target floor (3 outputs)� Lift up, Liftdown relays (2 outputs)� Door open, door close relays (2 outputs)

� Further considerations� The doors must close after the Lift Call Push button has been

pressed, and 2 seconds have been ellapsed without any activity onb the photocell

� While the door is closing, if the photocell detects motion, the door must be opened again and wait 2 secs from the moment the entrance is cleared

Page 38: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

38

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 75

Lift Control example: solution (simplified)� HINT: implement the photocell externally!

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 76

Washing machine control example� Cycle of operation of the machine:

� The cycle initiates after a pressing of a start push button

� At startup, the tub will be filled with water through electrovalve EVR until the level detector activates. This detector is activated when the tub is full of water and it is deactivated when empty.

� The washing operation consists of 50 cycles. In each cycle the motor will turn 30 seconds in clockwise (motor H) and 30 more counterclockwise (motor A), leaving a pause of half second in each change of sense

� After the washing is finished, the water of the tub will drain, by means of the pump, until the level detector is deactivated. While the pump works, the tub must turn (motor A).

� After the washing, there will be 4 rinses. Each rinse will begin filling of water the tub through electrovalve EVE until the level detector activates. Each rinse will consist of 10 cycles. In each cycle the motor will turn 30 seconds in each sense, with a pause of 0.5 sec. in each change of sense.

� After each rinse the water of the tub will drain, by means of the pump, until the level detector is deactivated. While the pump works, the tub must keep turning (motor A).

� Once the rinse is finished, the clothes must be centrifuged (motor C) during five minutes. During centrifugation the draining pump must be active.

� Counters :� C1 counts the number of cycles (50 in washing and 10 in rinse), while C2

counts the number of times that takes water to rinse (C2=0 in washing).

Page 39: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

39

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 77

Washing machine example: solution

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 78

Modern Automatisms I: GEMMA� In an automated production process, although it is desirable, machines are not

continuously in automatic operation mode. On the contrary, quite often a set ofcircumstances may force the process to stop:

� Machine faults

� Defective raw material

� Feeding parts shortage

� Periodic maintenance

� Weekend stops

� In modern automatic systems, these circumstances are foreseable and the automatismitself is prepared for detecting faults and breakdowns and cooperating with the operator ortechnician in maintenance, repair and other task outside the normal automatic operation

� In order to fix an universal way of defining the different states of a system, the frenchADEPA (Agence nationale pour le DÉveloppement de la Productique Appliquée àl'industrie) has developped the GEMMA guide (Guide d'Etude des Modes de Marches et d'Arrêts).

� GEMMA is a graphical guide which used to represent, in a simple and understandable way, the different run modes in which a production facility works, as well as the waysandconditions for switching between modes

� GEMMA is complemented with Petri Nets and GRAFCET, for a progressive description ofthe production automatism

Page 40: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

40

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 79

The GEMMA guide

� The control part can be powered or not. We are only interested in power-up operation.

� Once powered, thesystem can be in 3 states,� Normal operation

� Stopped

� Failed

� Production can happen in any situation! (though sometimes it produces invalid parts)

� Each of the previous situations is, in turn, subdivided in a set of internal states, leading to a total of 17 modes of operation

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 80

The GEMMA guide

Page 41: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

41

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 81

GEMMA Utilization (I)

Stop at the end of a cycle

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 82

GEMMA Utilization (II)

Human Supervised Automatic Operation

(ordered)

Page 42: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

42

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 83

GEMMA Utilization (III)

Manual Operation

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 84

GEMMA Utilization (IV)

Emergency Stop and return to initial state

Page 43: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

43

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 85

GEMMA Utilization (V)

Em. stop with manual state modification

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 86

GEMMA Utilization (VI)

Stop at a given point (=breakpoint)

Page 44: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

44

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 87

GEMMA Implementation

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 88

GEMMA Example

Page 45: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

45

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 89

GEMMA Example

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 90

GEMMA Example

Page 46: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

46

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 91

GEMMA Example

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 92

GEMMA Example

Page 47: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

47

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 93

Modern Automatisms: UML

UML Activity diagramImplements concurrency & synchronization

� Unified Modelling Language

� UML 2.0 is the current available version� APPLICATIONS

� OOP Software Modelling

� Web-based application

� Business Modelling

� GRAPHICAL TOOLS (9 DIAGRAMS)� Static

� Use case diagram � Class diagram

� Dynamic� Object diagram � State diagram � Activity diagram� Sequence diagram � Collaboration diagram

� Implementation� Component diagram � Deployment diagram

� SOFTWARE TOOLS� Diagram sketching

� Automatic code generation

� e.g. Rational RoseUML State Machine: states, transitions, Superstates

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 94

UML activity diagrams

� Generalization of Flowcharts� Implements

� Concurrency� Synchronization� Bifurcations…

� Start/End Nodes

Page 48: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

48

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 95

UML state machines: Seminar example(Mostly used in real time systems)

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 96

UML modelling: Superstates

Being Taught

Deliver course Material

Mark student work

Research course Material

Update course Material

Found

Require MoreMaterial

Work submitted

Student Dropped [Seminar Size>0]

Student Dropped [Seminar Size>0]

Teach

Final exams

Classes end

School

Break

Break starts

Break ends

Term starts

Page 49: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

49

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 97

Part II

PLC Programming of Petri Nets

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 98

Siemens S7-300 architecture

Page 50: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

50

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 99

Startup concepts

� Basic elements

� Power Supply (24VDC)

� CPU

� Bus connectors

� Peripheral modules

� Periferal Power supply

� Multirow configuration

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 100

Startup concepts: logical structure

� CPU

� Control Unit

� ROM with operating system

� Program memory

� Accumulator

� Process images, for inputs & outputs

� Timers, counters and marks

� Peripherals

Page 51: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

51

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 101

Startup concepts: logical structure

Program memory (RAM)

Control Unit

Registers

(ACU!,ACU2, VKE)

Op System memory(R

OM)

Process Image (I/O)

Internal timers

Internal counters

Marks

Analog & Dig. Inputs

Analog & Dig. Outputs

Other modules

EPROM or EEPROM

EPROM or EEPROM

BUS

MPI Channel

Modules: timers, comparers, counters

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 102

Family S7-300 technical data

646464646432Counters

Integr. Funct

Timers

Ex Time 1K instr

(msec)

AI/AO

DI/DO

Instr. memory

(Kbytes)

Working memory

(Kbytes)

Profibusconnecttion

Master-slave

IFM: 20DI/16DO

4AI/1AO

10DI/6DO

204820482048204820481024

0.30.30.30.30.60.6

2562562562566464

1024102410241024256256

6422161642

128644824126

CPU 316CPU 315-2DP

CPU 315CPU 314/IFM

CPU 313CPU 312 IFM

Page 52: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

52

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 103

Cyclic program processing

� Concept: program

execution cycle

� Watchdog

� IIP update

� Instructions

� Transfer to OIP

� Assignments=“wiring”

Watchdog

IIP Update

User program

OIP Transfer

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 104

Bits, bytes, words…

� BIT

� BYTE: 8 BITS

� WORD: 16 BITS

� DOUBLE WORD: 32

BITS

7 6 5 4 3 2 1 0

7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0

7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0

Page 53: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

53

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 105

Preliminaries

� Before processimg instructions, channels are

amples, and values are stored in IIP. IIP is

uncghanged during the cycle

� After processing, output channels are activated via

the OIP. This is an intermediate storage for the

outputs (avoid glitches)

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 106

Input/Output addresses

� Digital I/O: bytes 0..127, 32 bits per module.

� Hence, up to 32 modules.

� Original byte of module: plug place*4

� Analog I/O:

� Bytes 256..752. 16 bytes per module.

� Hence, up to 16 modules.

� Original byte: 256+plug place*16

� Some addresses are unused

Page 54: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

54

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 107

Input/Output addresses

� Digital addressing

� Analog address

60.0

to

63.7

40.036.0

to

39.7

32.0

To

35.7

IM

(receiv

er &

PS)

28.0

to

31.7

24.020.016.012.04.0

to

11.7

0.0

to

3.7

IM

(emmi

tter)

CPU

& PS

368

to

383

272

to

287

256

to

271

IMCPU

&

PS

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 108

Input/Output addresses

� Digital addressing

� Analog address

60.0

to

63.7

40.036.0

to

39.7

32.0

To

35.7

IM

(receiv

er &

PS)

28.0

to

31.7

24.020.016.012.04.0

to

11.7

0.0

to

3.7

IM

(emmi

tter)

CPU

& PS

368

to

383

272

to

287

256

to

271

IMCPU

&

PS

Page 55: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

55

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 109

Address spaces� Inputs/outputs

� E/A bit 0.0 to 65535.7� EB/AB byte 0 to 65535� EW/AW word 0 to 65534� ED/AD double word 0 to 65532

� Marks� M bit 0.0 to 65535.7� MB byte 0 to 65535� MW word 0 to 65534� MD double word 0 to 65532

� Peripherals� Byte PEB/PAB 0 to 65535� PEW/PAW, PED/PAD

� Timers: T0 to T255

� Counters: C0 to C255

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 110

AWL Programming in S7-300TIMERS AND COUNTERS

� Timers:� Elements capable of adopting a sequence of states in

time.

� They are fired through the evaluation of a condition(raising edge)

� Each CPU model has a determined quantity of timers

� There exist hardware timer modules

� Timers programming: initial setup� Fixed Setup: L S5T#4S200MS

� H:HOURS, M:MINUTES, S:SECONDS, MS:MILLISECONSDS

� Variable setup (e.g. 4.2s): L MW 120� At address 120: 0001 0000 0100 0010� Base time: 00:0.01s; 01:0.1s; 11:10s

BCD value

Page 56: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

56

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 111

AWL Programming in S7-300TIMERS AND COUNTERS

� Timer types:� SI: Impulse

U E0.1L S5T#42S500MSSI T1

� Usage: on raising edge of E0.1. T1 takes value “1” f or 42,5 seconds as long as E0.1 remains at “1”

� SV: Extended ImpulseU E3.0L S5T#125SSV T3

� Usage: on raising edge of E3.0. T3 takes value “1” f or 125s, independent of E0.3. Moreover, it can be fired agai n (raising edge of E3.0 restarts countdown)

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 112

AWL Programming in S7-300TIMERS AND COUNTERS

� Timer types:� SE: Connection delay

U E3.5L S5T#700MSSE T2

� Usage: on raising edge of E3.5, T2 takes value “1” A FTER 0.7 seconds, as long as E3.5 remains at “1”, and it wil l remain there until E3.5 goes back to “0”

� SA: Disconnection delayU E3.4L S5T#8SSA T3

� Usage: on raising edge of E3.4, T2 takes value “1”. When E3.4 returns to “0”, T2 will be zero AFTER 8s. May be re fired.

Page 57: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

57

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 113

AWL Programming in S7-300TIMERS AND COUNTERS

� Counters:� Elements capable of storing, increasing a decreasing an integer

value.� Its initial setup, increase or decrease are fired through the

evaluation of a logical condition (raising edge)� Each CPU model has a determined quantity of counters� There exist hardware counter modules

� Initialization:� Fixed Setup: L C#37� Variable setup (e.g. 153) L MW 160

� At address 160: 0000 0001 0101 0011 BCD value

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 114

AWL Programming in S7-300TIMERS AND COUNTERS� Counter operations:

� S: Initialize

� ZR: Decrease

� ZV: increase

� =: Query

� Usage:� On raising edge of 3.0, Z1

takes value “1”,. A raising edge of E3.1 increases by 1 the value of Z1. On falling edge of E3.2, it is decreased by 1. A4.0 is “1”if Z1 is nonzero

U E 3.0

L C#21

S Z 1

U E 3.1

ZV Z 1

UN E 3.2

ZR Z 1

U Z 1

= A 4.0

Page 58: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

58

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 115

AWL Programming in S7-300TRANSFER OPERATIONS

� Accumulators� ACU1 (32 bits). Stores results� ACU2 (32 bits)� Overflow bit: OV

� L: Loads the contents of a byte, word or double word into ACU1. Old contents of ACU1 move to ACU2.� L EB 7 PAE byte 7 to lower byte of ACU1� L EW 7 PAE bytes 7-8 to lower w. ACU1� L -312 Bipolar constant 16bits� L 2#1010100101100001 16bits binary constant� L W#16#FFFF 16bits HEX constant� L -1.3e+3 Floating point

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 116

AWL Programming in S7-300TRANSFER & LOGICAL OPERATIONS

� T: Transfers the contents of ACU1 to a byte, word or double word of memory. ACU2 remains unchanged.� T AB 8� T AW 8� T MW 5� T MD 10

� Logical operations(the result is soterd in ACU1)� UW logical AND between ACU1 and ACU2 (16 lower bits)� OW logical OR between ACU1 and ACU2 (16 lower bits)� XOW logical XOR between ACU1 and ACU2 (16 lower bits )� Example

� L EW 90 (0000011 0110 1100)� L W#16#F0A9� UW

Page 59: Automatismos - esi2.us.esfabio/TranspAuto2008.pdf · 2 Automatismos. 5ºIng. Telecom. FabioGómez-Estern Slide 3 Introduction Systems description A system description consists of

59

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 117

AWL Programming in S7-300ARITHMETIC OPERATIONS

� +I ACU1=ACU1+ACU2 (16bits)

� -I ACU1=ACU2-ACU1 (16bits)

� *I ACU1=ACU1*ACU2 (16bits)

� /I ACU1=ACU1*ACU2 (16bits)� (In case of overflow, OV is activated)

� ==I

� <>I

� >I ACU2>ACU1?

� >=I ACU2>=ACU1?

� <=I ACU2<=ACU1?� L EW 90 0000 0011 0110 1100 ACU2-L� L Z 3 0000 0010 1001 1100 ACU1-L� <I� =A 1.2 (A1.2=0)

Automatismos. 5º Ing. Telecom. Fabio Gómez-Estern Slide 118

AWL Programming in S7-300FLANK EVALUATION

� POSITIVE (FP) OR NEGATIVE (FN)� REQUIRES A MEMORY MARK� Positive flank (Raising edge)

� U E1.0 � U E1.3� FP M1.0� =A4.0

� Negative flank (falling edge)� U E2.1� O M2.0� FN M1.1� =A4.1