01-01 - IEC-61131 With Programming
01-01 - IEC-61131 With Programming
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
Layout:
© 2007
Robert Bosch GmbH
PA-ATMO1/SGS21
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
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
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
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
7 / 97
1 General
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
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
8 / 97
OpenControl
Control Engineering
for Bosch
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
9 / 97
2.1 Tasks
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
10 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
11 / 97
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
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
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
12 / 97
CPS21
VPP21
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
13 / 97
CPS21
VPP21
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
14 / 97
IndraLogic
The PLC program is programmed with the development environment of Bosch Rexroth.
Installation: \\fe16416\opcon$\Controls\Engineering\PLC
Fieldbus Configurator
The PLC configuration is integrated in IndraLogic.
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
15 / 97
2.8 Support
Hotline
Outlook-post-office-box:
PA-ATMO1/EES OpCon Hotline
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
16 / 97
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.
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
17 / 97
3.1 OpCon-Controls
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
18 / 97
Installation Files
The respective current installation set can be found on the OpCon server
\\fe16416\opcon$\Controls\Engineering\PLC\ndraLogic v1.x\IndraLogic
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
19 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
20 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
21 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
22 / 97
Execute Microsoft XML Parser Setup (starts automatically)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
23 / 97
Installation complete
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
24 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
25 / 97
Available Targets
Installation Targets
The installation files of the Targets can be found on the OpCon Server under
\\fe16416\opcon$\Controls\Development System\IndraLogicVersions\
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
26 / 97
Memory Layout:
General:
Attention:
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
27 / 97
Desktop
Editor
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
28 / 97
Font
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
29 / 97
Directories
Symbol configuration
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
30 / 97
4 Project Administration
IndraLogic
Project Administration
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
31 / 97
4.1 IndraLogic
Is a Windows program
Programming environment
Project (options, build, rebuild all, show cross references, compare, export, import)
Online (Login, Logout, Download, Breakpoint, Step cycle, Write, Force, create Boot project)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
32 / 97
Read Inputs
Write Outputs
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
33 / 97
FB FUN
I/O Image
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
34 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
35 / 97
Declaration of Variables
program organisation
POU Editor
At least one instruction must be programmed to get a precise build. I. e.: (* NOP *)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
36 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
37 / 97
Status window
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
38 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
39 / 97
5 Communication
IndraLogic
Communication
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
40 / 97
IndraLogic
Response Request
I/Os
PLC Machine
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
41 / 97
New Channel
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
42 / 97
Connection: Local
Address: disabled (local host => 127.0.0.1)
Connection: TCP/IP
Address: IP-address of the target (i. e. 192.1.89.133)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
43 / 97
Target Settings
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
44 / 97
PLCWinNT.exe (simulator)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
45 / 97
State = RUNNING
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.
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
47 / 97
DP Parameters
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
48 / 97
Bus Parameters
Module Parameters
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
49 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
50 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
51 / 97
Base Parameters
DP Parameters
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!).
Append Task
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
53 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
54 / 97
8 IEC 61131-3
IEC 61131-3
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
55 / 97
Read inputs
Write outputs
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
56 / 97
Project
HW configuration
POE Types
Function (FUN)
Program (PRG)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
57 / 97
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.
Furthermore:
Data type names
Function names
Function Block names
Operators IL-language, ST-language, …
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
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
Standard Operators
Boolean Operators
Arithmetic Operators
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
60 / 97
Comparison Operators
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
61 / 97
Bit Manipulation
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
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
63 / 97
Numeric Functions
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
64 / 97
Selection Functions
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
65 / 97
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
66 / 97
Bistable Elements
Edge Detection
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
67 / 97
Timer
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
68 / 97
Counter
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
69 / 97
Validity
Textual declaration
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
70 / 97
Declarations as tables
Autodeclaration
Example
VAR
RetVal : DINT; (* declaration of the variable „RetVal“ with data type DINT *)
END_VAR
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
71 / 97
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
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
72 / 97
RETAIN
CONSTANT
R_EDGE
F_EDGE
READ_ONLY
READ_WRITE
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
73 / 97
Operand Syntax
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
74 / 97
I/O Configuration
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
75 / 97
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)
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)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
76 / 97
Assignments
Boolean Operations
Mathematical Operations
Comparison Operations
Selection Operations
Type Conversion
Complex Operations
Shift Operations
Special Operations
Assignment
Boolean Operations
Mathematical Operations
IL,FBD,LD ST
ADD +
SUB -
MUL *
DIV /
MOD MOD
work with the type ANY_NUM
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 ...
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
78 / 97
Shift Operations
a b c d e f g h 0
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
Special Operations
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
79 / 97
Function
Example Simple(FUN)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
80 / 97
Function Block
Example HysteresisFB(FB)
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
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
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
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
83 / 97
Program
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);
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
84 / 97
FBD/LD
Program (PRG)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
85 / 97
String functions
Edge detection
counter
timer
NEW: Bistable function blocks
String Functions
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
86 / 97
Edge Detection
Counters
Timers
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
87 / 97
9 IEC-61131 Introduction
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
88 / 97
Part 5 - Communication
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
89 / 97
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.
Common Elements
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.
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
90 / 97
Software Model
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
91 / 97
Data Communication Model
Programming Model
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, ...
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
93 / 97
Function Block (FB)
Program (PRG)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
94 / 97
Configuration Elements
Configuration Example
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
95 / 97
Programming languages
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…
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).
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)
01_Op001_EN_V1.8.doc/V01.80
[Op001] Introduction to IEC 61131 with IndraLogic
97 / 97
Structured Software
Through the configuration of the resources and program organization units (POUs).
Typing of Data
Through the employment of program organization units (POUs), structures and complex data
types.
01_Op001_EN_V1.8.doc/V01.80