Download as pdf or txt
Download as pdf or txt
You are on page 1of 97

[Op001] Introduction to IEC 61131 with IndraLogic

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
2 / 97

Revision Index
Version Amended by Date
Amendment / Aenderung
(Vxx.yy) geaendert durch Datum
V01.80 Add new OpCon$ structure Frank Markert 19.01.2007
V01.70 New Release Frank Markert 27.11.2006
V01.60 Installation/Handling IndraLogic 1.31 added Frank Markert 10.08.2006
V01.50 Chapter 3 updated, first edition new template Frank Markert 03.03.2006

Imprint

Publisher:
Robert Bosch GmbH
PA-ATMO1/SGS21

Author: Frank Markert

Regarding this book:


- As this book has not been created for autodidactic learning, the coherences arise only from
the explanations in the seminar.
- In any case the information and instructions for the publication belonging to the products of the Robert Bosch
GmbH need to be considered.
- The images are partly wrong. These will be corrected and explained during the seminar.

Layout:

© 2007
Robert Bosch GmbH
PA-ATMO1/SGS21

All rights reserved by Robert Bosch GmbH,


also in case of trademark right registrations.
All authority of disposal, such as copyright and transmission
right remain with us.

Errors and technical modifications excepted.

The information in this document is subject to change without notice,


and does not represent an obligation on the part of the Robert Bosch GmbH.
* Microsoft, MS, MS–DOS, Windows, Windows NT, Windows95 and Excel are either registered trademarks resp. trademarks
of the Microsoft Corporation in the USA and/or other countries.
** Adobe and Acrobat Reader are trademarks of the Adobe Systems Incorporated
All further listed trademark markings and –descriptions are property of the respective companies.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
3 / 97

Directory

1 General.......................................................................................................................7
1.1 Organisation PLCopen ............................................................................................................................ 7
1.2 Targets..................................................................................................................................................... 7
1.3 Members (selection) ................................................................................................................................ 7

2 OpCon – Control Engineering for Bosch ................................................................8


2.1 Tasks ....................................................................................................................................................... 9
2.2 Scalable Control Engineering .................................................................................................................. 9
2.3 Scalable Control Engineering System ................................................................................................... 10
2.4 OpCon Properties .................................................................................................................................. 11
Software................................................................................................................................................. 11
Hardware ............................................................................................................................................... 11
Support .................................................................................................................................................. 11
2.5 Technical Overview ............................................................................................................................... 12
CPS21 ................................................................................................................................................... 12
VPP21.................................................................................................................................................... 12
2.6 System Architecture .............................................................................................................................. 13
CPS21 ................................................................................................................................................... 13
VPP21.................................................................................................................................................... 13
2.7 Development Environment .................................................................................................................... 14
IndraLogic .............................................................................................................................................. 14
Fieldbus Configurator ............................................................................................................................ 14
2.8 Support .................................................................................................................................................. 15
Hotline.................................................................................................................................................... 15
Documentations, Libraries and Updates ............................................................................................... 15

3 IndraLogic – The Development Environment .......................................................16


3.1 OpCon-Controls..................................................................................................................................... 17
3.2 What is IndraLogic ................................................................................................................................. 17
3.3 Installation of the Development Environment (IndraLogic) ................................................................... 18
Stop Gateway Server ............................................................................................................................ 18
Installation Files ..................................................................................................................................... 18
Selection of the target path.................................................................................................................... 20
Select a program folder ......................................................................................................................... 20
Confirm all target installation questions................................................................................................. 21
Installation complete .............................................................................................................................. 23
Link on the Desktop ............................................................................................................................... 23
3.4 Generate System Settings for IndraLogic ............................................................................................. 24
3.5 Manual Installation of Targets for OpCon.............................................................................................. 25
Available Targets ................................................................................................................................... 25
Installation Targets ................................................................................................................................ 25
3.6 Setting Targets ...................................................................................................................................... 26
Important project specific settings (i. e. VPP21).................................................................................... 26
For the other targets see the documentation on OpCon$ ..................................................................... 26
3.7 Options IndraLogic................................................................................................................................. 27
Setting of the Language ........................................................................................................................ 27
© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
4 / 97

4 Project Administration............................................................................................30
4.1 IndraLogic .............................................................................................................................................. 31
The IndraLogic Main Window ................................................................................................................ 31
The IndraLogic Taskbar......................................................................................................................... 31
4.2 An IndraLogic Project ............................................................................................................................ 32
The general functional Principle of a PLC ............................................................................................. 32
Structure of an IndraLogic Program ...................................................................................................... 33
Basic rules of the PLC Programming .................................................................................................... 33
4.3 Create New Project (file -> new) ........................................................................................................... 34
Select a Target System ......................................................................................................................... 34
Main Program: PLC_PRG(ST) .............................................................................................................. 35
File -> Save as....................................................................................................................................... 36
Project -> Build ...................................................................................................................................... 37
Create New Folder (right mouse key).................................................................................................... 37
Add Object (right mouse key) ................................................................................................................ 38

5 Communication .......................................................................................................39
5.1 Communication of the PLC.................................................................................................................... 40
5.2 Communication Parameters .................................................................................................................. 41
New Channel ......................................................................................................................................... 41
Communication Parameter for the Simulator (PlcWinNT)..................................................................... 42
Communication Parameter for the VPP21 ............................................................................................ 42
Target Settings ...................................................................................................................................... 43
PLCWinNT.exe (simulator).................................................................................................................... 44
5.3 Online -> Login ...................................................................................................................................... 44
5.4 Login / Run / Create boot project / File Save ........................................................................................ 45

6 Configuration Fieldbus...........................................................................................46
6.1 PLC Configuration (Fieldbus) ................................................................................................................ 46
Restoring Standard Configuration ......................................................................................................... 46
6.2 Parameterize Profibus ........................................................................................................................... 47
Append Subelement Profibus Master (at VPP21: COM-PB) ................................................................ 47
Parameterize COM-PB (Profibus Master) ............................................................................................. 47
Append Subelement (i. e. BK3120_V3) ................................................................................................ 49
Insert Inputs/Outputs to the Subelement (i. e. KL6201 (PAB 16)) ........................................................ 50
Parameterize Subelement BK3120 ....................................................................................................... 51

7 Task Configuration .................................................................................................52


Append Task.......................................................................................................................................... 52
Append Program Call PLC_PRG() ........................................................................................................ 53

