Вы находитесь на странице: 1из 15

#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 61131-


61131-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 61131-


61131-3 Compliance?
Compliance?

A PLC-
PLC-system, as defined in IEC 61131-
61131-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 61131-


61131-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
Brew Water
Ready
Ground Full
Boil
Hot Coffee
Finished Grind

Page 5

Walkthrough - Coffee Maker

States of a Coffee Maker

water
Hot

water
Full
coffee
Ground

machine coffee
Ready 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 Grind
Water Coffee

Brew
Coffee

Page 7

Walkthrough - Coffee Maker

Init
State Machine with SFC
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 61131-
61131-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 Structured Text Continuous Function Chart


LD A
ANDN B C:= A AND NOT B
ST C

Function Block Diagram Ladder Diagram Sequential Function Chart

AND A B C
A 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 6
Graphic Structures IL
5
Simple Syntax
Complex Syntax 4

Knowledge
Complex Semantic ST
3
Functionality
2 SFC LD
Binary Expressions
Arithmetic Calculation 1 CFC
Sequential Processes
0
Parallel Processing
0 2 4 6
Non-Procedural
Functionality

Page 13

Program Organization Unit

PROGRAM PROG name FUNCTION_BLOCK FB name FUNCTION FUN name Data type

Interface variables

Local variables Declaration part

Instructions
(POU body) Instruction part

END_PROGRAM 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/ Signed integer Unsigned integer Floating point Time of day,


sequence of Duration, Date
bits and String

BOOL INT UINT REAL TIME


BYTE SINT USINT LREAL DATE
WORD DINT UDINT TIME_OF_DAY
DWORD LINT ULINT DATE_AND_TIME
LWORD 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 15

Variables and Declarations

FUNCTION_BLOCK FB name FUNCTION_BLOCK Continue


VAR_INPUT VarIn : BOOL; END_VAR (* Input *)
Interface variables VAR_OUTPUT VarOut1 : BYTE; (* Outputs *)
VarOut2 : BOOL; END_VAR
Local variables VAR VarLocal : BYTE; END_VAR (* State value *)

Instructions LD VarIn
...
(POU body) LD VarLocal
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 Oper. Modifiers [1] Operand Semantics
LD N [2] Set current result equal to operand
ST N [2] Store current result to operand location
S BOOL [3] Set Boolean operand to 1
R BOOL [3] Set Boolean operand to 0
AND N,( BOOL [7] Boolean AND
OR N,( BOOL [7] Boolean OR
XOR N,( BOOL [7] Boolean Exclusive OR
ADD ( [2] Addition
SUB ( [2] Subtraction
MUL ( [2] Multiplication
DIV ( [2] Division
JMP C,N[3] LABEL [4] Jump to label
CAL C,N[3] NAME Call function block.
RET C,N[3] Return from called function or function block
GT ( [6] Comparison:
Comparison: >
GE ( [6] Comparison:
Comparison: >=
LE ( [6] Comparison:
Comparison: <=
LT ( [6] Comparison:
Comparison: <
EQ ( [6] Comparison:
Comparison: =
NE ( [6] Comparison:
Comparison: <>
) [2] Evaluate deferred operation
Page 18

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


#1412-WS-02 OEM Solution Workshop Saturday, 27 March 2004

Languages & Editors

Structured Text (1)

High Level Language


Block Structured
Syntax Resembles PASCAL
Complex Statements and nested
instructions possible
C:= A AND NOT B
Support for
Iteration loops
(REPEAT-UNTIL; WHILE-DO)
Conditional execution
(IF-THEN-ELSE; CASE)
Functions (SQRT(), SIN())

Page 19

Languages & Editors

Structured Text (2)


if IN < X[1] then
OUT := Y[1] + ( IN - X[1] ) * ( Y[2]-
Y[2]-Y[1] ) / ( X[2] - X[1] );
else
if IN > X[n] then m := n - 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]);
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 A B C
-| |--|/|----------------( )
Non-
Non-Binary Logic
Macro Contacts to
Place Function Blocks
Within the Network

Online Powerflow

Page 21

Languages & Editors

Ladder - Complex Arithmetic Operations

comparison assignment

contact

arithmetic
conditional

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

Dataflow-
Dataflow-Oriented
Modelling & Design 0001 S tartNetwork:
(* Network c omme nt *)

Electronics Design Function


VarAnd1 Function block
Paradigm AND Counte r_1
Output variable
Value transmission CTU
Composition VarAnd2 VarOut
CU Q
of Functional Var_Ini
R CV
Units & Items 1000
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
Operations to be performed
Sequences
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 steps
3)

Alternativ steps

Merging 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


Sequential Function Charts
Continuous Function Charts
Graphical Languages
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 Header byte2...

and byte2
...byte2 byte1 uint1
shl uint1
st byte1
END_PROGRAM

Page 29

Compiler & Code Generation

CFE
Make Generator and Bibliothek Editors

Resource
IEC 61131-3
Interpreter Configuration

CFG Instruction List

Compiler Frontend & CFE: Compiler Front End


Sources

Library

Compiler Backend ICODE


ICODE
ICODE ICODE LIB
Function
Program Funct.block

Linker & Systembuilder CBE: Compiler Back End


Library

Native Code (optional) Configuration


UCODE
ICODE
ICODE
UCODE

Program Function
Funct.block

Execution of Applications Linker


Native
Code

in SmartPLC or Target UCODE-CRD Symbol Ncode


table
UCODE-Executable

Resource - Builder

Loadable
UCODE + NCODE

Page 30

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

Вам также может понравиться