15
Page 1 Programming Programming Control ontrol S trategies 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 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

i Ec Control Strategy

Embed Size (px)

Citation preview

Page 1: i Ec Control Strategy

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

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

Page 1

Programming Programming CControlontrol SStrategiestrategies 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 61131of IEC 61131--33

Year International standard1977 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-31995 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: i Ec Control Strategy

#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 61131IEC 61131--3 3 ComplianceCompliance??

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

WalkthroughWalkthrough -- Coffee MakerCoffee Maker

Terms of aTerms of a Coffee MakerCoffee Maker

StatesStates of aof a Coffee MakerCoffee Maker

ActionsActions of aof a Coffee MakerCoffee Maker

StateState Machine withMachine with SFCSFC

Sequential FunctionSequential Function Chart OpenPCSChart OpenPCS

AddAdd aa Ladder Task for Coffee MakerLadder Task for Coffee Maker

Page 3: i Ec Control Strategy

#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 MakerCoffee Maker

BrewBrew

FillFill

FullFull

HotHotGrindGrind

BoilBoil

ReadyReady

GroundGround

WaterWater

CoffeeCoffeeFinishedFinished

WalkthroughWalkthrough -- Coffee MakerCoffee Maker

Page 6

WalkthroughWalkthrough -- Coffee MakerCoffee Maker

StatesStates of a of a Coffee MakerCoffee Maker

waterwater

FullFull

machinemachine

ReadyReady

waterwater

HotHot

coffeecoffee

GroundGround

coffeecoffee

FinishedFinished

Page 4: i Ec Control Strategy

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

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

Page 7

WalkthroughWalkthrough -- Coffee MakerCoffee Maker

ActionsActions of a of a Coffee MakerCoffee Maker

FillFillWaterWater

BoilBoilWaterWater

GrindGrindCoffeeCoffee

BrewBrewCoffeeCoffee

Page 8

WalkthroughWalkthrough -- Coffee MakerCoffee Maker

Init

Fill Water

Boil Water

Brew Coffee

Grind Coffee

Ready

Full

Hot and Ground

Finished

Init

State State Machine withMachine with SFCSFC

Page 5: i Ec Control Strategy

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

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

Page 9

WalkthroughWalkthrough -- Coffee MakerCoffee Maker

Control Strategy with Control Strategy with Sequential FunctionSequential Function ChartChart

Page 10

AddAdd a a Ladder Task for Coffee MakerLadder Task for Coffee Maker

WalkthroughWalkthrough -- Coffee MakerCoffee Maker

Page 6: i Ec Control Strategy

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

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

Page 11

LanguagesLanguages & Editors& Editors

IEC 61131IEC 61131--33 LanguagesLanguages

Declarations and Variables

Instruction List

Structured Text

Ladder Diagram

Function Block Diagram

Sequential Function Chart

Page 12

Programming LanguagesProgramming Languages

Instruction List Structured Text

Function Block Diagram Ladder Diagram

LD A

ANDN B

ST C

C:= A AND NOT B

A B C

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

ANDA C

B

Sequential Function Chart

Continuous Function Chart

LanguagesLanguages & Editors& Editors

Page 7: i Ec Control Strategy

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

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

Page 13

LanguagesLanguages & & MethodsMethodsKnowledgeKnowledge to to useuse

Simple Pick & Place

Graphic Structures

Simple Syntax

Complex Syntax

Complex Semantic

FunctionalityFunctionalityBinary Expressions

Arithmetic Calculation

Sequential Processes

Parallel Processing

Non-Procedural

0

1

2

3

4

5

6

0 2 4 6

FunctionalityK

now

ledg

e

STST

LDLD

ILIL

SFCSFC

CFCCFC

LanguagesLanguages & Editors& Editors

Page 14

Program Organization Program Organization UnitUnit

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

Page 8: i Ec Control Strategy

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

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

Page 15

Data TypesData Types: : Elementary Elementary and and ComplexComplex

Binary/ sequence of bits

Signed integer Unsigned integer Floating point Time of day, Duration, Date and String

BOOLBYTEWORDDWORDLWORD