8 IEC 61131-3..............................................................................................................54
8.1 IEC 61131 Part 3 – Programming Languages ...................................................................................... 55
The international Standard defines........................................................................................................ 55
8.2 The general functional Principle of a PLC ............................................................................................. 55
8.3 The Structure of an IndraLogic Program ............................................................................................... 56
8.4 What is a POU? ..................................................................................................................................... 56
POE Types ............................................................................................................................................ 56
8.5 Identifiers and Keywords ....................................................................................................................... 57
Identifiers ............................................................................................................................................... 57
Keywords ............................................................................................................................................... 57
© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
5 / 97
Numeric Literals..................................................................................................................................... 58
String Literals......................................................................................................................................... 58
Time Literals .......................................................................................................................................... 59
Standard Operators ............................................................................................................................... 59
Boolean Operators................................................................................................................................. 59
Arithmetic Operators.............................................................................................................................. 59
Comparison Operators .......................................................................................................................... 60
Bit Manipulation ..................................................................................................................................... 61
Type Conversion.................................................................................................................................... 62
Numeric Functions................................................................................................................................. 63
Selection Functions ............................................................................................................................... 64
Functions for Strings.............................................................................................................................. 65
Standard Function Blocks...................................................................................................................... 66
Bistable Elements .................................................................................................................................. 66
Edge Detection ...................................................................................................................................... 66
Timer...................................................................................................................................................... 67
Counter .................................................................................................................................................. 68
8.6 Variables – Datas and Operands .......................................................................................................... 69
Validity ................................................................................................................................................... 69
IndraLogic supports three methods of the Variable declaration............................................................ 69
Data Types (as general variable) .......................................................................................................... 70
Elementary Data Types (Standard IEC Data Types) ............................................................................ 71
Derived Data Types (type definition) ..................................................................................................... 71
General Data Types............................................................................................................................... 71
Multi Element-Variable: Fields and Structures ...................................................................................... 72
Attributes of the Variable Types ............................................................................................................ 72
Operand Types – Inputs, Outputs and Marker as special Variables..................................................... 73
Operand Syntax..................................................................................................................................... 73
Convention for Symbol Names.............................................................................................................. 73
I/O Process Image ................................................................................................................................. 74
I/O Configuration.................................................................................................................................... 74
Symbol table with Excel and OpCon-IO Macro ..................................................................................... 74
8.7 The Languages of the IEC 61131-3 ...................................................................................................... 75
Structured Text (ST) .............................................................................................................................. 75
Sequential Function Chart (SFC) .......................................................................................................... 75
8.8 IEC Operations ...................................................................................................................................... 76
Assignment ............................................................................................................................................ 76
Boolean Operations ............................................................................................................................... 76
Mathematical Operations....................................................................................................................... 76
Comparison Operations......................................................................................................................... 77
Selection Operations ............................................................................................................................. 77
Type Conversions.................................................................................................................................. 77
Complex Operations .............................................................................................................................. 77
Shift Operations ..................................................................................................................................... 78
Special Operations ................................................................................................................................ 78
8.9 POU Types ............................................................................................................................................ 79
Function ................................................................................................................................................. 79
Function Block ....................................................................................................................................... 80
Program ................................................................................................................................................. 83
How to call a FUN, FB or PRG ? ........................................................................................................... 84
Rules for reciprocal request for POUs................................................................................................... 84
8.10 Predefined POUs (Libraries) ................................................................................................................. 85
8.11 The Default-Library (standard.lib).......................................................................................................... 85
String Functions..................................................................................................................................... 85
Edge Detection ...................................................................................................................................... 86
Counters ................................................................................................................................................ 86
Timers.................................................................................................................................................... 86
© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
6 / 97

9 IEC-61131 Introduction ...........................................................................................87


9.1 Parts of the Norm................................................................................................................................... 88
9.2 Part 1 - General Information .................................................................................................................. 88
Functional Structure of programmable Systems ................................................................................... 88
9.3 Part 2 – Resource Requests and Tests................................................................................................. 89
9.4 Part 3 – Programming Languages......................................................................................................... 89
Common Elements ................................................................................................................................ 89
Programming languages ....................................................................................................................... 95
Key Characteristics for the Quality of the IEC 61131-3......................................................................... 97
Advantages of the Standard for the User .............................................................................................. 97
9.5 Part 4 – User Guidelines ....................................................................................................................... 97
9.6 Part 5 - Communication......................................................................................................................... 97

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
7 / 97

1 General

1.1 Organisation PLCopen


In 1992 PLCopen was founded as an international association independent of manufacturers and products.
Many PLC producers, Software companies and independent institutes in Europe and overseas belong to it.

1.2 Targets
The aim of PLCopen is the support of development and use of compatible Software for PLC.

The measures to reach this aim rely, among other things, on the application of the international Standard
IEC 61131-3.

The PLCopen is not a standards committee but it is a pool that wants to leverage the existing standards to an
international acceptance.
http://www.plcopen.org

1.3 Members (selection)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
8 / 97

2 OpCon – Control Engineering for Bosch

OpenControl
Control Engineering
for Bosch

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
9 / 97

2.1 Tasks

2.2 Scalable Control Engineering

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
10 / 97

2.3 Scalable Control Engineering System

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
11 / 97

2.4 OpCon Properties

Software
Operate and observe (visualization)
Soft-PLC, programmable according to IEC 61131-3
Data administration
Data concept with host computer connection
Operating- and machine data logging (BDE/MDE)
Statistic analysis
Reusability by means of standardization
Object oriented
Configurable

Open: Changeable and expandable by customer

Hardware
Scalable
Intelligent sensor modules for local data collection (ISM)
Long-term availability
Control Engineering of Bosch Rexroth: CPS21, CPS21-T,
VPP21, VPP21-T,
VEP30, L40 …

Support
Development Team for BOSCH requirements
- Advance development (CR)
- Customer specific developments
System training
Hotline
Remote maintenance
Annual customer meetings

Software and documentation are freely available in the Bosch Network.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
12 / 97

2.5 Technical Overview

CPS21

VPP21

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
13 / 97

2.6 System Architecture

CPS21

VPP21

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
14 / 97

2.7 Development Environment

IndraLogic
The PLC program is programmed with the development environment of Bosch Rexroth.

It is developed in the languages:


SFC (Sequential Function Chart)
ST (Structured Text)

Installation: \\fe16416\opcon$\Controls\Engineering\PLC

Fieldbus Configurator
The PLC configuration is integrated in IndraLogic.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
15 / 97

2.8 Support

Hotline

Regarding technical requests:

Outlook-post-office-box:
PA-ATMO1/EES OpCon Hotline

Email address for external employees:


OpConHotline.PA-ATMO1EES@de.bosch.com

Documentations, Libraries and Updates

Computer name : FE16416


Domain : DE
Path : FE16416
Share : OpCon$
User :
Password :

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
16 / 97

3 IndraLogic – The Development Environment

