• Non ci sono risultati.

3. - I Linguaggi di programmazione (Parte Prima)

N/A
N/A
Protected

Academic year: 2021

Condividi "3. - I Linguaggi di programmazione (Parte Prima)"

Copied!
32
0
0

Testo completo

(1)

Università degli Studi di Modena e Reggio Emilia Automation Robotics and System CONTROL

Automazione Industriale

3 - I linguaggi di programmazione.

(Prima Parte)

(Prima Parte)

Cesare Fantuzzi ([email protected])

Ingegneria Meccatronica

Ingegneria della Gestione Industriale AA 2010/2011

(2)

IEC Standards

סּ The International Electrotechnical Commission(IEC)

is a not-for-profit, non-governmental international standards organization that prepares and publishes International Standards for all electrical, electronic and related technologies.

סּ The IEC held its inaugural meeting on 26 June 1906,

סּ The IEC held its inaugural meeting on 26 June 1906,

following discussions between the British IEE, the American Institute of Electrical and Electronics

Engineers (IEEE) (then called AIEE), and others.

סּ It currently counts more than 130 countries.

סּ Originally located in London, the commission moved to

its current headquarters in Geneva in 1948.

2 C. Fantuzzi 3. I Linguaggi di Programmazione

(3)

IEC 61131 Standard

- 1 General overview, definitions

- 2 Hardware

- 3 Programming Languages

IEC 61131 is an IEC standard for Programmable logic controllers

(PLCs). It was known as IEC 1131 before the change in numbering system by IEC.

- 3 Programming Languages

- 4 User Guidelines

- 5 Messaging Service Specification

- 7 Fuzzy Logic

- 8 Implementation guidelines

(4)

Key quality features of IEC

61131-3

• Structured software - through use of Configuration,

Resource and Program Organization Units (POUs), that implements software modularization.

• Data Typing – languages restrict operations to only apply to appropriate types of data

• Execution control - use of tasks

• Discrete event system handling - Sequential

Function Charts

• Software encapsulation - through use of POUs,

structures and complex data types.

(5)

History of IEC 61131

NEMA Programmable Controllers Committee formed (USA) GRAFCET (France)

IEC 848, Function Charts DIN 40719, Function Charts (Germany)

NEMA ICS-3-304, Programmable Controllers (USA) IEC SC65A/WG6 formed

DIN 19 239, Programmable Controller (Germany)

MIL-STD-1815 Ada (USA)

IEC SC65A(Sec)67

IEC 65A(Sec)38, Programmable Controllers

IEC SC65A(Sec)49, PC Languages

Source: Dr. J. Christensen

77 78 79 80 81 93 94 95

70 82 83 84 85 86 87 88 89 90 91 92

IEC 848, Function Charts

Type 3 report recommendation 96 IEC 1131-3 IEC 64A(Sec)90 IEC 61131-3 name change

it took 20 years to make that standard…

C. Fantuzzi 3. I Linguaggi di 5

(6)

Importance of the IEC61131

סּ IEC 61131-3 is the most important automation language

in industry.

סּ 80% of all PLCs support it, all new developments base

on it.

סּ Depending on the PLC vendor (and often Country

סּ Depending on the PLC vendor (and often Country

because cultural reasons), some languages are most used.

C. Fantuzzi 3. I Linguaggi di Programmazione

(7)

Application Configuration

(Hardware)

configuration

(8)

Application configuration

(Software)

configuration resource program resource program FB FB program FB FB program

(9)

Application Software

(Run Time)

configuration resource program resource task task program FB FB task program FB FB task program

A Task is a run time (scan) instance of a

(10)

configuration resource

program

resource

IEC 61131 – Software Model

(Variable exchange)

task task program FB FB task program FB FB task program

execution control path variable access paths function block

variable or

represented variables

communication function legend: global and directly

access paths

C. Fantuzzi 3. I Linguaggi di Programmazione 10 FB

(11)

Communication model (a)

(12)

Communication model (b)

(13)

IEC Programming Model

סּ Data types

סּ Variables

סּ Program organization units (POU)

– Functions – Function blocks – Programs Programming languages

}

