Programming Control. Strategies. with IEC A short History of IEC B Walkthrough C Languages. D Compiler

#1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 Programming Control Strategies with IEC 61131 A Short History of IEC 61131-3 B Walkthrough...
Author: Ariel Lloyd
0 downloads 0 Views 138KB Size
#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Programming Control Strategies with IEC 61131 A Short History of IEC 61131-3 B Walkthrough C Languages 1 Organization 2 Textual Languages 3 Graphic Languages

D Compiler

Page 1

A short History of IEC 6113161131-3 Year

International standard

1977

IEC 848

1979

Start of the first working group

1982

Finalizing of the first draft of the IEC 61131; Division in 5 sub working groups

1983

Christensen Report on PLC-programming languages

1985

First results of the IEC 65 A WG6 TF3

1990

IEC 61131 part 1 and 2 become a standard

1992

International standard IEC 61131-1,2

1993

International standard IEC 61131-3

1995

International standard IEC 61131-4

1994 - 1999

Corrigendum for IEC 61131-3

1995 - 1996

Technical Reports type 2 and 3

1996 - 1999

Amendments

Page 2

(C) 2003 infoteam Software +49-9131-78 000

1

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

What is IEC 6113161131-3 Compliance? Compliance?

A PLCPLC-system, as defined in IEC 6113161131-1, which claims to comply, wholly or partially, with the requirements of this part of the IEC 61131 standard shall only do so if it states: "This system complies with the requirements of IEC 6113161131-3, for the following language features“ followed by a set of tables

Page 3

Walkthrough - Coffee Maker „

Terms of a Coffee Maker

„

States of a Coffee Maker

„

Actions of a Coffee Maker

„

State Machine with SFC

„

Sequential Function Chart OpenPCS

„

Add a Ladder Task for Coffee Maker

Page 4

(C) 2003 infoteam Software +49-9131-78 000

2

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Walkthrough - Coffee Maker

Terms of a Coffee Maker Fill Water Ready

Brew

Hot

Ground Boil

Full

Finished Grind

Coffee

Page 5

Walkthrough - Coffee Maker

States of a Coffee Maker water

Hot

water

Full

coffee

Ground machine

Ready

coffee

Finished

Page 6

(C) 2003 infoteam Software +49-9131-78 000

3

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Walkthrough - Coffee Maker

Actions of a Coffee Maker Fill Water Boil Water

Grind Coffee

Brew Coffee

Page 7

Walkthrough - Coffee Maker

State Machine with SFC

Init Ready

Fill Water Full

Boil Water

Grind Coffee Hot and Ground

Brew Coffee Finished Init Page 8

(C) 2003 infoteam Software +49-9131-78 000

4

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Walkthrough - Coffee Maker

Control Strategy with Sequential Function Chart

Page 9

Walkthrough - Coffee Maker

Add a Ladder Task for Coffee Maker

Page 10

(C) 2003 infoteam Software +49-9131-78 000

5

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Languages & Editors

„

IEC 6113161131-3 Languages

‰ Declarations

and Variables

‰ Instruction

List

‰ Structured

Text

‰ Ladder

Diagram

‰ Function

Block Diagram

‰ Sequential

Function Chart

Page 11

Languages & Editors Programming Languages Instruction List LD

A

ANDN

B

ST

C

C:= A AND NOT B

Function Block Diagram AND A

Continuous Function Chart

Structured Text

Ladder Diagram A B

C

Sequential Function Chart C

-| |--|/|----------------( )

B

Page 12

(C) 2003 infoteam Software +49-9131-78 000

6

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Languages & Editors Languages & Methods

„

Knowledge to use ‰

Simple Pick & Place

‰

Graphic Structures

‰

Simple Syntax

‰

Complex Syntax

‰

Complex Semantic

6

IL

5

Knowledge

„

Functionality ‰

Binary Expressions

‰

Arithmetic Calculation

‰

Sequential Processes

‰

Parallel Processing

‰

Non-Procedural

4

ST

3 2

SFC

LD

1

CFC

0 0

2

4

6

Functionality

Page 13

Program Organization Unit

PROGRAM PROG name FUNCTION_BLOCK FB name

FUNCTION FUN name Data type

Interface variables

END_PROGRAM

Local variables

Declaration part

Instructions (POU body)

Instruction part

END_FUNCTION_BLOCK

END_FUNCTION

Page 14

(C) 2003 infoteam Software +49-9131-78 000

7

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Data Types: Types: Elementary and Complex

Binary/ sequence of bits

Signed integer

Unsigned integer

Floating point

Time of day, Duration, Date and String

BOOL BYTE WORD DWORD LWORD

INT SINT DINT LINT

UINT USINT UDINT ULINT

REAL LREAL

TIME DATE TIME_OF_DAY DATE_AND_TIME STRING

Property

Ident.

Meaning

Initial value

initial

A specific initial value is assigned to the variable.

Enumeration

enum

The variable can assume a value out of a value list.

Range specification

range

The variable can assume values within the specified range.

Array limits

array

Data structure

structure

Several elements of the same data type are grouped in an array. Accessing the array variable the maximally allowed index value must not be exceeded. Several data types are grouped to one data type. The access to a certain variable of this structure is to be made using a dot and the name of the component. Page 15

Variables and Declarations

FUNCTION_BLOCK FB name

FUNCTION_BLOCK

Continue

Interface variables

VAR_INPUT VarIn : BOOL; END_VAR VAR_OUTPUT VarOut1 : BYTE;

Local variables

VAR

Instructions (POU body)

LD VarIn ... LD VarLocal

(* Input *) (* Outputs *)

VarOut2 : BOOL; END_VAR VarLocal : BYTE; END_VAR (* State value *)