Installation
IndraLogic
Development
Computer

The Versions of CoDeSys (V 2.0 and V 2.2) and IndraLogic 1.x can be used and installed simultaneously on
the development computer without any problems. However it is necessary to make arrangements to change
over the link in the explorer resp. desktop according to the requested CoDeSys version. This is necessary for
the Batch files and help programs to work with the version of CoDeSys / IndraLogic which is suitable to the
project. These programs need the development environment for their execution.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
17 / 97

3.1 OpCon-Controls

3.2 What is IndraLogic

a programming tool for PLC-programs

a test tool for PLC-programs

a tool for troubleshooting

a tool for the documentation of PLC-programs

a visualization program for the simulation of PLC-programs

a PLC-run time system ( VPP21 without VxWorks)

IndraLogic is a complete PLC-development environment

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
18 / 97

3.3 Installation of the Development Environment (IndraLogic)

Stop Gateway Server

A running gateway needs to be stopped before the installation of IndraLogic.

Installation Files

The respective current installation set can be found on the OpCon server
\\fe16416\opcon$\Controls\Engineering\PLC\ndraLogic v1.x\IndraLogic

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
19 / 97

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
20 / 97

Selection of the target path


It is recommended to select the following paths and their order.

1. Install CoDeSys V2.0 to < C:\BoschPCL_M >


2. Install CoDeSys V2.2 to < C:\BoschPCL_M_V2.2 >
3. Install IndraLogic V1.0 to < C:\BoschRexrothPlc_V1.0 >
or
Install IndraLogic V1.31 to < C:\Program Files\Rexroth >
(IndraLogic 1.x can only be installed simultaneously in one Version.)

Example: IndraLogic 1.31

Select a program folder


It is recommended to choose the following program folders.

CoDeSys V2.0 Program folder: BoschPCL_M


CoDeSys V2.2 BoschPCL_M_V2.2
IndraLogic V1.0 BoschRexrothPlc_V1.0
IndraLogic V1.31 Rexroth

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
21 / 97

Confirm all target installation questions

confirm all targets


with Yes

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
22 / 97
Execute Microsoft XML Parser Setup (starts automatically)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
23 / 97

Installation complete

Link on the Desktop

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
24 / 97

3.4 Generate System Settings for IndraLogic


The tool (AtmoPlcDevPath.exe) generates the requested Reg Files for the different SoftPLC development
environments after input.

The program can be found on the OpCon Server under


\\Fe16416\Opcon$\Controls\Engineering\PLC\AtmoPlcDevPath

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
25 / 97

3.5 Manual Installation of Targets for OpCon

Available Targets

None for internal simulation with IndraLogic (CoDeSys)


CoDeSys SP for Windows NT 1.0 for PLCWinNT (simulator CPS21)
CoDeSys SP for WinPanel for CPS21 with VxWorks
CoDeSys SP for Windows NT Realtime for VPP21 with RTE
3S CoDeSys SP PLCWinNt V2.4 for PLCWinNT V2.4 (simulator VPP21)
IndraLogic L20, L40, VEP
…. others see below

Installation Targets

Open the program InstallTarget in the Windows start menu.

The installation files of the Targets can be found on the OpCon Server under
\\fe16416\opcon$\Controls\Development System\IndraLogicVersions\

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
26 / 97

3.6 Setting Targets

Important project specific settings (i. e. VPP21)

Attention: these settings will be saved with the project.

Memory Layout:

General:

Attention:

The Address Check has


to be active to prevent a
program access on an
undefined address.

For the other targets see the documentation on OpCon$

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
27 / 97

3.7 Options IndraLogic

Setting of the Language


The development environment is set on the setup language after the installation. It can be adjusted through
the menu „project\options…\desktop“.

Desktop

Editor

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
28 / 97

Font

Load & Save

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
29 / 97

Directories

Symbol configuration

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
30 / 97

4 Project Administration

IndraLogic
Project Administration

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
31 / 97

4.1 IndraLogic

The IndraLogic Main Window

Is a Windows program

Menu bar / Menus (Short Cuts)

Object and program manager

Programming environment

Message window (e. g. Compiler error)

Status bar (current environmental status)

The IndraLogic Taskbar

File (New, Open, Save, Save as)

Edit (copy, cut, paste, find, replace)

Project (options, build, rebuild all, show cross references, compare, export, import)

Insert (new declaration, objects)

Extras (Monitoring Options)

Online (Login, Logout, Download, Breakpoint, Step cycle, Write, Force, create Boot project)

Window (Window Control, Library Manager)

Help (contents, search)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
32 / 97

4.2 An IndraLogic Project


Will be saved completely in one file (name.pro)

Starts always with a main program PLC_PRG (like OB1)

Consists of different program organisation units (POUs).

Will be executed cyclic

The general functional Principle of a PLC

Read Inputs

Execute PLC program

Write Outputs

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
33 / 97

Structure of an IndraLogic Program

PLC_PRG VAR VAR


END_VAR END_VAR

FB FUN

I/O Image

Basic rules of the PLC Programming

A called POU must always return to the calling POU.

Attention with the usage of loops.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
34 / 97

4.3 Create New Project (file -> new)

Select a Target System

i. e. Target system: 3S CoDeSys SP PLCWinNTV2.4 for PLCWinNT.exe (simulation for VPP21)

A New POU must be created automatically.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
35 / 97

Main Program: PLC_PRG(ST)

Declaration of Variables

program organisation

POU Editor

At least one instruction must be programmed to get a precise build. I. e.: (* NOP *)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
36 / 97

File -> Save as

Path: Drive:\ Production Line \ Station of Line \ Plc \ *.pro


Example: D:\FeW_0815\Stat010\Plc\Stat010.pro

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
37 / 97

Project -> Build

Status window

Create New Folder (right mouse key)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
38 / 97

Add Object (right mouse key)

New POU i. e. MyFB(FB)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
39 / 97

5 Communication

IndraLogic
Communication

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
40 / 97

5.1 Communication of the PLC

IndraLogic

Response Request

I/Os
PLC Machine

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
41 / 97

5.2 Communication Parameters

New Channel

Important: TCP/IP (Level 2 Route)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
42 / 97

Communication Parameter for the Simulator (PlcWinNT)

Connection: Local
Address: disabled (local host => 127.0.0.1)

Communication Parameter for the VPP21

Connection: TCP/IP
Address: IP-address of the target (i. e. 192.1.89.133)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
43 / 97

Target Settings

Configuration: 3S CoDeSys SP PLCWinNTV2.4 for PLCWinNT.exe (simulation for VPP21)


Configuration: CoDeSys SP for Windows NT Realtime for VPP21 with RTE

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
44 / 97