INTSINTDINTLINT

UINTUSINTUDINTULINT

REALLREAL

TIMEDATETIME_OF_DAYDATE_AND_TIMESTRING

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 DeclarationsDeclarations

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_OUTPUTVAR_INPUT

VARVarOut2 : BOOL; END_VARVarLocal : BYTE; END_VAR

ST VarOut2...

(* Input *)(* Outputs *)

(* State value *)

END_FUNCTION_BLOCK END_FUNCTION_BLOCK

LD VarLocal

Page 9: i Ec Control Strategy

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

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

Page 17

InstructionInstruction List (1)List (1)

Single Single Accumulator Based ExecutionAccumulator Based Execution ModelModel

BasedBased on on thethe German ‘Anweisungsliste’ AWLGerman ‘Anweisungsliste’ AWL

One Operation per LineOne Operation per Line

DefinesDefines a a Virtual MachineVirtual Machine ModelModel

LD A

ANDN B

ST C

LanguagesLanguages & Editors& Editors

Page 18

InstructionInstruction List (2)List (2)

NoNo Oper.Oper. ModifiersModifiers [1][1] OperandOperand SemanticsSemanticsLD LD NN [2] [2] Set Set current result equalcurrent result equal to to operandoperandST ST NN [2] [2] Store Store current resultcurrent result to to operand locationoperand location

SS BOOL [3] BOOL [3] Set Set Boolean operandBoolean operand to 1to 1RR BOOL [3] BOOL [3] Set Set Boolean operandBoolean operand to 0to 0