ST VarOut1 ... ST VarOut2 END_ FUNCTION_BLOCK

END_ FUNCTION_BLOCK

Page 16

(C) 2003 infoteam Software +49-9131-78 000

8

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Languages & Editors Instruction List (1) „

Single Accumulator Based Execution Model

„

Based on the German ‘Anweisungsliste’ AWL LD

A

„

One Operation per Line

ANDN

B

Defines a Virtual Machine Model

ST

C

„

Page 17

Languages & Editors Instruction List (2) No LD ST

Oper. N N

S R

Modifiers [1] Operand Semantics [2] Set current result equal to operand [2] Store current result to operand location BOOL [3] BOOL [3]

Set Boolean operand to 1 Set Boolean operand to 0

AND OR XOR

N,( N,( N,(

BOOL [7] BOOL [7] BOOL [7]

Boolean AND Boolean OR Boolean Exclusive OR

ADD SUB MUL DIV

( ( ( (

[2] [2] [2] [2]

Addition Subtraction Multiplication Division

JMP CAL RET

C,N[3] C,N[3] C,N[3]

LABEL [4] Jump to label NAME Call function block. Return from called function or function block

GT GE LE LT EQ NE )

( ( ( ( ( (

[6] [6] [6] [6] [6] [6] [2]

Comparison: Comparison: > Comparison: Comparison: >= Comparison: Comparison: X[n] then m := n - 1; OUT:=Y[n]+(INOUT:=Y[n]+(IN-X[n])*(Y[n]X[n])*(Y[n]-Y[m])/(X[n]Y[m])/(X[n]-X[m]); else repeat i:=i+1; until IN >= X[i] end_repeat end_repeat;; j := i + 1; OUT := Y[1] + ( IN - X[i] )*( Y[j]Y[j]-Y[i] ) / ( X[j]X[j]-X[i] ); end_if end_if;; end_if end_if;;

Page 20

(C) 2003 infoteam Software +49-9131-78 000

10

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Languages & Editors Ladder Diagrams „

US Look&Feel Look&Feel ‰

Comments in Declaration Section and Implementation Section

„

Control Relays

„

NonNon-Binary Logic ‰

„

A B

C

-| |--|/|----------------( )

Macro Contacts to Place Function Blocks Within the Network

Online Powerflow

Page 21

Languages & Editors Ladder - Complex Arithmetic Operations comparison

assignment

contact

conditional

arithmetic

Page 22

(C) 2003 infoteam Software +49-9131-78 000

11

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Languages & Editors Function Block Diagrams

„

DataflowDataflow-Oriented Modelling & Design

„

0001

S tartNetwork:

(* Network c omme nt *)

Electronics Design

Function

Paradigm

VarAnd1

Composition

VarAnd2

Counte r_1

AND

Output variable

Value transmission „

CTU CU

of Functional

Var_Ini

Units & Items

1000

Function block

R

Q

VarOut

CV

PV

Negation of binary function inputs and outputs

Page 23

Languages & Editors Function Block Diagrams „

Function Block Pick & Place

„

Autorouting

„

Block Hierachy

„

Parameters

„

Type Checking

„

Page Layout

„

Import of Prototypes

Page 24

(C) 2003 infoteam Software +49-9131-78 000

12

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Languages & Editors Sequential Function Chart „

Steps ‰

„

Contain the Actions to be Performed

Transitions ‰

Conditions to Pass control to the next step

„

Actions

„

Sequences

‰

‰

„

Operations to be performed Simultaneous Sequences or Sequence selection

Jumps ‰

Iteration of Enclosed Section

Page 25

Languages & Editors Sequential Function Charts „

Sequencing Functionality

1) FALS E

‰ (Initial)

Step

‰ Transitions ‰ Simultaneous ‰ Alternativ ‰ Merging

steps

3)

steps

of Paths

5) FALSE

‰ Jumps

FALSE

Page 26

(C) 2003 infoteam Software +49-9131-78 000

13

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Languages & Editors Libraries of Function Blocks & Functions „

Prototypes IEC 1131-3 standard OEM specific ‰ user global ‰ application specific ‰ ‰

„

Language independend

Page 27

Languages & Editors „

Design & Configuration ‰ ‰

„

Graphical Languages ‰ ‰

„

Sequential Function Charts Continuous Function Charts Incremental Compilers Translated to IL

IL Portability

Page 28

(C) 2003 infoteam Software +49-9131-78 000

14

#1412-WS-02 OEM Solution Workshop

Saturday, 27 March 2004

Compiler & Code Generation Graphic Î IL Î UCODE Î Native Code PROGRAM EXAMPLE VAR byte1 : BYTE ; byte2 AT %IB0.2 : BYTE ; uint1 : uint :=1 ; END_VAR ld byte1 and byte2 shl uint1 st byte1 END_PROGRAM

Header

...byte2

byte2...

byte1

uint1

Page 29

Compiler & Code Generation „

Make Generator and

Bibliothek

CFE

Editors

Resource

Interpreter

IEC 61131-3

Configuration

CFG

„

Compiler Frontend &

Instruction List Sources

CFE: Compiler Front End

Compiler Backend

ICODE ICODE ICODE

ICODE

„

„

Native Code (optional)

Library

CBE: Compiler Back End

Configuration

ICODE ICODE UCODE

UCODE Program

„

LIB

Function Funct.block

Program

Linker & Systembuilder

Library

Execution of Applications

Function Funct.block Native Code

Linker

in SmartPLC or Target

UCODE-CRD

Symbol table

Ncode

UCODE-Executable

Resource - Builder

UCODE + NCODE

Loadable

Page 30

(C) 2003 infoteam Software +49-9131-78 000

15