#1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004
(C) 2003 infoteam Software +49-9131-78 000 1
Page 1 Programming Programming C Control ontrol S Strategies trategies with IEC 61131 with IEC 61131 AShort History of IEC 61131-3 B Walkthrough C Languages 1 Organization 2 Textual Languages 3 Graphic Languages D Compiler Page 2 A A short History short History of IEC 61131 of IEC 61131- -3 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 #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 2 Page 3 What is What is IEC 61131 IEC 61131- -3 3 Compliance Compliance? ? A PLC A PLC- -system, as defined in IEC system, as defined in IEC 61131 61131- -1, which claims to 1, which claims to comply, wholly or partially, with the requirements of this comply, wholly or partially, with the requirements of this part of the IEC 61131 standard shall only do so if it states: part of the IEC 61131 standard shall only do so if it states: "This system complies with the requirements of IEC "This system complies with the requirements of IEC 61131 61131- -3, 3, for the following language features for the following language features followed by a set of tables followed by a set of tables Page 4 Walkthrough Walkthrough - - Coffee Maker Coffee Maker Terms of a Terms of a Coffee Maker Coffee Maker States States of a of a Coffee Maker Coffee Maker Actions Actions of a of a Coffee Maker Coffee Maker State State Machine with Machine with SFC SFC Sequential Function Sequential Function Chart OpenPCS Chart OpenPCS Add Add a a Ladder Task for Coffee Maker Ladder Task for Coffee Maker #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 3 Page 5 Terms of a Terms of a Coffee Maker Coffee Maker Brew Brew Fill Fill Full Full Hot Hot Grind Grind Boil Boil Ready Ready Ground Ground Water Water Coffee Coffee Finished Finished Walkthrough Walkthrough - - Coffee Maker Coffee Maker Page 6 Walkthrough Walkthrough - - Coffee Maker Coffee Maker States States of a of a Coffee Maker Coffee Maker water water Full Full machine machine Ready Ready water water Hot Hot coffee coffee Ground Ground coffee coffee Finished Finished #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 4 Page 7 Walkthrough Walkthrough - - Coffee Maker Coffee Maker Actions Actions of a of a Coffee Maker Coffee Maker Fill Fill Water Water Boil Boil Water Water Grind Grind Coffee Coffee Brew Brew Coffee Coffee Page 8 Walkthrough Walkthrough - - Coffee Maker Coffee Maker Init Fill Water Boil Water Brew Coffee Grind Coffee Ready Full Hot and Ground Finished Init State State Machine with Machine with SFC SFC #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 5 Page 9 Walkthrough Walkthrough - - Coffee Maker Coffee Maker Control Strategy with Control Strategy with Sequential Function Sequential Function Chart Chart Page 10 Add Add a a Ladder Task for Coffee Maker Ladder Task for Coffee Maker Walkthrough Walkthrough - - Coffee Maker Coffee Maker #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 6 Page 11 Languages Languages & Editors & Editors IEC 61131 IEC 61131- -3 3 Languages Languages Declarations and Variables Instruction List Structured Text Ladder Diagram Function Block Diagram Sequential Function Chart Page 12 Programming Languages Programming Languages Instruction List Structured Text Function Block Diagram Ladder Diagram LD A ANDN B ST C C:=A AND NOT B A B C -| |--|/|----------------( ) AND A C B Sequential Function Chart Continuous Function Chart Languages Languages & Editors & Editors #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 7 Page 13 Languages Languages & & Methods Methods Knowledge Knowledge to to use use Simple Pick & Place Graphic Structures Simple Syntax Complex Syntax Complex Semantic Functionality Functionality Binary Expressions Arithmetic Calculation Sequential Processes Parallel Processing Non-Procedural 0 1 2 3 4 5 6 0 2 4 6 Functionality K n o w l e d g e ST ST LD LD IL IL SFC SFC CFC CFC Languages Languages & Editors & Editors Page 14 Program Organization Program Organization Unit Unit PROGRAM PROG name END_PROGRAM FUNCTION_BLOCK FB name END_FUNCTION_BLOCK Instructions (POU body) FUNCTION FUN name END_FUNCTION Data type Interface variables Declaration part Instruction part Local variables #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 8 Page 15 Data Types Data Types: : Elementary Elementary and and Complex 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 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. Data structure structure 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 16 Variables and Variables and Declarations Declarations VarIn : BOOL; END_VAR LD VarIn ST VarOut1 ... FUNCTION_BLOCK FB name Instructions (POU body) Interface variables Local variables FUNCTION_BLOCK Continue VarOut1 : BYTE; VAR_OUTPUT VAR_INPUT VAR VarOut2 : BOOL; END_VAR VarLocal : BYTE; END_VAR ST VarOut2 ... (* Input *) (* Outputs *) (* State value *) END_FUNCTION_BLOCK END_FUNCTION_BLOCK LD VarLocal #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 9 Page 17 Instruction Instruction List (1) List (1) Single Single Accumulator Based Execution Accumulator Based Execution Model Model Based Based on on the the German Anweisungsliste AWL German Anweisungsliste AWL One Operation per Line One Operation per Line Defines Defines a a Virtual Machine Virtual Machine Model Model LD A ANDN B ST C Languages Languages & Editors & Editors Page 18 Instruction Instruction List (2) List (2) No No Oper. Oper. Modifiers Modifiers [1] [1] Operand Operand Semantics Semantics LD LD N N [2] [2] Set Set current result equal current result equal to to operand operand ST ST N N [2] [2] Store Store current result current result to to operand location operand location S S BOOL [3] BOOL [3] Set Set Boolean operand Boolean operandto 1 to 1 R R BOOL [3] BOOL [3] Set Set Boolean operand Boolean operandto 0 to 0 AND AND N,( N,( BOOL [7] BOOL [7] Boolean BooleanAND AND OR OR N,( N,( BOOL [7] BOOL [7] Boolean BooleanOR OR XOR XOR N,( N,( BOOL [7] BOOL [7] Boolean Exclusive Boolean ExclusiveOR OR ADD ADD ( ( [2] [2] Addition Addition SUB SUB ( ( [2] [2] Subtraction Subtraction MUL MUL ( ( [2] [2] Multiplication Multiplication DIV DIV ( ( [2] [2] Division Division J MP J MP C,N[3] C,N[3] LABEL [4] LABEL [4] J ump J umpto to label label CAL CAL C,N[3] C,N[3] NAME NAME Call function Call functionblock. block. RET RET C,N[3] C,N[3] Return Return from called function or function from called function or function block block GT GT ( ( [6] [6] Comparison Comparison: > : > GE GE ( ( [6] [6] Comparison Comparison: >= : >= LE LE ( ( [6] [6] Comparison Comparison: <= : <= LT LT ( ( [6] [6] Comparison Comparison: < : < EQ EQ ( ( [6] [6] Comparison Comparison: = : = NE NE ( ( [6] [6] Comparison Comparison: <> : <> ) ) [2] [2] Evaluate deferred operation Evaluate deferred operation Languages Languages & Editors & Editors #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 10 Page 19 Structured Structured Text (1) Text (1) High Level High Level Language Language Block Block Structured Structured Syntax Syntax Resembles Resembles PASCAL PASCAL Complex Complex Statements and Statements and nested nested instructions possible instructions possible Support Support for for Iteration loops (REPEAT-UNTIL; WHILE-DO) Conditional execution (IF-THEN-ELSE; CASE) Functions (SQRT(), SIN()) C:=A AND NOT B Languages Languages & Editors & Editors Page 20 if if IN <X[1] IN <X[1] then then OUT :=Y[1] +( IN OUT :=Y[1] +( IN - -X[1] ) * ( Y[2] X[1] ) * ( Y[2]- -Y[1] ) / ( X[2] Y[1] ) / ( X[2] - -X[1] ); X[1] ); else else if if IN >X[n] IN >X[n] then then m:=n m:=n - -1; 1; OUT:=Y[n]+(IN OUT:=Y[n]+(IN- -X[n])*(Y[n] X[n])*(Y[n]- -Y[m])/ (X[n] Y[m])/ (X[n]- -X[m]); X[m]); else else repeat repeat i:=i+1; i:=i+1; until until IN >=X[i] IN >=X[i] end_ end_repeat repeat; ; j :=i +1; j :=i +1; OUT :=Y[1] +( IN OUT :=Y[1] +( IN - -X[i] )*( Y[j] X[i] )*( Y[j]- -Y[i] ) / ( X[j] Y[i] ) / ( X[j]- -X[i] ); X[i] ); end_ end_if if; ; end_ end_if if; ; Structured Structured Text (2) Text (2) Languages Languages & Editors & Editors #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 11 Page 21 Ladder Ladder Diagrams Diagrams US Look& US Look&Feel Feel Comments in Declaration Section and Implementation Section Control Relays Control Relays Non Non- -Binary Logic Binary Logic Macro Contacts to Place Function Blocks Within the Network Online Online Powerflow Powerflow Languages Languages & Editors & Editors A B C -| |--|/|----------------( ) Page 22 Ladder Ladder - - Complex Arithmetic Operations Complex Arithmetic Operations comparison assignment arithmetic conditional contact Languages Languages & Editors & Editors #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 12 Page 23 Function Function Block Diagrams Block Diagrams Dataflow Dataflow- -Oriented Oriented Modelling & Design Modelling & Design Electronics Design Electronics Design Paradigm Paradigm C Composition omposition of Functional of Functional Units & Items Units & Items Languages Languages & Editors & Editors 0001 (* Network comment *) StartNetwork: AND VarAnd1 VarAnd2 1000 VarOut Function Negation of binary function inputs and outputs Output variable Value transmission CU CTU Q PV CV R Var_Ini Counter_1 Function block Page 24 Function Function Block Diagrams Block Diagrams Function Function Block Block Pick & Pick & Place Place Autorouting Autorouting Block Block Hierachy Hierachy Parameters Parameters Type Type Checking Checking Page Layout Page Layout Import of Import of Prototypes Prototypes Languages Languages & Editors & Editors #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 13 Page 25 Sequential Function Sequential Function Chart Chart Steps Steps Contain the Actions to be Performed Transitions Transitions Conditions to Pass control to the next step Actions Actions Operations to be performed Sequences Sequences Simultaneous Sequences or Sequence selection Jumps Jumps Iteration of Enclosed Section Languages Languages & Editors & Editors Page 26 Sequential Function Sequential Function Charts Charts Sequencing Functionality Sequencing Functionality (Initial) Step Transitions Simultaneous steps Alternativ steps Merging of Paths Jumps Languages Languages & Editors & Editors FALS E 1) FALSE 3) FALSE 5) #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 14 Page 27 Libraries Libraries of of Function Function Blocks & Blocks & Functions Functions Prototypes Prototypes IEC 1131-3 standard OEM specific user global application specific Language Language independend independend Languages Languages & Editors & Editors Page 28 Design & Configuration Design & Configuration Sequential Function Charts Continuous Function Charts Graphical Languages Graphical Languages Incremental Compilers Translated to IL IL Portability IL Portability Languages Languages & Editors & Editors #1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004 (C) 2003 infoteam Software +49-9131-78 000 15 Page 29 Graphic Graphic IL IL UCODE UCODE Native Code Native Code PROGRAM EXAMPLE VAR byt e1 : BYTE ; byt e2 AT %I B0. 2 : BYTE ; ui nt 1 : ui nt : =1 ; END_VAR l d byt e1 and byt e2 shl ui nt 1 st byt e1 END_PROGRAM Header byt e2. . . . . . byt e2 ui nt 1 byt e1 Compiler & Code Generation Compiler & Code Generation Page 30 Bibliothek CFE Editors IEC 61131-3 Resource Configuration Library Instruction List LIB CFE: Compiler Front End Library Function Funct.block Configuration Sources Loadable Linker Resource - Builder Symbol table CBE: Compiler Back End ICODE ICODE ICODE ICODE Program ICODE ICODE UCODE UCODE Program Function Funct.block UCODE-CRD UCODE-Executable CFG UCODE + NCODE Native Code Ncode Compiler & Code Generation Compiler & Code Generation Make Make Generator and Generator and Interpreter Interpreter Compiler Compiler Frontend Frontend & & Compiler Backend Compiler Backend Linker & Linker & Systembuilder Systembuilder Native Code (optional) Native Code (optional) Execution Execution of of Applications Applications in in SmartPLC or Target SmartPLC or Target