ANDAND N,(N,( BOOL [7] BOOL [7] BooleanBoolean ANDANDOR OR N,(N,( BOOL [7] BOOL [7] BooleanBoolean ORORXORXOR N,(N,( BOOL [7] BOOL [7] Boolean ExclusiveBoolean Exclusive OROR

ADDADD (( [2] [2] AdditionAdditionSUBSUB (( [2] [2] SubtractionSubtractionMULMUL (( [2] [2] MultiplicationMultiplicationDIVDIV (( [2] [2] DivisionDivision

JMPJMP C,N[3]C,N[3] LABEL [4]LABEL [4] JumpJump to to labellabelCALCAL C,N[3]C,N[3] NAME NAME Call functionCall function block.block.RETRET C,N[3]C,N[3] Return Return from called function or function from called function or function blockblock

GTGT (( [6] [6] ComparisonComparison: >: >GEGE (( [6] [6] ComparisonComparison: >=: >=LELE (( [6] [6] ComparisonComparison: <=: <=LTLT (( [6] [6] ComparisonComparison: <: <EQEQ (( [6] [6] ComparisonComparison: =: =NENE (( [6] [6] ComparisonComparison: <>: <>) ) [2] [2] Evaluate deferred operationEvaluate deferred operation

LanguagesLanguages & Editors& Editors

Page 10: i Ec Control Strategy

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

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

Page 19

StructuredStructured Text (1)Text (1)

High Level High Level LanguageLanguageBlock Block Structured Structured Syntax Syntax ResemblesResembles PASCAL PASCAL ComplexComplex Statements and Statements and nested nested instructions possibleinstructions possibleSupport Support forfor

Iteration loops (REPEAT-UNTIL; WHILE-DO)Conditional execution (IF-THEN-ELSE; CASE) Functions (SQRT(), SIN())

C:= A AND NOT B

LanguagesLanguages & Editors& Editors

Page 20

ifif IN < X[1] IN < X[1] thenthen

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] );

elseelse

ifif IN > X[n] IN > X[n] thenthen m := n m := n -- 1;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]);X[m]);

elseelse

repeatrepeat

i:=i+1;i:=i+1;

untiluntil IN >= X[i] IN >= X[i] end_end_repeatrepeat;;

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_ifif;;

end_end_ifif;;

StructuredStructured Text (2)Text (2)

LanguagesLanguages & Editors& Editors

Page 11: i Ec Control Strategy

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

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

Page 21

LadderLadder DiagramsDiagrams

US Look&US Look&FeelFeel

Comments inDeclaration Section and Implementation Section

Control RelaysControl Relays

NonNon--Binary LogicBinary Logic

Macro Contacts toPlace Function BlocksWithin the Network

Online Online PowerflowPowerflow

LanguagesLanguages & Editors& Editors

A B C

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

Page 22

LadderLadder -- Complex Arithmetic OperationsComplex Arithmetic Operations

comparison assignment

arithmeticconditional

contact

LanguagesLanguages & Editors& Editors

Page 12: i Ec Control Strategy

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

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

Page 23

Function Function Block DiagramsBlock Diagrams

DataflowDataflow--OrientedOriented

Modelling & DesignModelling & Design

Electronics DesignElectronics Design

ParadigmParadigm

CCompositionomposition

of Functional of Functional

Units & ItemsUnits & Items

LanguagesLanguages & Editors& Editors

0001(* Network comment *)

StartNetwork:

ANDVarAnd1

VarAnd2

1000

VarOut

Function

Negation of binary functioninputs and outputs

Output variableValue transmission

CU

CTU

Q

PV

CVRVar_Ini

Counter_1Function block

Page 24

Function Function Block DiagramsBlock Diagrams

FunctionFunction BlockBlockPick & Pick & Place Place

Autorouting Autorouting

Block Block HierachyHierachy

ParametersParameters

Type Type CheckingChecking

Page LayoutPage Layout

Import of Import of PrototypesPrototypes

LanguagesLanguages & Editors& Editors

Page 13: i Ec Control Strategy

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

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

Page 25

Sequential FunctionSequential Function ChartChart

StepsStepsContain the Actions to be Performed

TransitionsTransitionsConditions to Pass controlto the next step

ActionsActionsOperations to be performed

SequencesSequencesSimultaneous Sequences orSequence selection

JumpsJumpsIteration of Enclosed Section

LanguagesLanguages & Editors& Editors

Page 26

Sequential Function Sequential Function ChartsCharts

Sequencing FunctionalitySequencing Functionality

(Initial) Step

Transitions

Simultaneous steps

Alternativ steps

Merging of Paths

Jumps

LanguagesLanguages & Editors& Editors

FALS E

1 )

FALSE

3)

FALSE

5)

Page 14: i Ec Control Strategy

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

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

Page 27

Libraries Libraries ofof FunctionFunction Blocks & Blocks & FunctionsFunctions

PrototypesPrototypesIEC 1131-3 standardOEM specificuser globalapplication specific

Language Language independendindependend

LanguagesLanguages & Editors& Editors

Page 28

Design & ConfigurationDesign & ConfigurationSequential Function ChartsContinuous Function Charts

Graphical LanguagesGraphical LanguagesIncremental CompilersTranslated to IL

IL PortabilityIL Portability

LanguagesLanguages & Editors& Editors

Page 15: i Ec Control Strategy

#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 CodeNative Code

PROGRAM EXAMPLEVAR

byte1 : BYTE ; byte2 AT %IB0.2 : BYTE ; uint1 : uint

:=1 ;END_VAR

ld byte1and byte2shl uint1st byte1

END_PROGRAM

Header byte2...

...byte2 uint1byte1

Compiler & Code GenerationCompiler & Code Generation

Page 30

Bibliothek CFE Editors

IEC 61131-3Resource Configuration

Library

Instruction List

LIB

CFE: Compiler Front End

LibraryFunctionFunct.block

Configuration

Sources

Loadable

Linker

Resource - Builder

Symbol table

CBE: Compiler Back End

ICODEICODE

ICODE ICODE

Program

ICODEICODE

UCODE UCODE

Program FunctionFunct.block

UCODE-CRD

UCODE-Executable

CFG

UCODE + NCODE

NativeCode

Ncode

Compiler & Code GenerationCompiler & Code Generation

MakeMake Generator and Generator and

InterpreterInterpreter

Compiler Compiler FrontendFrontend & &

Compiler BackendCompiler Backend

Linker & Linker & SystembuilderSystembuilder

Native Code (optional)Native Code (optional)

ExecutionExecution of of Applications Applications

in in SmartPLC or TargetSmartPLC or Target