– Programs

סּ Sequential Function Chart (SFC) elements

סּ Configuration elements

– Global variables – Resources

– Access paths – Tasks

C. Fantuzzi 3. I Linguaggi di Programmazione 13

languages

}

(Programming language)

(14)

graphical languages

The five IEC 61131-3

Programming languages

Function Block Diagram (FBD) Sequential Flow Chart (SFC) START STEP T1 T2 D1_READY D2_READY STEP A N ACTION D1 D ACTION D2

STEP B N ACTION D3 D3_READY PUMP AUTO MAN_ON ACT DO V DI V CALC1 CALC IN1 IN2 OUT >=1 Structured Text (ST)

VAR CONSTANT X : REAL := 53.8 ; Z : REAL; END_VAR

VAR aFB, bFB : FB_type; END_VAR

bFB(A:=1, B:=‘OK’);

Z := X - INT_TO_REAL (bFB.OUT1); IF Z>57.0 THEN aFB(A:=0, B:=“ERR”); ELSE aFB(A:=1, B:=“Z is OK”);

END_IF Ladder Diagram (LD)

Instruction List (IL)

A: LD %IX1 (* PUSH BUTTON *) ANDN %MX5 (* NOT INHIBITED *) ST %QX2 (* FAN ON *) STEP B D3_READY D4_READY ACTION D3 N D ACTION D4 T3 textual languages OUT PUMP AUTO MAN_ON ACT CALC1 CALC IN1 IN2

(15)

Structured Text (ST)

סּ ST is a textual language similar to “C”, or (for who might

remember it) PASCAL.

סּ ST can be successfully used to develop complex

algorithm, data structure handling, etc.

סּ ST has the syntactical structure of the procedural

programming languages: programming languages:

Assignment

Choices

Iteration

(16)

Assignment

סּ The variable on the left side should be of the same type

of the result of the expression of the right side.

סּ on contrary, the ST compiler will introduce a variable

casting to set all the variables to the same type.

C. Fantuzzi 3. I Linguaggi di Programmazione 16 <variable> := <expression>;

(17)

Choices

IF <Boolean_Expr_1> THEN

<code>;

ELSIF <Boolean_Expr_2> THEN

<code>; ELSE

<code>; END_IF

C. Fantuzzi 3. I Linguaggi di Programmazione 17 CASE <integer_expression> OF <integer_value_1> : <code>; <integer_value_2> : <code>; ... ELSE <code>; END_CASE

(18)

Iteration

REPEAT <

code>;

UNTIL <Boolean_Expr> END_REPEAT; WHILE <Boolean_Expr> DO

C. Fantuzzi 3. I Linguaggi di Programmazione 18

WHILE <Boolean_Expr> DO <

code>

END_WHILE;

FOR <integer_Variable>:= <initial_value> TO

<final_value> BY <step> DO <

code>

(19)

Warning

סּ The iteration structure may violate the real time concerns

of the program.

סּ An iteration can’t be done to wait for a external variable

changes.

C. Fantuzzi 3. I Linguaggi di Programmazione

(20)

ST Operators (a)

(21)

ST Operators (b)

(22)

Functional Block Language

סּ Funktionsblocksprache, Langage de blocs de

fonction.

סּ Also called "Function Chart" or "Function Plan" – FuPla סּ The function block languages express "combinatorial”

programs in a way similar to electronic circuits.

סּ They draw on a large variety of predefined and custom

functions

(23)

Function Block Examples

& A B C Example 1: Trigger T &

Example 2: external inputs external outputs

Function blocks is a graphical programming language, which is akin to the electrical and block diagrams of the analog and digital technique.

It mostly expresses combinatorial logic, but its blocks may have a memory (e.g. flip-flops). Trigger T & Running Reset S R Spin

(24)

Function Block Elements

The block is defined by its:

"continuously" executing block, independent, no side effects set point measurement motor parameters Function block Example PID

The block is defined by its:

• Data flow interface (number and type of input/output signals) • Black-Box-Behavior (functional semantic, e.g. in textual form). Connections that carry a pseudo-continuous data flow.