PLCWinNT.exe (simulator)

Create a link on the desktop

5.3 Online -> Login

Check the target settings under resources -> target settings.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
45 / 97

5.4 Login / Run / Create boot project / File Save

Saves the PLC


program on the
hard disk of the
target.
(Default.prg)

State = RUNNING

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
46 / 97

6 Configuration Fieldbus
6.1 PLC Configuration (Fieldbus)

Attention: When changing the targets the control configuration (bus configuration) will be deleted.

Restoring Standard Configuration

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
47 / 97

6.2 Parameterize Profibus

Append Subelement Profibus Master (at VPP21: COM-PB)

Parameterize COM-PB (Profibus Master)

DP Parameters

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
48 / 97
Bus Parameters

Module Parameters

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
49 / 97

Append Subelement (i. e. BK3120_V3)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
50 / 97

Insert Inputs/Outputs to the Subelement (i. e. KL6201 (PAB 16))

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
51 / 97

Parameterize Subelement BK3120

Base Parameters

DP Parameters

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
52 / 97

7 Task Configuration
In the VPP21 the Profi bus runs task synchronous in contrast to the CPS21. Therefore the task the Profi bus
should be synchronized with must be configured. Normally only one task is programmed. Should this be the
case: in control configuration ->module parameter -> under „Update Task” stands the value “ALL”. Should this
be changed the task name must be entered exactly in the way it is described in the task configuration
(Case sensivity!).

See also 6.2. Parameterize Profibus

Append Task

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
53 / 97

Append Program Call PLC_PRG()

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
54 / 97

8 IEC 61131-3

IEC 61131-3

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
55 / 97

8.1 IEC 61131 Part 3 – Programming Languages

The international Standard defines

How data will be declared

The basic structure of PLC programs and run time systems.

The syntax and semantics of 5 different PLC-programming languages.

IndraLogic is an IEC 61131-3 conform PLC-Programming System

8.2 The general functional Principle of a PLC

Read inputs

Execute PLC program

Write outputs

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
56 / 97

8.3 The Structure of an IndraLogic Program

Project

POUs Global Variables Structures

HW configuration

declaration Code HMI pictures

8.4 What is a POU?


A POU (Program-Organization-Unit) is a module, which contains program lines and which can be called by
other POUs.
The reserved POU <PLC_PRG> can only be called by a runtime system of the PLC itself.

POE Types

Function (FUN)

Function block (FB)

Program (PRG)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
57 / 97

8.5 Identifiers and Keywords

Identifiers Keywords

Series of letters, numerics and underscores (_). These are qualified as combinations of characters,
Has to begin with a letter or underscore. Several which must not contain embedded blanks. Key
prefix and multiple embedded underscores are words must not be used for other purposes (i. e. as
inadmissible. Furthermore blanks must not be variable names)
included in the identifiers. At least six characters
must be supported by several systems.

Example for Keywords


Examples for identifier ACTION...END_ACTION
START ARRAY...OF
STOP AT
VALVE_6 CASE...OF...ELSE...END_CASE
CONFIGURATION...END_CONFIGURATION
VAV_E_7 CONSTANT
_16E8 EN
_Shaft ENO
_000S901 EXIT
FALSE
F_EDGE
FOR...TO...BY...END_FOR
FUNCTION...END_FUNCTION
FUNCTION_BLOCK...END_FUNCTION_BLOCK
IF...THEN...ELSIF...ELSE...END_IF
INITIAL_STEP...END_STEP
PROGRAM...WITH...
PROGRAM...END_PROGRAM
R_EDGE
READ_ONLY
READ_WRITE
REPEAT...UNTIL...END_REPEAT
RESOURCE...ON...END_RESOURCE
RETAIN
RETURN
STEP...END_STEP
STRUCT...END_STRUCT
TASK
TRANSITION...FROM...TO...END_TRANSITION
TRUE
TYPE...END_TYPE
VAR...END_VAR
VAR_INPUT...END_VAR
VAR_IN_OUT...END_VAR
VAR_EXTERNAL...END_VAR
VAR_ACCESS...END_VAR
VAR_GLOBAL...END_VAR
WHILE...DO...END_WHILE
WITH

Furthermore:
Data type names
Function names
Function Block names
Operators IL-language, ST-language, …

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
58 / 97

Numeric Literals
Integer literals and real literals

Examples:
-5 +96 628_26 Interger literals;
Underscores between
the numeric must not be
sigificant.
-5.0 0.123 12.56 Real literals
6.2E – 4 bzw. 6.2e – 4 Real literal with exponent
-2.6E + 3 bzw. –2.6e + 3
12.0E3 bzw. 12.0e3
2#1010_1010 Literal to basis 2
8#156 Literal to basis 8
16#FF Literal to basis 16
0 1 Boolean zero und one
FALSE TRUE Boolean FALSE und
TRUE

String Literals
Series of zero or more characters, which is embedded in a single quotation mark (‘)

Examples:
‘‘ Blank string with the length zero
‘X‘ String with the length one, with sign X
‘‘ String with the length one, with blank
‘$“ String with the length one, with inverted
commas
‘$$6.00‘ String with the length five, $6.00
$$ Dollar-sign $
$‘ Inverted Commas
$L resp. $l Linefeed
$N resp. $n New line
$P resp. $p New page
$R resp. $r Carriage return

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
59 / 97

Time Literals

1. Duration Examples
Data for the duration must be limited through the key
T#80 ms T#30.8s T#9.5m T#20.6h
word T#, TIME#, t# or time# on the left.
T#30h26m t#7d16h12m
Underscores can separate the unit of the duration-
TIME#2.5h time#2.5h
literals.
T16h_12m_18s T#16h_12m_18s

2. Date and time of day Examples


DATE# resp. D# Date
Date#1996-04-6
TIME_OF_DAY# resp. TOD# Time of day D#1996-04-6
DATE_AND_TIME# resp. DT# Date and time D#1996-04-6
TIME_OF_DAY#17 : 19 : 40.12
TOD#17 : 19 : 40.12
DATE_AND_TIME#1996-04-12-17 : 26 :
45.16
Dt#1996-01-12-17 : 26 : 45.16

Standard Operators

Boolean Operators

Operator Parameter Comment


AND ANY_BIT AND-function
OR ANY_BIT OR-function
NOT ANY_BIT NOT-function, negation
XOR ANY_BIT XOR-function, nonequivalence

Arithmetic Operators

Operator Input- Output- Comment


Parameter Parameter
ADD+ ANY_NUM ANY_NUM Addition
SUB- ANY_NUM ANY_NUM Subtraction
MUL* ANY_NUM ANY_NUM Multiplication
DIV/ ANY_NUM ANY_NUM Division; at
ANY_INT
integer division
MOD ANY_INT ANY_INT Modulo (remain
at integer
division)
EXPT** Basis: ANY_REAL Exponentiation
ANY_REAL
Exponent:
ANY_NUM
MOVE:= ANY_NUM ANY_NUM Allocation

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
60 / 97

Comparison Operators

Operator Input- Output- Comment


Parameter Parameter
GT > ANY_BIT BOOL greater than
ANY_NUM
STRING
TIME
ANY_DATE
GE >= ANY_BIT BOOL greater or equal
ANY_NUM
STRING
TIME
ANY_DATE
LE <= ANY_BIT BOOL less or equal
ANY_NUM
STRING
TIME
ANY_DATE
LT < ANY_BIT BOOL less
ANY_NUM
STRING
TIME
ANY_DATE
EQ = ANY_BIT BOOL equal
ANY_NUM
STRING
TIME
ANY_DATE
NE <> ANY_BIT BOOL not equal
ANY_NUM
STRING
TIME
ANY_DATE
ANY_NUM

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
61 / 97

Bit Manipulation

Function Input- Output- Comment


parameter parameter Example
SHL IN: ANY_BIT Shift left from IN
X : SHL (IN :=WERT, N :=3);
ANY_BIT and N Bit
N: 00010101 before SHL...
ANY_INT
10101000 after SHL...
SHR IN: ANY_BIT Shift right from
ANY_BIT IN by N Bit Three digits to the left, zeros follow at the
N: right.
ANY_INT
ROL IN: ANY_BIT Rotation left
ANY_BIT from IN by N Bit
N: in a circle
ANY_INT
ROR IN: ANY_BIT Rotation right
ANY_BIT from IN by N Bit
N: in a circle
ANY_INT

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
62 / 97

Type Conversion

Function Input-
Output- Comment
parameter
parameter
*_TO_** ANY_NUM Numeric Types Example
ANY_NUM
are converted
X := INT_TO_REAL(Y);
into one
another
*Input data
**Output data
TRUNC ANY_REAL ANY_INT Truncates will
be cut
BCD_TO_* ANY_BIT ANY_INT *Data type Example
Data of the X := TRUNC (Y);
ANY_BIT-
Group in the Example
BCD-format X := BCD_TO_INT (Y);
will be
converted into
the ANY_INT-
format
*_TO_BCD ANY_INT ANY_BIT *Data type
Data in the
ANY_INT-
format will be Example
converted into X := INT_TO_BCD (Y);
the BCD-
format

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
63 / 97

Numeric Functions

Function Input- Output- Comment


parameter parameter
ABS ANY_NUM ANY_NUM Absolute value
SQRT ANY_REAL ANY_REAL Square root
LN ANY_REAL ANY_REAL Logarithm,
natural
LOG ANY_REAL ANY_REAL Logarithm, base
10
EXP ANY_REAL ANY_REAL Exponent
function base e
SIN ANY_REAL ANY_REAL Sine function
(circular
measure)
COS ANY_REAL ANY_REAL Cosine function
(circular
measure)
TAN ANY_REAL ANY_REAL Tangent function
(circular
measure)
ASIN ANY_REAL ANY_REAL Arc sine function
ACOS ANY_REAL ANY_REAL Arc cosine
function
ATAN ANY_REAL ANY_REAL Arc tangent
function

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
64 / 97

Selection Functions

Function Input- Output- Comment


parameter parameter
SEL G: BOOL ANY Binary selection
Example
IN0: ANY
OUT := IN0,
IN1: ANY X := SEL (G :=0, IN0 :=IN1 = 3);
if G = 0
OUT := IN1,
if G = 2
MAX ANY_BIT ANY_BIT Maximum- Example
ANY_NUM ANY_NUM function
STRING STRING X := MAX (Y,Z);
OUT := MAX
ANY_DATE ANY_DATE
(IN1, IN2,...)
TIME TIME
MIN ANY_BIT ANY_BIT Minimum- Example
ANY_NUM ANY_NUM function
STRING STRING X := MIN (Y,Z);
OUT := MIN
ANY_DATE ANY_DATE
(IN1, IN2,...)
TIME TIME
LIMIT MN, IN, MX: ANY_BIT Limiting Example
ANY_NUM X := LIMIT (IN := X, MN := 0, MX := 3);
ANY_BIT OUT :=MIN
STRING
ANY_NUM (MAX (IN, MN,)
ANY_DATE
STRING MX)
TIME
ANY_DATE
TIME
MUX K: ANY_INT ANY Multiplexer Example
other: X := MUX (K := 0, IN0 := A, IN1 = B, IN2 = C);
Selects one of
ANY
N inputs
depends on the
input K

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
65 / 97

Functions for Strings

Function Input- Output- Comment


Parameter Parameter
LEN STRING INT Length of a Example
string
X := LEN (‘WORT‘);
X :=4
LEFT IN: STRING L Example
STRING left aligned X := LEFT (IN := ‘WORT‘, L :=3);
L: characters of X := WOR
ANY_INT IN
RIGHT IN: STRING L Example
STRING right aligned X := RIGHT (IN := ‘WORT‘, L :=3);
L: characters of X := ORT
ANY_INT IN
MID IN: STRING L character of Example
STRING IN, starting with
X := MID (IN := ‘WORT‘, L =2, P = 2);
L: the P-ten
X := OR
ANY_INT character
CONCAT STRING STRING String together Example
strings
X := CONCAT X := INSERT (IN1 := ‘HER‘,IN1 := ‘MA‘, P = 2);
(‘WO‘, ‘RT‘) X := HEMAR
X := WORT
INSERT IN1, IN2: STRING Inserts IN2 in Example
STRING IN1 after the
P: P-ten character X := INSERT (IN1 := HER, IN2 := MA, P := 2);
ANY_INT position X := HEMAR

DELETE IN: STRING Deletes L Example


STRING characters of
L, P: IN starting with X := DELETE (IN := ‘WORT‘, L :=1, P := 2);
ANY_INT the P-ten X := WRT
position
REPLACE IN1:, IN2: STRING Replaces L Example
STRING from IN1 by
X := REPLACE
L, P: IN2 starting
(IN1 := ‘WORT‘, IN2 :=‘T‘, L := 1, P :=2);
ANY_INT with the P-ten
X := WTRT
character
position
FIND IN1, IN2: INT Locates the Example
STRING character
X := FIND (IN1 := ‘WORT‘, IN2 :=‘RT‘);
position of the
X := 3
beginning for
the first
occurrence of
IN2 in IN1.
If no
occurrence can
be found of
IN2, the result
will be zero.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
66 / 97