Connects the function blocks.

Signals

(set point) (set point) set point

Example

(25)

Function Block Example

(26)

Rule of evaluation

סּ Each signal is connected to exactly one source

– This source can be the output of a function block or a plant signal. סּ The type of the output pin, the type of the input pin and the

signal type.

סּ The signals flow from left to right and from top to bottom.

סּ Feedback is an exception: the signal direction is from right to סּ Feedback is an exception: the signal direction is from right to

the left, and it is identified by an arrow

C. Fantuzzi 26 a b y x z c

(27)

Ladder Diagram

סּ (Kontaktplansprache, langage à contacts)

סּ The ladder logic is the oldest programming language for

PLC

סּ it bases directly on the relay intuition of the electricians. סּ it is widely in use outside Europe.

סּ it is widely in use outside Europe.

סּ It is described here but not recommended for new

projects.

(28)

Ladder Logic (1)

01 02 03 50 relay coil (bobine) break contact make contact origin: electrical circuit break contact (contact repos) 01 02 50 03 corresponding ladder diagram 50 05 44 rung

"coil" 50 is used to move other contact(s)

(29)

Ladder logic (2)

The contact plan or "ladder logic" language allows an easy transition from the traditional relay logic diagrams to the programming of binary functions.

It is well suited to express combinational logic

It is not suited for process control programming (there are no analog elements).

The main ladder logic symbols represent the elements: The main ladder logic symbols represent the elements:

make contact break contact relay coil contact travail contact repos bobine Arbeitskontakt Ruhekontakt Spule

(30)

Ladder logic (3)

Binary combinations are expressed by series and parallel relay contact:

+ 01 02

50

Coil 50 is active (current flows) when 01 is active and 02 is not. 01

02 50

Series

ladder logic representation "CMOS" equivalent

+ 01

40 02

Coil 40 is active (current flows) when 01 is active or 02 is not. Parallel

01

02 40

C. Fantuzzi 3. I Linguaggi di 30

(31)

Ladder logic (4)

The ladder logic is more intuitive for complex binary expressions than literal languages textual expressions

%50 1 2 3 4 5 6 !N 1 & 2 STR 3 & N 4 STR N 5 & 6 / STR & STR = %50 %50 0 1 4 5 6 7 2 3 10 11 12 !0 & 1 STR 2 & 3 / STR STR 4 & 5 STR N 6 & 7 / STR & STR STR 10 & 11 / STR & 12 = %50

(32)

Ladder logic (5)

Ladder logic stems from the time of the relay technology.

As PLCs replaced relays, their new possibilities could not be expressed any more in relay terms.

The contact plan language was extended to express functions:

literal expression: !00 & 01 FUN 02 = 200 200 FUN 02 01 00 !00 & 01 FUN 02 = 200

The intuition of contacts and coil gets lost.

The introduction of «functions» that influence the control flow itself, is problematic. The contact plan is - mathematically - a functional representation.

The introduction of a more or less hidden control of the flow destroys the freedom of side effects and makes programs difficult to read.

Riferimenti

Documenti correlati

// lettura ingressi analogici //11 cicli di ADC clock = 16.5us. sensore_posizione

La disciplina in esame è, infatti, regolata in modo che gli effetti determinati dalla non operatività di una società influiscano, dal punto di vista della base

Then, among the BBHs exclusively detected by the BLASTp (2610 matches) and by the tBLASTx (2561 matches) methods, we considered the cases in which the same Arabidopsis gene found

Passando ai centri abitati si deve ricor- dare che le città nascono sempre dalla pau- sa o dall’incontro di più flussi: strade, corsi d’acqua, approdi… Quella

Attraverso le lezioni di giornalisti esperti del mondo della scuola vengono forniti agli studenti gli strumenti per realizzare articoli, interviste e video per

•  PA0 test production @ Taiyo can start as soon as we sign-off the production drawings produced by Taiyo &amp; circulated on Tue.. –  Markus or someone else can carefully

Requirement 3 : Solo l’utente root può : Solo l’utente root può alterare l’accesso alle informazioni per alterare l’accesso alle informazioni per accedere ad un role