Standard Function Blocks

Bistable Elements

Function- Input- Output- Comment


block parameter parameter
SR S1, R: Q1: BOOL Storage with
BOOL preemptive set
RS S, R1: Q1: BOOL Storage with
BOOL preemptive
reset

Edge Detection

Function- Input- Output- Comment


block parameter parameter
R_TRIG CLK: Q: BOOL With rising
BOOL edge on CLK Q
is TRUE
F_TRIG CLK: Q: BOOL With falling
BOOL edge on CLK Q
is TRUE

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
67 / 97

Timer

Function- Input- Output- Comment


block parameter parameter
TON IN: BOOL Q: BOOL Input delay
PT: TIME ET: TIME IN: rising edge
starts timing
relay
PT: duration of
delay
Q: If time
elapsed, TRUE
ET: momentary
elapsed delay
TOF IN: BOOL Q: BOOL Turn-off delay,
PT: TIME ET: TIME otherwise TON
TP IN: BOOL Q: BOOL Pulse time,
PT: TIME ET: TIME otherwise TON
RTC IN: BOOL Q: BOOL Real time clock1)
PDT: CDT: IN: rising edge,
DATE DATE date + time are
loaded
PDT: Default of 1)
date + time If a rising edge is recognized on IN, the
CDT: current time will be set. It expires as long as IN is
date + current TRUE.
time
Q: like EN

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
68 / 97

Counter

Function- Input- Output- Comment


block parameter parameter
CTU CU: Q: BOOL Incrementer,
R_TRIG ET: TIME Counter counts
(BOOL) from zero to PV.
R: BOOL
PV: INT CU: counting
input (rising
edge)
PV: Target value
of the counter
R: Reset (CV to
0)
Q: If PV is
reached, then Q
TRUE
CTD CD: Q: BOOL Decrementer,
R_TRIG ET: TIME counter counts
(BOOL) from PV to zero.
LD: BOOL CD: counting
PV: INT input (rising
edge)
PV: target value
of the counter
LD: Initialization
from CV to PV
Q: If PV = 0, then
Q TRUE
CV: current
counter value
CTUD CU, CD: QU, QD: In/ Decremeter
R_TRIG BOOL QU: If CV has
(BOOL) CV: INT reached
R, LD: maximum value,
BOOL TRUE
PV: INT QD: If CV has
reached
minimum value,
TRUE, otherwise
like CTU and
CTD

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
69 / 97

8.6 Variables – Datas and Operands

Validity

Local (a POU) or Global (all POUs)

IndraLogic supports three methods of the Variable declaration

Textual, in form of a table and automatically (dialog)

Textual declaration

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
70 / 97

Declarations as tables

Autodeclaration

Data Types (as general variable)

Example
VAR
RetVal : DINT; (* declaration of the variable „RetVal“ with data type DINT *)
END_VAR

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
71 / 97

Elementary Data Types (Standard IEC Data Types)

BOOL, BYTE, WORD, DWORD Bit, bit string


SINT(8Bit), INT(16), DINT(32) Integer with sign
USINT, UINT, UDINT Integer
STRING(80 Byte) String
REAL(32Bit), LREAL(64) Binary real number
TIME, TOD, DATE, DT Duration, time, date, date & time

Derived Data Types (type definition)

STRUCTURES, ARRAY, (POINTER not IEC!!!)

General Data Types

The IEC 61131-3 defines general data types, in order to combine the elementary data types in single groups
hierarchically.

ANY
ANY_BIT ANY_NUM ANY_DATE
ANY_INT ANY_REAL
BOOL INT UINT REAL DATE TIME
BYTE SINT USINT LREAL TIME_OF_DAY STRING
WORD DINT UDINT DATE_AND_TIME All derivided
DWORD LINT ULINT
LWORD

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
72 / 97

Multi Element-Variable: Fields and Structures

Attributes of the Variable Types

RETAIN
CONSTANT
R_EDGE
F_EDGE
READ_ONLY
READ_WRITE

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
73 / 97

Operand Types – Inputs, Outputs and Marker as special Variables

Inputs (%I...), Outputs (%Q...), Markers (%M...)

Operand Syntax

Percent sign % Example symbolic variable


Operand prefix
VAR_GLOBAL
I Input _000S901 AT %IX1.1 : BOOL;
Q Output TEST1 AT %QW215 : WORD;
M Marker TEST2 AT %MD48 : DWORD;
END_VAR

Operand type (supplementation) Area


X Bit %IX21.0..21.15
None Bit Word-oriented
B Byte (8 Bit) %IX21.0..21.7
Byte-oriented
W Word (16 Bit)
D Double word (32 Bit)
See target settings
( Byte addressing mode )

Convention for Symbol Names

Characters and numbers Examples


Symbols start always with a character Otto, otto, OTTO
(A..Z und _) Valve1
Only simple underscores are allowed a_long_name
_100S200A
_100S200A
No blanks in symbol names
No IEC control- or operand names are
allowed
The compiler does not distinguish
between upper and lower case.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
74 / 97

I/O Process Image

I/O Configuration

Input of the symbol tables (with OpCon through IOBaseStation.xls)


Absolute addressing
Symbolic allocation (Resources -> Global Variables -> IO)

Symbol table with Excel and OpCon-IO Macro

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
75 / 97

8.7 The Languages of the IEC 61131-3

Englisch Deutsch
Instruction List (IL) Anweisungsliste (AWL)
Structured Text (ST) Strukturierter Text (ST)
Function Block Diagram (FBD) Funktionsplan (FUP)
Ladder Diagram (LD) Kontaktplan (KOP)
Sequential Function Chart (SFC) Ablaufsprache (AS)

The languages ST and SFC are used with OpCon.

Structured Text (ST)

Textual language
High-level language
PASCAL oriented
Rather unknown as PLC programming language (latest language)
Very good qualified for complex program flows.
(Loops, analog value processing, IF, WHILE, FOR, CASE)

Sequential Function Chart (SFC)

Graphic sequential function chart.


Supports the structuring of flow controls.
Consists of steps (actions and forward switching).
The steps (actions) contain program parts in ST(OpCon).
SFC code cannot be converted in other languages.
CoDeSys provides two different presentations in AS.
PA-ATMO uses a separate manager for each chain.

See also 9.4 Part 3 – Programming Languages

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
76 / 97

8.8 IEC Operations

Assignments
Boolean Operations
Mathematical Operations
Comparison Operations
Selection Operations
Type Conversion
Complex Operations
Shift Operations
Special Operations

Assignment

IL: LD, LDN, ST, STN, S, R


ST: A := B;
FBD: A B
S
A C
A D
LD:

Boolean Operations

AND, OR, XOR, NOT


AND, OR and XOR are extendable (Amount of Inputs)

Mathematical Operations

IL,FBD,LD ST
ADD +
SUB -
MUL *
DIV /
MOD MOD
work with the type ANY_NUM

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
77 / 97

Comparison Operations

IL,FBD,LD ST
EQ =
NE <>
GE >=
GT >
LE <=
LT <
work with the type ANY

Selection Operations

MIN
MAX
SEL
MUX
LIMIT
work with the type ANY

Type Conversions

Function <type>_TO_<type>
Tip: The amount of type conversions should be kept as little as possible. Type conversions
should always take place implicit if possible.
A:=B is allowed if
Type width(A) >= Type width(B)
Attention: Functions require an exact type indication!

Complex Operations

ABS
SQRT
LN (Basis e), LOG (Basis 10)
EXP (ex)
SIN, COS, TAN, ASIN, ACOS, ATAN
EXPT (yx)
Work with the type ...

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
78 / 97

Shift Operations

SHL (shift left) a b c d e f g h

a b c d e f g h 0

SHR (shift right) a b c d e f g h

0 a b c d e f g h

a b c d e f g h
ROL (rotate left)
b c d e f g h a

a b c d e f g h
ROR (rotate right)
h a b c d e f g

work with the type ...

Special Operations

ADR (ANY: provides the variable address)


BITADR (Bit: provides the address on a bit operand)
SIZEOF (ANY: provides the amount of byte of a variable)
Pointer Operator “^”: provides the content of the variable addressed by the
pointer.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
79 / 97

8.9 POU Types

Function (FUN) Any number of input parameters (min. 1),


a return value,
no static variables

Function block (FB) Any number of input parameters, several return


values, static variables.
Multiple applicable through instantiation.

Program (PRG) A global defined function block. No instantiation


possible.

Function

Cannot save values. (over the cycle)


All local variables are initialized at each call.
The function name is the variable for the return value.
Consequently a type must be defined for each function.
Suitable for the calculation of complex expressions.
The use of global variables is not allowed.

Example Simple(FUN)

FUNCTION Simple : REAL (* Function Name *)


VAR_INPUT
A, B : REAL; (* Variables Declaration *)
C : REAL := 1.0; (* *)
END_VAR
VAR
END_VAR
-------------------------------------------------------------
Simple := A*B/C; (* Function Body *)
END_FUNCTION

The preinitialization of input variables


(VAR_INPUT) is not possible with FUN!

Division by zero must be prevented in the


program code.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
80 / 97

Function Block

All variables are created static and save their values.


Copies of the local variable sets can be generated through instantiation.
FBs are applied in program parts whose sequences are controlled by several PLC
cycles or whose program code should be applied multiple.

Example HysteresisFB(FB)

Solution with IF-instruction: (IF – THEN – ELSIF)

FUNCTION_BLOCK HysteresisFB
VAR_INPUT
XIN1 : REAL; (* current value *)
XIN2 : REAL; (* target value *)
EPS : REAL; (* hysteresis band *)
END_VAR
VAR_OUTPUT
Q: BOOL := FALSE; (* initialize once *)
END_VAR
VAR
END_VAR
-------------------------------------------------------------
IF (Q = TRUE)
THEN
IF XIN1 < (XIN2-EPS)
THEN
Q := FALSE; (* XIN decreasing *)
END_IF
ELSIF XIN1 > (XIN2+EPS)
THEN
Q := TRUE; (* XIN increasing *)
END_IF
END_FUNCTION_BLOCK

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
81 / 97
Solution with IF-instruction: (IF – THEN – ELSE)

FUNCTION_BLOCK HysteresisFB
VAR_INPUT
XIN1 : REAL; (* current value *)
XIN2 : REAL; (* target value *)
EPS : REAL; (* hysteresis band *)
END_VAR
VAR_OUTPUT
Q: BOOL := FALSE; (* hysteresis band *)
END_VAR
VAR
END_VAR
-------------------------------------------------------------
IF (Q = TRUE)
THEN
IF XIN1 < (XIN2-EPS)
THEN
Q := FALSE; (* XIN decreasing *)
END_IF
ELSE
IF XIN1 > (XIN2+EPS)
THEN
Q := TRUE; (* XIN increasing *)
END_IF
END_IF
END_FUNCTION_BLOCK

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
82 / 97
Solution with CASE-instruction: (CASE – OF)

FUNCTION_BLOCK HysteresisFB
VAR_INPUT
XIN1 : REAL; (* current value *)
XIN2 : REAL; (* target value *)
EPS : REAL; (* hysteresis band *)
END_VAR
VAR_OUTPUT
Q: BOOL := FALSE; (* initialize once *)
END_VAR
VAR
END_VAR
-------------------------------------------------------------
CASE BOOL_TO_INT(Q) OF
1: IF XIN1 < (XIN2-EPS)
THEN
Q := FALSE; (* XIN decreasing *)
END_IF

0: IF XIN1 > (XIN2+EPS)


THEN
Q := TRUE; (* XIN increasing *)
END_IF
END_CASE
END_FUNCTION_BLOCK

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
83 / 97

Program

All variables are created statically and save their values.


No instantiation possible.
PRGs are applied in programs, whose sequences are controlled over several
PLC-cycles and whose program code should only be applied once.

Example PLC_PRG(PRG)

PROGRAM PLC_PRG
VAR
Result : REAL;
A, B : REAL;
C : REAL := 1.0;
Hysteresis1: HysteresisFB; (* Instantiation *)
XIN1, XIN2 : REAL;
EPS : REAL;
Q_Hyst : BOOL;
END_VAR
-------------------------------------------------------------
(* Example call a function *)
Result := Simple(A:=10, B:=20, C:=30);

(* Example call a function block *)


Hysteresis1.EPS := 5; (* Parameter passing *)
Hysteresis1.XIN1 := 16; (* Parameter passing *)
Hysteresis1.XIN2 := 10; (* Parameter passing *)
Hysteresis1; (* call function block *)
Q_Hyst := Hysteresis1.Q; (* result passing *)
END_PROGRAM

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
84 / 97

How to call a FUN, FB or PRG ?

Function (FUN) Function block (FB) Program (PRG)

Example Function Fun1:INT Function_Block FunBlck1 Program Prgr1


3 Inputs (INT): A, B, C 3 Inputs (INT): A, B, C 3 Inputs (INT): A, B, C
2 Outputs (INT): D, E 2 Outputs (INT): D, E
Instance1: FunBlck1

LD 5 CAL Instance1(A:=5, B:=3, C:=2) CAL Prgr1(A:=5, B:=3, C:=2);


IL
Fun1 3,2 ... ...
ST Result LD Instance1.D LD Prgr1.D
ST Result1 ST Result1
LD Instance1.E LD Prgr1.E
ST Result2 ST Result2

Result:=Fun1(5,3,2); Instance1(A:=5, B:=3, C:=2); Prgr1(A:=5, B:=3, C:=2);


ST
... ...
Result1:=Instance1.D; Result1:= Prgr1.D;
Result2:=Instance1.E; Result1:= Prgr1.E;

FBD/LD

Rules for reciprocal request for POUs

Program (PRG)

Function (FUN) Function block (FB) Program (PRG)

Function (FUN) Function (FUN) Function block (FB) Program (PRG)


Not with IEC61131!

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
85 / 97

8.10 Predefined POUs (Libraries)

A library is a list of objects, which can be used in different projects.


The user can create own libraries easily.
The manufacturer can supply protected libraries.
So his own know how is protected.
CoDeSys enables the call of C functions as library objects.
The default library is called (standard.lib, util.lib)

8.11 The Default-Library (standard.lib)

Is supplied from IndraLogic.


Includes predefined functions which correspond to the IEC 61131-3 standard such as:

String functions
Edge detection
counter
timer
NEW: Bistable function blocks

String Functions

LEN The function LEN issues the length of a string.


LEFT The function LEFT provides the left beginning-string of a
string.
RIGHT The function RIGHT provides a right beginning-string of a
string.
MID The function MID provides a part-string of a string.
CONCAT The function CONCAT provides the concatenation (string
together) of two strings.
INSERT The function INSERT inserts a string from a certain
position into another one.
DELETE The function DELETE deletes a part-string out of a string
from a certain position.
REPLACE The function REPLACE replaces a part-string of a string
by another string.
FIND The function FIND searches for a part-string in a string.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
86 / 97

Edge Detection

R_TRIG The function block R_TRIG detects a rising edge.


F_TRIG The function block F_TRIG detects a falling edge.

Counters

CTU The function block incrementer.


CTD The function block decrementer.
CTUD The function block in- and decrementer.

Timers

TP The function block TP is a pulse transmitter.

TON The function block Timer on-delay realizes a turn-on


delay.

TOF The function block Timer off-delay realizes a turn-off


delay.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
87 / 97

9 IEC-61131 Introduction

Programmable Logic Controller


Inroduction to the Standard
IEC-61131

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
88 / 97

9.1 Parts of the Norm


Part 1 – General information

Part 2 – Resource requests and tests

Part 3 – Programming languages

Part 4 – User guidelines

Part 5 - Communication

9.2 Part 1 - General Information


Definition and glossary of expressions that are used in the standard.
Description of principal functions and properties of programmable systems.

Functional Structure of programmable Systems

Functions for the activation of signals.


Functions of the interface to actors and sensors.
Functions of the communication.
Functions of the Human Machine Interface (HMI).
Functions of the programming.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
89 / 97

9.3 Part 2 – Resource Requests and Tests


Part 2 specifies:
The electrical, mechanical and functional requirements for programmable logic controllers and
the corresponding periphery as well as the conditions for repairs, storing and transport.

The information for supply at the manufacturer.

The methods and processes of the function testing in their application for the complete review
of the properties of programmable logic controllers and the periphery.

9.4 Part 3 – Programming Languages


Definition of the programmable languages and their application.

The syntactical and semantical rules.

The basic interaction of the instructions.

The program test.

The program enlargement and integration of foreign program parts.

Common Elements

Data Types and Variables

Data types: Boolean, Integer, Real, Byte, Word, Character strings, date, time, ..., as well as
structured data types (user defined).
BOOL, INT, REAL, BYTE, WORD, STRING, DATE, TIME_OF_DAY, ...

Variables: Allocations of hardware addresses: I/O, storage, global und locale data enable a
hardware- independent programming.

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
90 / 97
Software Model

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
91 / 97
Data Communication Model

Communication with help of global variables.

Programming Model

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
92 / 97
Program Organisation Units (POUs)

Function (FUN)

Standard functions: CONCAT, ADD, SQRT, SIN, COS, MIN, MAX, AND, OR, ...

User specific functions: Example Simple(FUN)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
93 / 97
Function Block (FB)

Standard FBs: R_TRIG, R_TRIG, CTU, CTD, TP, TON, TOF...

User specific FBs: Example HysteresisFB(FB)

Program (PRG)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
94 / 97
Configuration Elements

Configuration Example

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
95 / 97

Programming languages

The five languages of the IEC 61131-3:

Graphical languages: Ladder Diagram, LD (Kontaktplan, KOP),


Function Block Diagram, FBD (Funktions Baustein Sprache, FBS).

Text languages: Instruction List, IL (Anweisungsliste, AWL),


Structured Text, ST (Strukturierter Text, ST).

Sequential Function Chart, SFC (Ablaufsprach e, AS).

The right choice of the program language depends on the experience of the programmer, the
application, the level of the definition of the application, the structure of the automation system and the
level of the communication with other departments within a company…

Structured Text (ST)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
96 / 97
Sequential Function Chart (SFC)

SFC describes the behaviour of sequential program flows within a control. The Sequential
Function Chart has been derived from the french “Grafcet“ (IEC 848).

Allows the classification of an application in several parts.

Simplifies the quick analysis of errors and facilitates the work at the program maintenance.

SFC is the accumulation of steps (STEP´s) a block of actions (ACTION BLOCK, BEFA) and
transitions (TRANSITION´s, WSB) is realized with. The result is a development of a step chain.

Allows alternative branching and simultaneous branching. ( not allowed with OpCon)

Instruction List (IL) (not used with OpCon)

Function Block Diagram (FBD) (not used with OpCon)

Ladder Diagram (LD) (not used with OpCon)

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
97 / 97

Key Characteristics for the Quality of the IEC 61131-3

Structured Software

Through the configuration of the resources and program organization units (POUs).

Typing of Data

Through languages that reduce operations to the corresponding data types.

Control of the Program Execution

Through the employment of tasks.

Complex sequential Behavior

Through schematic sequential flows.

Encapsulation of the Software

Through the employment of program organization units (POUs), structures and complex data
types.

Advantages of the Standard for the User

Reduces the effort of the programmer: training, data cleaning, troubleshooting, …


Allows more flexibility with the solution of problems and the reuse of program sources.
The same programming techniques in all areas.
Combines the elements and modes of the representation.
Improves the contact and communication between the departments and companies.

9.5 Part 4 – User Guidelines

9.6 Part 5 - Communication

© Robert Bosch GmbH

01_Op001_EN_V1.8.doc/V01.80

You might also like