PLC 2 Unity Reference Standard Block Library
PLC 2 Unity Reference Standard Block Library
Standard
Block Library
September 2004
33002519.01
2
Table of Contents
Part II Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3
Chapter 9 FIND_EQP_***: First element of a table equal to
a value starting from a given rank . . . . . . . . . . . . . . . . . . . . . . 63
5
Part IV Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
6
Part VI Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7
Chapter 59 TRIGGER: Detection of all edges . . . . . . . . . . . . . . . . . . . . . . 209
8
Chapter 74 LN: Natural logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
9
Chapter 90 MIN: Minimum value function . . . . . . . . . . . . . . . . . . . . . . . . . 281
10
Part X Timer & Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
11
Chapter 117 DBCD_TO_***: Conversion of a double BCD integer
into binary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
12
Chapter 130 REAL_AS_WORD: Type conversion . . . . . . . . . . . . . . . . . . . . 391
13
Chapter 146 WORD_TO_BIT: Type conversion . . . . . . . . . . . . . . . . . . . . . 429
Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
14
About the Book
At a Glance
Document Scope This document describes the functions and function blocks of the Standard library.
This document is valid for Unity Pro Version 2.0.
Validity Note The data and illustrations found in this document are not binding. We reserve the
right to modify our products in line with our policy of continuous product
development. The information in this document is subject to change without notice
and should not be construed as a commitment by Schneider Electric.
15
About the Book
Product Related Schneider Electric assumes no responsibility for any errors that may appear in this
Warnings document. If you have any suggestions for improvements or amendments or have
found errors in this publication, please notify us.
No part of this document may be reproduced in any form or by any means, electronic
or mechanical, including photocopying, without express written permission of
Schneider Electric.
All pertinent state, regional, and local safety regulations must be observed when
installing and using this product. For reasons of safety and to ensure compliance
with documented system data, only the manufacturer should perform repairs to
components.
When controllers are used for applications with technical safety requirements,
please follow the relevant instructions.
Failure to use Schneider Electric software or approved software with our hardware
products may result in injury, harm, or improper operating results.
Failure to observe this product related warning can result in injury or equipment
damage.
User Comments We welcome your comments about this document. You can reach us by e-mail at
TECHCOMM@modicon.com
16
General information
I
Introduction
Overview This section contains general information about the Standard library.
17
General information
18
Block types and their applications
1
Introduction
Overview This chapter describes the different block types and their applications.
19
Block types and their applications
Block types
Block types Different block types are used in Unity Pro. The general term for all block types is
FFB.
There are the following types of block:
l Elementary Function (EF)
l Elementary Function Block (EFB)
l Derived Function Block (DFB)
l Procedure
Elementary Elementary functions (EF) have no internal status.. If the input values are the same,
Function the value at the output is the same for all executions of the function, e.g. the addition
of two values gives the same result at every execution.
An elementary function is represented in the graphical languages (FDB and LD) as
a block frame with inputs and an output. The inputs are always represented on the
left and the outputs always on the right of the frame The name of the function, i.e.
the function type, is shown in the center of the frame.
The number of inputs can be increased with some elementary functions.
Elementary Elementary function blocks (EFB) have an internal status. If the inputs have the
function block same values, the value on the output can have another value during the individual
executions. For example, with a counter, the value on the output is incremented.
An elementary function block is represented in the graphical languages (FDB and
LD) as a block frame with inputs and outputs. The inputs are always represented on
the left and the outputs always on the right of the frame The name of the function
block, i.e. the function block type, is shown in the center of the frame. The instance
name is displayed above the frame.
Derived function Derived function blocks (DFBs) have the same properties as elementary function
block blocks. They are created by the user in the programming languages FBD, LD, IL
and/or ST.
20
Block types and their applications
FFB Structure
Structure Each FFB is made up of an operation (name of the FFB), the operands required for
the operation (formal and actual parameters) and an instance name for elementary/
derived function blocks.
Call of a function block in the FBD programming language:
Instance name Operation Operand
(FFB name)
Formal Actual
parameter parameter
MY_TON
TON
ENABLE EN ENO ERROR
EXAMP IN Q OUT
TIME1 PT ET TIME2
Operands
Operation The operation determines which function is to be executed with the FFB, e.g. shift
register, conversion operations.
21
Block types and their applications
Operand The operand specifies what the operation is to be executed with. With FFBs, this
consists of formal and actual parameters.
Formal/actual Inputs and outputs are required to give values to the FFB or to take values from the
parameters FFB. These are called formal parameters.
Objects are connected to the formal parameters which contain the current process
states. These are called actual parameters.
During program runtime, the actual parameters are used to pass the process values
to the FFB and output them after processing.
The data type of the actual parameters must match the data type of the input/output
(formal parameters). The only exceptions are generic inputs/outputs, for which the
data types are determined by the actual parameters. If all actual parameters are
literals, the correct data type for the function block will be selected.
FFB Call in IL/ST In text languages IL and ST, FFBs can be called in formal and in informal form.
Details can be found in the Reference manual.
Example of a formal function call:
out:=LIMIT (MN:=0, IN:=var1, MX:=5) ;
Example of an informal function call:
out:=LIMIT (0, var1, 5) ;
Note: Take note that the use of EN and ENO is only possible for formal calls.
22
Block types and their applications
VAR_IN_OUT FFBs are often used to read a variable on an input (input variables), to process them
variable and output the changed value of the same variable again (output variables).
This is special case for an input/output variable and is also called VAR_IN_OUT
variable.
The input and output variable are linked in the graphic languages (FBD and LD)
using a line showing that they belong together.
Function block with VAR_IN_OUT variable in FBD:
MY_EXAMP1
EXAMP1
Input1 IN1 OUT1 Output1
Input2 IN2 OUT2 Output2
Comb_IN_OUT IO1 IO1 Comb_IN_OUT
23
Block types and their applications
EN and ENO
Description An EN input and an ENO output can be configured for all FFBs.
If the value of EN is "0" when the FFB is called up, the algorithms defined by the FFB
are not executed and ENO is set to "0".
If the value of EN is "1" when the FFB is called up, the algorithms defined by the FFB
are executed. After the algorithms have been executed successfully, the value of
ENO is set to "1". If an error occurs when executing these algorithms, ENO is set to
"0".
If ENO is set to "0" (caused by EN=0 or an error during execution):
l Function blocks
l EN/ENO-handling with function blocks that (only) have one connection as
output parameter:
FunctionBlock_1 FunctionBlock_2
EN ENO EN ENO
IN1 OUT IN1 OUT
IN2 IN2
24
Block types and their applications
l Functions/Procedures
As defined in IEC61131-3, the outputs from deactivated functions (EN-input set
to "0") is undefined. (The same applies for procedures.)
Nevertheless here is an explanation of the output statuses for this case:
l EN/ENO-handling with function/procedure blocks that (only) have one
connection as output parameter:
Function/Procedure_1 Function/Procedure_2
EN ENO EN ENO
IN1 OUT IN1 OUT
IN2 IN2
Conditional/ "Unconditional" or "conditional" calls are possible with each FFB. The condition is
Unconditional realized by pre-linking the input EN.
FFB Call l EN connected
conditional calls (the FFB is only processed if EN = 1)
l EN not used or set to TRUE
unconditional calls (FFB is always processed)
Note for FBD If the EN input is used, it must be connected to logic (conditional call) or permanently
set to TRUE (unconditional call) because otherwise the FFB will never be
processed.
25
Block types and their applications
Note for LD In LD, each FFB must be connected with the left power rail using a Boolean input.
Normally, the EN input is used for this purpose.
If the EN input is not connected to the left power rail, it cannot be used or it must be
permanently set to TRUE because otherwise the FFB will never be processed.
Note for IL and The use of EN and ENO is only possible in the text languages for a formal FFB call,
ST e.g.
MY_BLOCK (EN:=enable, IN1:=var1, IN2:=var2,
ENO=>error, OUT1=>result1, OUT2=>result2);
Assigning the variables to ENO must be done with the operator =>.
With an informal call, EN and ENO cannot be used.
26
Availability of the blocks on
different hardware platforms
2
Availability of the block on the various hardware platforms
Introduction Not all blocks are available on all hardware platforms. The blocks available on your
hardware platform can be found in the following tables.
27
Availability of the block
Legend:
+ Yes
- No
28
Availability of the block
Legend:
+ Yes
- No
GE EF + +* +
GT EF + +* +
LE EF + +* +
LT EF + +* +
NE EF + +* +
Legend:
+ Yes
* The data types UINT and UDINT are only available on
Premium: +
Premium TSX P 57 5••.
- No
29
Availability of the block
MULTIME EF + +* +
SUB_***_*** EF + + +
SUB_***_TIME EF + + +
Legend:
+ Yes
Premium: +* The data types UINT and UDINT are only available on
Premium TSX P 57 5••.
- No
30
Availability of the block
Legend:
+ Yes
- No
31
Availability of the block
ACOS EF + + +
ADD EF + +* +
ADD_TIME EF + +* +
ASIN EF + + +
ATAN EF + + +
COS EF + + +
DEC Procedure - +* +
DIV EF + +* +
DIVMOD Procedure - +* +
EXP EF + + +
EXPT_REAL EF + +* +
INC Procedure - +* +
LN EF + + +
LOG EF + + +
MOD EF + +* +
MOVE EF + + +
MUL EF + +* +
NEG EF - +* +
SIGN EF - +* +
SIN EF + + +
SQRT EF DINT: - + +
INT: -
REAL: +
SUB EF + +* +
SUB_TIME EF + +* +
TAN EF + + +
Legend:
+ Yes
32
Availability of the block
Premium: + * The data types UINT and UDINT are only available on
Premium TSX P 57 5••.
- No
LIMIT EF + + * +
LIMIT_IND Procedure - +* +
MAX EF + +* +
MIN EF + +* +
MUX EF + +* +
SEL EF + + +
Legend:
+ Yes
Premium: + * The data types UINT and UDINT are only available on
Premium TSX P 57 5••.
- No
33
Availability of the block
Legend:
+ Yes
- No
34
Availability of the block
CTU EFB + + +
CTU_*** EFB - + * +
CTUD EFB + + +
CTUD_*** EFB - + * +
TOF EFB + + +
TON EFB + + +
TP EFB + + +
Legend:
+ Yes
* The data types UINT and UDINT are only available on
Premium: +
Premium TSX P 57 5••.
- No
35
Availability of the block
BYTE_AS_WORD EF - + +
BYTE_TO_BIT Procedure - + +
BYTE_TO_*** EF + + * +
DATE_TO_STRING EF + + +
DBCD_TO_*** EF - + +
DEG_TO_RAD EF - + +
DINT_AS_WORD Procedure - + +
DINT_TO_*** EF + + * +
DINT_TO_DBCD EF - + +
DINT_TO_STRING EF + + +
DT_TO_STRING EF + + +
DWORD_TO_*** EF + + * +
GRAY_TO_INT EF - + +
INT_AS_DINT EF - + +
INT_TO_*** EF + +* +
INT_TO_BCD EF - + +
INT_TO_DBCD EF - + +
INT_TO_STRING EF + + +
RAD_TO_DEG EF - + +
REAL_AS_WORD Procedure - + +
REAL_TO_*** EF + + * +
REAL_TO_STRING EF + + +
REAL_TRUNC_*** EF + +* +
STRING_TO_*** EF + + +
TIME_AS_WORD Procedure - + +
TIME_TO_*** EF + +* +
TIME_TO_STRING EF + + +
36
Availability of the block
UDINT_TO_*** EF + +* +
UINT_TO_*** EF + +* +
WORD_AS_BYTE Procedure - + +
WORD_AS_DINT EF - + +
WORD_AS_REAL Procedure - + +
WORD_AS_TIME EF - + +
WORD_AS_UDINT EF - +* +
WORD_TO_BIT Procedure - + +
WORD_TO_*** EF + + +
Legend:
+ Yes
- No
Premium: +* The data types UINT and UDINT are only available on Premium
TSX P 57 5••.
37
Availability of the block
38
Arrays
II
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Arrays family.
39
Arrays
40
ADD_***_***: Addition of a number
to elements of a table or addition
of two tables 3
Description
Function The ADD_***_*** function adds a number to the elements of a table or adds two
description tables together.
Available The available functions for adding a number to the elements of a table are as
functions follows:
l ADD_ARINT_INT (addition of each element of a table of INTs to an INT).
l ADD_ARDINT_DINT (addition of each element of a table of DINTs to a DINT).
The available functions for adding the elements of one table to the elements of
another table:
l ADD_ARINT (Sum of the respective elements of both INT tables).
l ADD_ARDINT (Sum of the respective elements of both DINT tables).
41
ADD_***_***
EN ENO
Input_IN2 IN2
42
ADD_***_***
Runtime errors The management of the %S18 (See Description of system bits %S15 to %S21,
p. 448) system bit is identical to that for operations on words or double words.
If an operation between two elements sets the %S18 (See Description of system bits
%S15 to %S21, p. 448) bit (overflow or division by zero), the result for this operation
is incorrect, but the operation on the following elements is carried out correctly.
43
ADD_***_***
44
AND_***_***: Logical AND
between tables and variables
4
Description
Function The AND_***_*** function carries out a logical AND (bit to bit) between:
description l the elements of two tables,
l between a single type variable and the elements of a table,
l between the elements of a table and a single type variable.
Available The functions available in the general library are the following:
functions l AND_AREBOOL (logical AND of two EBOOL tables).
l AND_ARWORD (logical AND of two WORD tables).
l AND_ARWORD_WORD (logical AND of each element of a WORD table with a
WORD).
l AND_ARDWORD_DWORD (logical AND of each element of a DWORD table with a
DWORD).
l AND_ARDWORD (logical AND of two DWORD tables).
45
AND_***_***
Input_IN2 IN2
46
AND_***_***
47
AND_***_***
48
COPY_***_***: Copy on tables
5
Description
Function The COPY_***_*** function copies a series of contiguous elements from one table
description into another table. The tables are of different or identical types and the target zone
is fixed by the parameters of the function.
COPY_ARINT_AREBOOL
49
COPY_***_***
COPY_ARINT_AREBOOL
EN ENO
Begin_Row P1
Element_number N
Destination_Row P2
50
COPY_***_***
Note: if the number of elements to be extracted is greater than the remaining size,
starting from the rankBegin_Row, the function extracts all the elements
fromBegin_Row to the last element of the table.
If the number of elements to be extracted is greater than the space available
starting from the rankDestination_Row, the copy function runs to the last
element of the table.
A negative value of Begin_Row, Element_Number and Destination_Row is
interpreted as null.
51
COPY_***_***
52
DIV_***_***: Division of tables
6
Description
Available The available functions for division of a number by the elements of a table are as
functions follows:
l DIV_INT_ARINT,
l DIV_DINT_ARDINT.
The available functions for division of the elements of a table by a number are as
follows:
l DIV_ARINT_INT,
l DIV_ARDINT_DINT.
The available functions for division of the elements of a table by the respective
elements of another table are as follows:
l DIV_ARINT,
l DIV_ARDINT.
DIV_INT_ARINT
Input_IN1 IN1 OUT Array1
Input_IN2 IN2
53
DIV_***_***
DIV_INT_ARINT
EN ENO
Input_IN2 IN2
54
DIV_***_***
Runtime errors The management of the %S18 (See Description of system bits %S15 to %S21,
p. 448) system bit is identical to that for operations on words or double words. In the
case of division by zero, the value of the result is equal to the value of the numerator.
If an operation between two elements sets the %S18 (See Description of system bits
%S15 to %S21, p. 448) bit (overflow or division by zero), the result for this operation
is incorrect, but the operation on the following elements is carried out correctly.
55
DIV_***_***
56
EQUAL_***: Comparison of two
tables
7
Description
57
EQUAL_****
Array2 IN2
Position P
58
EQUAL_****
Runtime errors When the table contains an invalid value, the result of the function contains -2 and
the bit %S18 (See Description of system bits %S15 to %S21, p. 448) = 1.
59
EQUAL_****
60
FIND_EQ_***: First element of a
table equal to a given value
8
Description
Function The FIND_EQ_*** function searches for the first element of a table equal to a given
description value.
61
FIND_EQ_***
Value1 IN2
Runtime errors When the table contains an invalid value or if Value1 is an invalid value, the result
of the function contains-2 and the bit %S18 (See Description of system bits %S15
to %S21, p. 448 ) = 1.
62
FIND_EQP_***: First element of a
table equal to a value starting from
a given rank 9
Description
Function The FIND_EQP_*** function searches for the first element of a table equal to a
description value starting from a given rank.
63
FIND_EQP_***
Value1 IN2
Begin1 P
64
FIND_EQP_***
Runtime errors When the table contains an invalid value or if Value1 is an invalid value, the result
of the function contains-2 and the bit %S18 (See Description of system bits %S15
to %S21, p. 448) = 1.
65
FIND_EQP_***
66
FIND_GT_***: First element of a
table greater than a given value
10
Description
Function The FIND_GT_*** function searches for the first element of a table greater than a
description given value.
EN ENO
Value1 IN2
67
FIND_GT_***
Runtime errors When the table contains an invalid value or if Value1 is an invalid value, the result
of the function contains-2 and the bit %S18 (See Description of system bits %S15
to %S21, p. 448 ) = 1.
68
FIND_LT_***: First element of a
table less than a given value
11
Description
Function The FIND_LT_*** function searches for the first element of a table less than a
description given value.
69
FIND_LT_***
Value1 IN2
70
FIND_LT_***
Runtime errors When the table contains an invalid value or if Value1 is an invalid value, the result
of the function contains-2 and the bit %S18 (See Description of system bits %S15
to %S21, p. 448) = 1.
71
FIND_LT_***
72
LENGTH_***: Length of a table
12
Description
Function The LENGTH_*** function calculates the length of a table. It is used mainly with
description DFBs when the tables are not explicitly declared.
73
LENGTH_***
Representation Representation:
in ST Length_Array1:= LENGTH_ARINT(Array1);
74
MAX_***: Maximum value of table
elements
13
Description
Function The MAX_*** function searches for the maximum value of the elements of a table.
description
The additional parameters EN and ENO can be configured.
75
MAX_***
Runtime errors When the table contains an invalid value, the result of the function contains -1.#INF
and the bit %S18 (See Description of system bits %S15 to %S21, p. 448) = 1.
76
MIN_***: Minimum value of table
elements
14
Description
Function The MIN_*** function searches for the minimum value of the elements of a table.
description
The additional parameters EN and ENO can be configured.
EN ENO
77
MIN_***
Runtime errors When the table contains an invalid value, the result of the function contains 1.#INF
and the bit %S18 (See Description of system bits %S15 to %S21, p. 448) = 1.
78
MOD_***_***: Remainder of
division of tables
15
Description
Available The available functions for calculation of the remainder of the division of a number
functions by the elements of a table are as follows:
l MOD_INT_ARINT,
l MOD_DINT_ARDINT.
The available functions for the calculation of the remainder of the division of the
elements of a table by a number are as follows:
l MOD_ARINT_INT,
l MOD_ARDINT_DINT.
The available functions for the calculation of the remainder of the division of the
elements of a table by the respective elements of another table are as follows:
l MOD_ARINT,
l MOD_ARDINT.
MOD_INT_ARINT
Input_IN1 IN1 OUT Array1
Input_IN2 IN2
79
MOD_***_***
MOD_INT_ARINT
EN ENO
Input_IN2 IN2
80
MOD_***_***
Runtime errors The management of the %S18 (See Description of system bits %S15 to %S21,
p. 448) system bit is identical to that for operations on words or double words. The
remainder of a division by zero is zero and the system bit is set to 1.
If an operation between two elements sets the %S18 (See Description of system bits
%S15 to %S21, p. 448) bit (overflow or division by zero), the result for this operation
is incorrect, but the operation on the following elements is carried out correctly.
81
MOD_***_***
82
MOVE_***_***: Assignment to
tables
16
Description
Function One of the actions of the MOVE_***_*** function is the assignment of an identical
description value to each element of a table.
83
MOVE_***_***
84
MOVE_***_***: Table conversion
17
Description
Function One of the actions of the MOVE_***_*** function is to convert a table into a value
description or a value into a table.
85
MOVE_***_***
86
MUL_***_***: Multiplication of
tables
18
Description
Available The available functions for the multiplication of the elements of a table by a number
functions are as follows:
l MUL_ARINT_INT,
l MUL_ARDINT_DINT.
The available functions for the multiplication of the elements of a table by the
respective elements of another table are as follows:
l MUL_ARINT,
l MUL_ARDINT.
MUL_ARINT_INT
Input_IN1 IN1 OUT Array1
Input_IN2 IN2
87
MUL_***_***
MUL_ARINT_INT
EN ENO
Input_IN2 IN2
88
MUL_***_***
Runtime errors The management of the %S18 (See Description of system bits %S15 to %S21,
p. 448) system bit is identical to that for operations on words or double words.
If an operation between two elements sets the %S18 (See Description of system bits
%S15 to %S21, p. 448) bit (overflow or division by zero), the result for this operation
is incorrect, but the operation on the following elements is carried out correctly.
89
MUL_***_***
90
NOT_***: Logical negation of
tables
19
Description
Function The NOT_*** function carries out a logical negation (bit to bit) between the
description elements of two tables.
91
NOT_***
92
OCCUR_***: Occurrence of a value
in a table
20
Description
Function The OCCUR_*** function gives the number of elements of a table equal to a given
description value.
Value1 IN2
93
OCCUR_***
94
OR_***_***: Logical OR between
tables and variables
21
Description
Function The OR_***_*** function carries out a logical OR (bit to bit) between:
description l the elements of two tables,
l between a single type variable and the elements of a table,
l between the elements of a table and a single type variable.
Available The functions available in the general library are the following:
functions l OR_AREBOOL (logical OR of two BOOL tables).
l OR_ARWORD (logical OR of two WORD tables).
l OR_ARWORD_WORD (logical OR of each element of a WORD table with a WORD).
l OR_ARDWORD_DWORD (logical OR of each element of a DWORD table with a
DWORD).
l OR_ARDWORD (logical OR of two DWORD tables).
95
OR_***_***
EN ENO
Input_IN2 IN2
96
OR_***_***
97
OR_***_***
98
ROL_***: Rotate shift to left
22
Description
Function The ROL_*** function carries out a rotate shift of the elements of a table in the
description ascending direction of the indices.
Available The functions available in the general library are the following:
functions l ROL_ARWORD,
l ROL_ARDWORD,
l ROL_ARINT,
l ROL_ARDINT,
l ROL_ARREAL.
99
ROL_***
EN ENO
Positions N
Example: Positions = 2.
Note: if the value of Positions is negative
or nil, no shift is carried out.
100
ROR_***: Rotate shift to right
23
Description
Function The ROR_*** function carries out a rotate shift of the elements of a table in the
description descending direction of the indices.
Available The functions available in the general library are the following:
functions l ROR_ARWORD,
l ROR_ARDWORD,
l ROR_ARINT,
l ROR_ARDINT.
l ROR_ARREAL.
101
ROR_***
Positions N
Example: Positions = 2.
Note: if the value of Positions is negative
or nil, no shift is carried out.
102
SORT_***: Ascending or
descending sort
24
Description
Function The SORT_*** function sorts a table in ascending or descending order and
description arranges the sorted elements in this same table.
Direction N
103
SORT_***
104
SUB_***_***: Subtraction from
tables
25
Description
Available The available functions for the subtraction of the elements of a table from a number
functions or of a number from the elements of a table are as follows:
l SUB_INT_ARINT (Subtraction of each element of an INT table from an INT).
l SUB_DINT_ARDINT (Subtraction of each element of a table of DINTs from a
DINT).
l SUB_ARINT_INT (Subtraction of an INT from the elements of a table of INTs).
l SUB_ARDINT_DINT (Subtraction of a DINT from the elements of a table of
DINTs).
The available functions for the subtraction of the elements of a table from the
respective elements of another table are as follows:
l SUB_ARINT (Subtraction of the respective elements of both tables of INTs).
l SUB_ARDINT (Subtraction of the respective elements of both tables of DINTs).
Representation Representation applied to the subtraction of the elements of a table of integers from
in FBD an integer:
SUB_INT_ARINT
Input_IN1 IN1 OUT Array1
Input_IN2 IN2
105
SUB_***_***
Representation Representation applied to the subtraction of the elements of a table of integers from
in LD an integer:
SUB_INT_ARINT
EN ENO
Input_IN2 IN2
Representation Representation applied to the subtraction of the elements of a table of integers from
in IL an integer:
LD Input_IN1
SUB_INT_ARINT Input_IN2
ST Array1
Representation Representation applied to the subtraction of the elements of a table of integers from
in ST an integer:
Array1:= SUB_INT_ARINT(Input_IN1,Input_IN2);
106
SUB_***_***
Runtime errors The management of the %S18 (See Description of system bits %S15 to %S21,
p. 448) system bit is identical to that for operations on words or double words.
If an operation between two elements sets the %S18 (See Description of system bits
%S15 to %S21, p. 448) bit (overflow or division by zero), the result for this operation
is incorrect, but the operation on the following elements is carried out correctly.
107
SUB_***_***
108
SUM_***: Sum of table elements
26
Description
Function The SUM_*** function calculates the sum of the elements of a table.
description
The additional parameters EN and ENO can be configured.
Sum1 = å
j=m
i=n
Array1[j]
Description:
Element Signification
Array1 Table declared in the following way:
ARRAY [n..m] OF ...
109
SUM_***
Runtime errors When the table contains an invalid value, the sum of its elements contains 0.0 and
the bit %S18 (See Description of system bits %S15 to %S21, p. 448) = 1.
When the sum of elements is greater than the maximum authorized value, its value
becomes 1.#INF and the bit %S18 = 1
110
SWAP_***: Permutation of the
bytes of a table
27
Description
Function The SWAP_*** function carries out a permutation of the least significant bytes and
description the most significant bytes of the elements of a table.
111
SWAP_***
112
XOR_***_***: Exclusive OR
between tables
28
Description
Function The XOR_***_*** function carries out an exclusive logical OR (bit to bit) between:
description l the elements of two tables,
l between a single type variable and the elements of a table,
l between the elements of a table and a single type variable.
Available The functions available in the general library are the following:
functions l XOR_AREBOOL (exclusive logical OR of two BOOL tables).
l XOR_ARWORD (exclusive logical OR of two WORD tables).
l XOR_ARWORD_WORD (exclusive logical OR of each element of a WORD table with
a WORD).
l XOR_ARDWORD_WORD (exclusive logical OR of each element of a DWORD table
with a DWORD).
l XOR_ARDWORD (exclusive logical OR of two DWORD tables).
113
XOR_***_***
Input_IN2 IN2
114
XOR_***_***
115
XOR_***_***
116
CLC_INT
III
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the CLC_INT family.
117
CLC_INT
118
Introduction to integer regulation
functions
29
At a Glance
Subject of this This chapter provides the basic notions necessary for the use and implementation
Chapter of the following integer regulation functions:
l PID_INT,
l PWM_INT,
l SERVO_INT.
119
Introduction to regulation EFs
General Introduction
General The regulation functions are the standard elements of the language.
They are used to program regulation loops.
Note: There is no limit on the number of PID_INT functions that are available in
an application. In practice, it is the maximum number of input and output modules
which are accepted by the PLC that limits the number of loops.
120
Introduction to regulation EFs
The signal from the corrector is either directly handled by an analog output card of
the PLC linked to the actuator, or handled via the PWM or SERVO adjustments
depending on the types of actuator to be driven on a discrete output card of the PLC.
HMI console
OUTPUTS
INPUTS
Loop
Adapter
controller
MEASUREMENT
CONTROL
PLC
ACTUATORS
SENSORS
Process to control
121
Introduction to regulation EFs
Flow diagram The following diagram shows the links between tasks to be carried out during the
creation and debugging of a regulation application (the order shown here is for
information purposes only).
File -> Save Use of the control loops Exploitation of process via
Saving of the application the operator terminal
Documentation
Application documentation
122
Introduction to regulation EFs
Programming The regulation function parameters must all be entered. The functions use 3 kinds
rules of parameters:
l read only parameters, considered at the beginning of the function’s execution,
l write only parameters, positioned at the conclusion of the function’s execution,
l the read and write parameters, whose contents are considered at the beginning
of the function’s execution, are then updated by the results of the function.
Parametering The word type input parameters are analog dimensions expressed on the scale [0,
+10000] and can be directly connected to measurement sensors via the %IWr.m.c
words of the analog inputs.
The bit type output parameters can be used to control discrete actuators and can be
directly connected to the %Qr.m.c. type variables.
In the same way, the word type output parameters can be used to control analog
actuators on the scale [0, +10000] and can be directly assigned to %QWr.m.c type
variables.
The ARRAY [0..n] OF INT or %MWi:L integer table type parameters contain the user
parameters and data necessary to the internal operation of the function.
If the length of a table is insufficient, the function is not executed.
Note: In order to keep the adjustment parameters of the regulation on cold start
function, it is necessary to delete the %MWi reset to zero option (in the processor’s
configuration screen)
123
Introduction to regulation EFs
Introduction This paragraph describes the behavior of the functions in different start-up
scenarios:
l cold start (new application, change of cartridge…),
l warm restart (power return without changing the application context),
l first execution after adding a function via modification in connected mode.
Cold start This type of start occurs for a new application or a change of cartridge
On a cold start, the PLC can start automatically in RUN (according to the
application’s configuration). The function correctors have the following security
behavior: manual mode, outputs at 0. In addition, this supports the switching of the
PLC into RUN mode without carrying out the PID adjustment, then its debugging
with the operator terminal (the adjustment can only be performed in RUN).
Warm restart This type of restart occurs for a power return, without changing the application
context.
With a power return after an outage (regardless of how long it lasted) and if the
application context is not lost or modified, the functions go back to their state before
the outage. If the user wants to use another type of behavior, it is his responsibility
to test the %S1 system bit and to associate the required processing with it (forcing
in manual mode…).
Note: The PLC’s time-and-date stamp allows you find out the duration of the last
outage.
Adding a new Following the addition of a new function regulation call in connected mode, an
call in connected identical initialization to the case of the cold start is carried out.
mode
Note: In order to be seen as a new function, this must use a new parameter table.
Therefore, the removal of a PID_INT function, followed by the addition of a
PID_INT function that uses the same parameter table is not considered as an
addition of a new PID. In this case the PID is executed in the same state and with
the same parameters as the preceding PID.
124
PID_INT: PID controller
30
Description
125
PID_INT
Function description
Function The PID_INT function carries out PID-type regulation on INT type inputs and
description outputs.
The measurement and the setpoint are analog data in [0-10000] format and
generate an analog command in the same format.
Note:
l The display parameters used by the operator terminal are shown in physical
units.
l For a correct PID operation, you must stay within the scale of [0-1000] for the
measurement and the setpoint.
l The PID function can be entered in any periodic task (MAST or FAST). The
function does not have to be conditioned.
126
PID_INT
Operating The following illustration provides the operating synoptic for the PID function.
synoptic
TS
CORRECTOR P.I.D.
TI
The Setpoint branch
Deviation +
INTERNAL 10000 Integrated
SETPOINT + + KP
Limiter
SET POINT SETPOINT - ρ Derivative action
0 USED on deviation +
S.P
1 TD
MEASUREMENT 0 d
USED Derivative PV_DEV dt
action Derived
INTERNAL on
MEASUREMENT Process
value The PID action
PROCESS The Measurement branch
VALUE
P.V
The PID operating modes
OUT_MAX
1
Limiter AUTO
OUTP
OUT_MIN 0
OUT_MAN
Monitoring without step by step of the command on switching from Auto ->Manu
127
PID_INT
Representation Representation:
in FBD
PID_INT
Representation Representation:
in LD
PID_INT
EN ENO
Input_Unit UNIT
Input_PV PV
Representation Representation:
in IL LD Input_Tag
PID_INT Input_Unit, Input_PV, In_Out_Auto, In_Out_Para,
PID_Out
Representation Representation:
in ST PID_INT(Input_Tag, Input_Unit, Input_PV, In_Out_Auto,
In_Out_Para, PID_Out);
128
PID_INT
129
PID_INT
Description of The table below presents the different parameters of the PARA table:
PARA Table
Parameter Rank Function
SP PARA[0] Internal setpoint in 0 - 10000 format.
OUT_MAN PARA[1] Value of the manual output of the PID (between 1 and 1000).
KP PARA[2] Proportional gain of the PID (x100), signed without unit (-
10000<KP<+10000). The Kp sign determines the direction of
the PID’s action (negative: forward, positive: reverse).
TI PARA[3] The PID’s integral time (between 0 and 20000) is shown in 0.1
seconds.
TD PARA[4] The PID’s derivative time (between 0 and 10000) is shown in
0.1 seconds.
TS PARA[5] The PID’s sampling period (between 1 and 32000) is shown in
0.01 seconds. The real sampling period will be the multiple of
the period of the task in which the PID closest to the TS is
introduced.
OUT_MAX PARA[6] Upper limit of the PID’s output in automatic (between 0 and
10000).
OUT_MIN PARA[7] Lower limit of the PID’s output in automatic (between
0 and 10000).
PV_DEV PARA[8].0 Derived action choice 0 = on process variable, 1 = on
deviation.
NO_BUMP PARA[8].4 Bumpless or non-bumpless mode.
0 = non-bumpless, 1 = bumpless.
DEVAL_MMI PARA[8].8 = 1: inhibits the acknowledgement of the PID by the Human
Machine Interface.
= 0: the PID is operated by the Human Machine Interface.
This bit makes it possible to avoid performing scale
conversions on the PIDs not operated by the terminal, and to
select the operated PIDs, especially when there are more than
9 PIDs in the application.
PV_SUP* PARA[9] Upper limit of the measurement scale’s range, in a physical unit
(x100) (between –9 999 999 and +9 999 999).
PV_INF* PARA[11] These two integers are, respectively, the most significant and
PARA[12] least significant of a double integer, that is the lower limit of the
measurement scale's range, in a physical unit (x100) (between
-9 99 999 and + 9 999 999).
130
PID_INT
Note:
l The other parameters that are used by the PID’s internal management must
never be modified by the application.
l The values used by the terminal are multiplied by 100 in order to support a
display with 2 figures after the decimal point on the terminal (the terminal does
not use floating point format but supports a fixed comma format).
The settings on the scale only take place on modification of one of the setpoints (SP
or DOP_SP).
The algorithm without the integral action (TI = 0) carries out the following operation:
For Then the output With
The algorithm with the integral action (TI <0) carries out the following operation:
For Then the output With
On a cold start, the PID starts off again in manual, with the output at 0. To impose
the automatic mode or a manual output that is not at 0 after a cold start, you will have
to program the initialization sequence after the PID call.
131
PID_INT
132
PWM_INT: Pulse width
modulation of a numerical value
31
Description
Function The PWM_INT function carries out pulse width regulation on a Discrete output. It is
description a function that formats a PID output.
The pulse width depends on the PID’s output (The PWM function’s INP input) and
the modulation period.
Note: the PWM_INT function can be entered in any periodic task (MAST or FAST).
The function does not have to be conditioned.
Operating The following diagram shows the operating synoptic of the PWM function:
synoptic
PV
SP
T_MOD
133
PWM_INT
Representation Representation:
in FBD
PWM_INT
Input_INP INP PW_O PW_O_Out
In_Out_Para PARA PARA In_Out_Para
Representation Representation:
in LD
PWM_INT
EN ENO
Representation Representation:
in IL LD Input_INP
PWM_INT In_Out_Para, PW_O_Out
Representation Representation:
in ST PWM_INT(Input_INP, In_Out_Para, PW_O_Out);
134
PWM_INT
135
PWM_INT
Pulse widths To each Top of the T_MOD modulation period, the activation period in 10-3 seconds
of the PW_O_Out (PW_O) output is calculated according to the following formula:
State 1 of the gap (shown in 10 -2 seconds) = INP * T_MOD / 1000
PW_O
Modulation period
Time
Pulse Width
Practical rules T_MOD = TS (where TS is the sampling period of the upstream PID).
The period of the current task (expressed in 10 -3 seconds) is equal to:
(Required resolution)* 10 * T_MOD.
The PID is in the MAST task, the MAST’s period is 50*10-3 s, TS = 500*10-2 s and
the required resolution is 1/50 (a T_MOD period must contain at least 50 periods of
the current task).
The period of the task in which the PWM is introduced must be less than
500 * 10 / 50 =100 10-3 s.
The PWM function can therefore be programmed in the MAST task.
The resolution will be 1/100.
136
SERVO_INT: Servo drive function
32
Description
Function The SERVO_INT function carries out a regulation with a motor-type actuator driven
description by two Discrete outputs (UP and DOWN).
Note:
l A SERVO_INT function can be entered in any periodic task (MAST or FAST).
The function does not have to be conditioned.
l It must be connected in tandem with the analog output of a PID. It cannot be
used alone.
When there is a copy of a position, the valve’s position is locked via the Input_Inp
(setpoint) and Input_Pot (position measurement) inputs.
When the copy does not physically exist, the algorithm no longer uses the PID’s
absolute output but the output’s variation. The Out_Up output (or Out_Down,
according to the variation sign) is set to 1 for a length of time proportional to the
actuator opening time and to the variation of the value. Also, the notion of minimum
pulse time is introduced.
Representation Representation:
in FBD
SERVO_INT
Input_Inp INP UP Out_Up
Input_Pot POT DOWN Out_Down
In_Out_Pid PID PID In_Out_Pid
In_Out_Para PARA PARA In_Out_Para
137
SERVO_INT
Representation Representation:
in LD
SERVO_INT
EN ENO
Representation Representation:
in IL LD Input_Inp
SERVO_INT Input_Pot, In_Out_Pid, In_Out_Para, Out_Up, Out_Down
Representation Representation:
in ST SERVO_INT(Input_Inp, Input_Pot, In_Out_Pid, In_Out_Para,
Out_Up, Out_Down);
138
SERVO_INT
139
SERVO_INT
Principle of The SERVO_INT function locks the motor’s position according to a setpoint of the
operating with a Input_Inp (INP) position from a PID’s output in [0 - 10000] format, and to a
position copy Input_Pot (POT) position measurement.
The locking algorithm is a relay with hysteresis.
In this case, the PID, T_MOTOR and T_MINI parameters are not used.
SERVO
PV
OUTP INP UP
PID +
SP
-
DOWN
POT HYST
Principle of In this case, the SERVO_INT function is synchronized with the upstream PID by
operating using the PID parameter table passed on to the SERVO_INT function as a
without a parameter.
position copy
(POT= -10000) The algorithm receives in input the PID’s variation output and converts it into pulse
period, according to the following formula:
T_IMP (expressed in 10-3 s) = OUT x T_MOTOR / 1000
The acquired period is added to the remaining period of the preceding cycles: In fact,
what is not "consumed" in a cycle is memorized for the following cycles. This
ensures correct operation, especially where there are sudden variations in the
command (e.g.: PID setpoint scale division) and in manual mode.
140
SERVO_INT
+2% +2%
1 2 3 4 5
UP
5s 1s
DOWN
1s
T_MOTOR = 25 s
T_MINI = 1 s
Label Description
1 The PID output variation is +20 % (T_MOTOR pulse =25 s for a 100 % variation).
In this case, the pulse affects the UP output for a period of 5 s.
2 The PID variation is +2 %, which would correspond to a pulse of 0.5 s. This pulse
is less than T_MINI (=1 s.), and it does not affect the outputs.
3 A second variation of +2 % appears and the function adds this variation to the
previous one (which corresponded to a variation less than the minimal value),
which corresponds to a positive global variation of +4 %, and therefore to a pulse
of 1 s on the UP output.
4 A variation of -24 % appears and the activated pulse is therefore of 6 s on the
DOWN output.
5 Before the following second has elapsed, another variation of +22 % brings the
system back to a global variation of 2 % < the variation of T_MINI (4 %). The
function finishes carrying out the minimal pulse of 1 s.
Note 1: The SERVO_INT function does not manage the position limits. These must
be managed by the application. If a limit is detected, you must force the
corresponding output to 0 (UP for the high limit, DOWN for the low limit).
141
SERVO_INT
OPERATE
SERVO_INT(Outp,%IW0.3.1,%Q0.2.1,%Q0.2.1,%Q0.2.2,>>)
(* Management of limits *)
Limit_up %Q0.2.1
Limit_down %Q0.2.2
R
Note 2: It is possible to switch from the operating mode with copy to the mode
without copy (for example: when a copy error occurs, go to mode without copy).
142
Comparison
IV
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Comparison family.
143
Comparison
144
EQ: Equal to
33
Description
Function This function checks the inputs for equality, i.e. the output becomes "1" if there is
description equality at all inputs; otherwise, the output remains at "0".
The data types of all input values must be identical.
The number of inputs can be increased to a maximum of 31.
EN and ENO can be configured as additional parameters.
Formula OUT = 1, if (IN1 = IN2) & (IN2 = IN3) & .. & (IN(n-1) = INn)
Representation Representation:
in FBD EQ
Value1 IN1 OUT Result
Value2 IN2
Representation Representation:
in LD
EQ
EN ENO
Result
Value1 IN1 OUT
Value2 IN2
145
EQ
Representation Representation:
in IL LD Value1
EQ Value2
ST Result
Representation Representation:
in ST Result := EQ (Value1, Value2) ;
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451 ).
146
GE: Greater than or equal to
34
Description
Function The function checks the values of successive inputs for a decreasing sequence or
description equality.
The data types of all input values must be identical.
The number of inputs can be increased to a maximum of 31.
When comparing variables of the BOOL, BYTE, WORD, DWORD, INT, DINT, UINT,
UDINT, REAL, TIME, DATE, DT and TOD data types, the values are compared with
each other.
STRING variables are compared using the alphabet; variables at the end of the
alphabet are higher priority expressions than those at the front.
EN and ENO can be configured as additional parameters.
Formula OUT = 1, if (IN1 ≥ IN2) & (IN2 ≥ IN3) & .. & (IN(n-1) ≥ INn)
Representation Representation:
in FBD
GE
Value1 IN1 OUT Result
Value2 IN2
147
GE
Representation Representation:
in LD
GE
EN ENO
Result
Value1 IN1 OUT
Value2 IN2
Representation Representation:
in IL LD Value1
GE Value2
ST Result
Representation Representation:
in ST Result := GE (Value1, Value2) ;
148
GE
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451).
149
GE
150
GT: Greater than
35
Description
Function The function checks the values of successive inputs for a decreasing sequence.
description The data types of all input values must be identical.
The number of inputs can be increased to a maximum of 31.
When comparing variables of the BOOL, BYTE, WORD, DWORD, INT, DINT, UINT,
UDINT, REAL, TIME, DATE, DT and TOD data types, the values are compared with
each other.
STRING variables are compared using the alphabet; variables at the end of the
alphabet are higher priority expressions than those at the front.
EN and ENO can be configured as additional parameters.
Formula OUT = 1, if (IN1 > IN2) & (IN2 > IN3) & .. (IN(n-1) > INn)
Representation Representation:
in FBD GT
Value1 IN1 OUT Result
Value2 IN2
151
GT
Representation Representation:
in LD
GT
EN ENO
Result
Value1 IN1 OUT
Value2 IN2
Representation Representation:
in IL LD Value1
GT Value2
ST Result
Representation Representation:
in ST Result := GT (Value1, Value2) ;
152
GT
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451).
153
GT
154
LE: Less than or equal to
36
Description
Function The function checks the values of successive inputs for an increasing sequence or
description equality.
The data types of all input values must be identical.
The number of inputs can be increased to a maximum of 31.
When comparing variables of the BOOL, BYTE, WORD, DWORD, INT, DINT, UINT,
UDINT, REAL, TIME, DATE, DT and TOD data types, the values are compared with
each other.
STRING variables are compared using the alphabet; variables at the end of the
alphabet are higher priority expressions than those at the front.
EN and ENO can be configured as additional parameters.
Formula OUT = 1, if (IN1 ≤ IN2) & (IN2 ≤ IN3) & .. & (IN(n-1) ≤ INn)
Representation Representation:
in FBD LE
Value1 IN1 OUT Result
Value2 IN2
155
LE
Representation Representation:
in LD
LE
EN ENO
Result
Value1 IN1 OUT
Value2 IN2
Representation Representation:
in IL LD Value1
LE Value2
ST Result
Representation Representation:
in ST Result := LE (Value1, Value2) ;
156
LE
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451).
157
LE
158
LT: Less than
37
Description
Function The function checks the values of successive inputs for an increasing sequence.
description The data types of all input values must be identical.
The number of inputs can be increased to a maximum of 31.
When comparing variables of the BOOL, BYTE, WORD, DWORD, INT, DINT, UINT,
UDINT, REAL, TIME, DATE, DT and TOD data types, the values are compared with
each other.
STRING variables are compared using the alphabet; variables at the end of the
alphabet are higher priority expressions than those at the front.
EN and ENO can be configured as additional parameters.
Formula OUT = 1, if (IN1 < IN2) & (IN2 < IN3) & .. & (IN(n-1) < INn)
Representation Representation:
in FBD LT
Value1 IN1 OUT Result
Value2 IN2
159
LT
Representation Representation:
in LD
LT
EN ENO
Result
Value1 IN1 OUT
Value2 IN2
Representation Representation:
in IL LD Value1
LT Value2
ST Result
Representation Representation:
in ST Result := LT (Value1, Value2) ;
160
LT
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451).
161
LT
162
NE: Not equal to
38
Description
Representation Representation:
in FBD NE
Value1 IN1 OUT Result
Value2 IN2
Representation Representation:
in LD
NE
EN ENO
Result
Value1 IN1 OUT
Value2 IN2
Representation Representation:
in IL LD Value1
NE Value2
ST Result
163
NE
Representation Representation:
in ST Result := NE (Value1, Value2) ;
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451 ).
164
Date & Time
V
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Date & Time family.
165
Date & Time
166
ADD_***_TIME: Addition of a
duration to a date
39
Description
Time_to_Add IN2
167
ADD_***_TIME
Runtime errors For the type TOD, there is a change of day if Result_Value is outside the
authorized values. In this case, the system bit %S18 (See Description of system bits
%S15 to %S21, p. 448) is set at 1 and the value of Result_Value is only
significant with a modulo 24:00:00.
For the type DT, if Result_Value is outside the interval of authorized values, the
system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
and the value of Result_Value is equal to the maximum limit.
If one of the input parameters cannot be interpreted and is inconsistent with the
function format then the system bit %S18 (See Description of system bits %S15 to
%S21, p. 448) is set at 1 and Result_Value applies:
l 00:00:00 for the type TOD.
l 00001-01-01-00:00:00 for the type DT.
168
DIVTIME: Division
40
Description
Function The function divides the value at the TIME_variable (data type TIME) input with
description the value at the Divisor input and assigns the result to the output.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD DIVTIME
TIME_variable IN1 OUT Quotient
Divisor IN2
Representation Representation:
in LD
DIVTIME
EN ENO
Divisor IN2
Representation Representation:
in IL LD TIME_variable
DIVTIME Divisor
ST Quotient
169
DIVTIME
Representation Representation:
in ST Quotient := DIVTIME (TIME_variable, Divisor) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l an invalid division by 0 is executed (all available data types)
or
l an unauthorized floating point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
Note: For a list of all block error codes and values, see Date & Time, p. 442.
170
MULTIME: Multiplication
41
Description
Function The function multiplies the input values and assigns the result to the output.
description The data type of the 1st input value (TIME_variable) must be a TIME data type.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD MULTIME
TIME_variable IN1 OUT Product
Factor IN2
Representation Representation:
in LD
MULTIME
EN ENO
Factor IN2
Representation Representation:
in IL LD TIME_variable
MULTIME Factor
ST Product
171
MULTIME
Representation Representation:
in ST Product := MULTIME (TIME_variable, Factor) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range at the output has been exceeded (all available data types)
or
l an unauthorized floating-point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
Note: For a list of all block error codes and values, see Date & Time, p. 442.
172
SUB_***_***: Calculates the time
difference between two dates or
times 42
Description
Function The SUB_***_*** function calculates the time difference between two dates or
description times.
Input_IN2 IN2
173
SUB_***_***
Runtime errors If Delay1 exceeds the maximum value allowed for a TIME format, there is overrun,
then Delay1 = 0 and the system bit %S18 (See Description of system bits %S15 to
%S21, p. 448) is set to 1.
If one of the input parameters is not interpretable and coherent in the function
format, then Delay1 = 0 and the system bit %S18 (See Description of system bits
%S15 to %S21, p. 448) is set to 1.
174
SUB_***_TIME: Subtraction of a
duration from a date
43
Description
Time_to_Sub IN2
175
SUB_***_TIME
Runtime errors For the type TOD, there is a change of day if Result_Value is outside the interval
of authorized values. In this case the system bit %S18 (See Description of system
bits %S15 to %S21, p. 448 ) is set at 1 and the value of Result_Value is only
significant with a modulo 24:00:00.
For the type DT, if Result_Value is outside the interval of authorized values, the
system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
and the value of Result_Value is equal to the minimum limit.
If one of the input parameters cannot be interpreted and is inconsistent with the
function format then the system bit %S18 (See Description of system bits %S15 to
%S21, p. 448) is set at 1 and Result_Value applies:
l 00:00:00 for the type TOD.
l 00001-01-01-00:00:00 for the type DT.
176
Logic
VI
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Logic family.
177
Logic
178
AND: AND function
44
Description
Function The function for a bit-by-bit AND link of the bit sequences at the inputs and assigns
description the result to the output.
The data types of all input values and output values must be identical.
The number of inputs can be increased to a maximum of 32.
EN and ENO can be configured as additional parameters.
Further available When using a Premium PLC, the following functions are also available in the
functions Obsolete library:
l AND_DINT
l AND_INT
The functionality of these functions is identical to the function AND.
Representation Representation:
in FBD
AND
Value_1 IN1 OUT Result
Value_2 IN2
179
AND
Representation Representation:
in LD
AND
EN ENO
Value_2 IN2
Representation Representation:
in IL LD Value_1
AND Value_2
ST Result
Representation Representation:
in ST Result := AND (Value_1, Value_2) ;
180
F_TRIG: Falling edge detection
45
Description
Function This function block is used for the detection of falling edges 1 -> 0.
description Output Q becomes "1" if there is a transition from "1" to "0" at the CLK input. The
output will remain at "1" from one function block execution to the next; the output
subsequently returns to "0".
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD F_TRIG_Instance
F_TRIG
ClockInput CLK Q Output
Representation Representation:
in LD F_TRIG_Instance
F_TRIG
EN ENO
ClockInput Output
CLK Q
Representation Representation:
in IL CAL F_TRIG_Instance (CLK:=ClockInput, Q=>Output)
Representation Representation:
in ST F_TRIG_Instance (CLK:=ClockInput, Q=>Output) ;
181
F_TRIG
182
FE: Detection of Falling Edge
46
Description
Function The FE function detects the passage from 1 to 0 (Falling Edge) of the bit associated
description with it.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
FE
Start_Button IN OUT Start_Pulse
Representation Representation:
in LD
Start_Button Start_Pulse
N
Representation Representation:
in IL LD Start_Button
FE
ST Start_Pulse
Representation Representation:
in ST Start_Pulse:= FE (Start_Button);
183
FE
Start_Button
Start_Pulse
T T is the Start_Button update
delay
T T is equal to a PLC cycle time for an input and is the delay between two assignments for
a discrete output or an internal bit.
184
NOT: Negation
47
Description
Function The function negates the input bit sequence bit-by-bit and assigns the result to the
description output.
The data types of the input and output values must be identical.
EN and ENO can be configured as additional parameters.
Further available The Obsolete library provides the following additional functions:
functions l NOT_DINT
l NOT_INT
The functionality of these functions is identical to the function NOT.
Representation Representation:
in FBD NOT
Value IN OUT NegValue
Representation Representation:
in LD
NOT
EN ENO
185
NOT
Representation Representation:
in IL LD Value
NOT
ST NegValue
Representation Representation:
in ST NegValue := NOT (Value) ;
186
OR: OR function
48
Description
Function The function for a bit OR link of the bit sequences at the inputs and returns the result
description at the output.
The data types of all input values and output values must be identical.
The number of inputs can be increased to a maximum of 32.
EN and ENO can be configured as additional parameters.
Further available When using a Premium PLC, the following functions are also available in the
functions Obsolete library:
l OR_DINT
l OR_INT
The functionality of these functions is identical to the function OR.
Representation Representation:
in FBD
OR
Value_1 IN1 OUT Result
Value_2 IN2
187
OR
Representation Representation:
in LD
OR
EN ENO
Value_2 IN2
Representation Representation:
in IL LD Value_1
OR Value_2
ST Result
Representation Representation:
in ST Result := OR (Value_1, Value_2) ;
188
R_TRIG: Rising edge detection
49
Description
Function This function block is used for the detection of rising edges 0 -> 1.
description Output Q becomes "1" if there is a transition from "0" to "1" at the CLK input. The
output remains at "1" from one function block execution to the next (one cycle); the
output subsequently returns to "0".
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD R_TRIG_Instance
R_TRIG
ClockInput CLK Q Output
Representation Representation:
in LD R_TRIG_Instance
R_TRIG
EN ENO
ClockInput Output
CLK Q
Representation Representation:
in IL CAL R_TRIG_Instance (CLK:=ClockInput, Q=>Output)
Representation Representation:
in ST R_TRIG_Instance (CLK:=ClockInput, Q=>Output) ;
189
R_TRIG
190
RE: Detection of Rising Edge
50
Description
Function The RE function detects the passage from 0 to 1(Rising Edge) of the bit associated
description with it.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
RE
Start_Button IN OUT Start_Pulse
Representation Representation:
in LD
Start_Button Start_Pulse
P
Representation Representation:
in IL LD Start_Button
RE
ST Start_Pulse
Representation Representation:
in ST Start_Pulse := RE (Start_Button);
191
RE
Start_Button
Start_Pulse
T T is the Start_Button update
delay
T T is equal to a PLC cycle time for an input and is the delay between two assignments for
a discrete output or an internal bit.
192
RESET: Setting of a bit to 0
51
Description
Function The RESET function sets the bit associated with it to zero.
description
Representation Representation:
in FBD
RESET
OUT Bit_to_Reset
Representation Representation:
in LD
Bit_to_Reset
R
Representation Representation:
in IL CAL RESET(Bit_to_Reset)
Representation Representation:
in ST RESET (Bit_to_Reset);
193
RESET
194
ROL: Rotate left
52
Description
Function This function rotates the bit pattern at the IN input circularly to the left by n bits (value
description at input Number).
System bit %S17 is used as CARRY bit, i.e. the status of the bit that is shifted out is
stored there.
The data types of the IN input and OUT output must be identical.
Note: Because of IEC 61131-3 conformity, this function also works with the BOOL
data type. This is not significant here.
Further available When using a Premium PLC, the following functions are also available in the
functions Obsolete library:
l ROL_DINT
l ROL_INT
The functionality of these functions is identical to the function ROL.
Representation Representation:
in FBD ROL
InputPattern IN OUT OutputPattern
Number N
195
ROL
Representation Representation:
in LD
ROL
EN ENO
Number N
Representation Representation:
in IL LD InputPattern
ROL Number
ST OutputPattern
Representation Representation:
in ST OutputPattern := ROL (InputPattern, Number) ;
196
ROR: Rotate right
53
Description
Function This function rotates the bit pattern at the In input circularly to the right by n bits
description (value at input Number).
System bit %S17 is used as CARRY bit, i.e. the status of the bit that is shifted out is
stored there.
The data types of the IN input and OUT output must be identical.
Note: Because of IEC 61131-3 conformity, this function also works with the BOOL
data type. This is not significant here.
Further available When using a Premium PLC, the following functions are also available in the
functions Obsolete library:
l ROR_DINT
l ROR_INT
The functionality of these functions is identical to the function ROR.
Representation Representation:
in FBD ROR
InputPattern IN OUT OutputPattern
Number N
197
ROR
Representation Representation:
in LD
ROR
EN ENO
Number N
Representation Representation:
in IL LD InputPattern
ROR Number
ST OutputPattern
Representation Representation:
in ST OutputPattern := ROR (InputPattern, Number) ;
198
RS: Bistable function block, reset
dominant
54
Description
Function The function block is used as RS memory with the property "Reset dominant".
description Output Q1 becomes "1" when the S input becomes "1". This state remains even if
input S reverts back to "0". Output Q1 changes back to "0" when input R1 becomes
"1". If the inputs S and R1 are "1" simultaneously, the dominating input R1 will set
the output Q1 to "0".
When the function block is called for the first time, the initial state of Q1 is "0".
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD RS_Instance
RS
Set S Q1 Output
Reset R1
Representation Representation:
in LD RS_Instance
RS
EN ENO
Set Output
S Q1
Reset
R1
Representation Representation:
in IL CAL RS_Instance (S:=Set, R1:=Reset, Q1=>Output)
199
RS
Representation Representation:
in ST RS_Instance (S:=Set, R1:=Reset, Q1=>Output) ;
200
SET: Setting of a bit to 1
55
Description
Representation Representation:
in FBD
SET
OUT Bit_to_Set
Representation Representation:
in LD
Bit_to_Set
S
Representation Representation:
in IL CAL SET(Bit_to_Set)
Representation Representation:
in ST SET (Bit_to_Set);
201
SET
202
SHL: Shift left
56
Description
Function This function shifts the bit pattern at the IN input to the left by n bits (value at input N).
description System bit %S17 is used as CARRY bit, i.e. the status of the bit that is shifted out is
stored there.
Zeros are filled in from the right.
The data types of the IN input and OUT output must be identical.
Note: Because of IEC 61131-3 conformity, this function also works with the BOOL
data type. This is not significant here.
Further available Additionally, the Obsolete library provides the following functions:
functions l SHL_DINT
l SHL_INT
The functionality of these functions is identical to the function SHL.
Representation Representation:
in FBD
SHL
IntputPattern IN OUT ShiftedPattern
Number N
203
SHL
Representation Representation:
in LD
SHL
EN ENO
Number N
Representation Representation:
in IL LD IntputPattern
SHL Number
ST ShiftedPattern
Representation Representation:
in ST ShiftedPattern := SHL (IntputPattern, Number) ;
204
SHR: Shift right
57
Description
Function This function shifts the bit pattern at the IN input to the right by n bits (value at
description input N).
System bit %S17 is used as CARRY bit, i.e. the status of the bit that is shifted out is
stored there.
Zeros are filled in from the left.
Special case: If in the dialog box Tools → Project Settings → Language
extensions, the option INT/DINT is activated instead of ANY_BIT valid and input
IN uses data types INT or DINT, then zeros are filled in from the left when the most
significant bit is 0. If the most significant bit is 1, ones are filled in. The most
significant bit contains the sign bit for data types INT and DINT. This guarantees
that the sign is not lost when shifting. If the sign is not to be considered and zeros
are always filled in, the function SHRZ_*** from the Obsolete library can be used
for Premium controllers.
The data types of the In input and OUT output must be identical.
Note: Because of IEC 61131-3 conformity, this function also works with the BOOL
data type. This is not significant here.
Representation Representation:
in FBD
SHR
IntputPattern IN OUT ShiftedPattern
Number N
205
SHR
Representation Representation:
in LD
SHR
EN ENO
Number N
Representation Representation:
in IL LD IntputPattern
SHR Number
ST ShiftedPattern
Representation Representation:
in ST ShiftedPattern := SHR (IntputPattern, Number) ;
206
SR: Bistable function block, set
dominant
58
Description
Function The function block is used as SR memory with the property "Set dominant".
description Output Q1 becomes "1" when the S1 input becomes "1". This state remains even if
input S1 reverts back to "0". Output Q1 changes back to "0" when input R becomes
"1". If the inputs S1 and R are both "1" simultaneously, the dominating input S1 will
set the output Q1 to "1".
When the function block is called for the first time, the initial state of Q1 is "0".
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD SR_Instance
SR
Set S1 Q1 Output
Reset R
Representation Representation:
in LD SR_Instance
SR
EN ENO
Set Output
S1 Q1
Reset
R
Representation Representation:
in IL CAL SR_Instance (S1:=Set, R:=Reset, Q1=>Output)
207
SR
Representation Representation:
in ST SR_Instance (S1:=Set, R:=Reset, Q1=>Output) ;
208
TRIGGER: Detection of all edges
59
Description
Function The function block recognizes all types of edges (1 -> 0 and 0 -> 1) at the CLK input.
description At a rising edge, a transition from "0" to "1"occurs on the CLK input; at a falling edge,
a transition from "1" to "0" occurs on the CLK input.
At any edge, the EDGE output becomes "1".
At a rising edge, the EDGE output and the RISE output become "1".
At a falling edge, the EDGE output and the FALL output become "1". If no edge
occurs, all outputs are "0".
Representation Representation:
in FBD TRIGGER_Instance
TRIGGER
ClockInput CLK RISE RisingEdge
EDGE AnyEdge
FALL FallingEdge
209
TRIGGER
Representation Representation:
in LD TRIGGER_Instance
TRIGGER
EN ENO
ClockInput RisingEdge
CLK RISE
AnyEdge
EDGE
FallingEdge
FALL
Representation Representation:
in IL CAL TRIGGER_Instance (CLK:=ClockInput, RISE=>RisingEdge,
EDGE=>AnyEdge, FALL=>FallingEdge)
Representation Representation:
in ST TRIGGER_Instance (CLK:=ClockInput, RISE=>RisingEdge,
EDGE=>AnyEdge, FALL=>FallingEdge) ;
210
XOR: Exclusive OR function
60
Description
Function The function for a bit XOR link of the bit sequences at the inputs and returns the
description result at the output.
The data types of all input values and output values must be identical.
The number of inputs can be increased to a maximum of 32.
EN and ENO can be configured as additional parameters.
Further available When using a Premium PLC, the following functions are also available in the
functions Obsolete library:
l XOR_DINT
l XOR_INT
The functionality of these functions is identical to the function XOR.
Representation Representation:
in FBD
XOR
Value_1 IN1 OUT Result
Value_2 IN2
211
XOR
Representation Representation:
in LD
XOR
EN ENO
Value_2 IN2
Representation Representation:
in IL LD Value_1
XOR Value_2
ST Result
Representation Representation:
in ST Result := XOR (Value_1, Value_2) ;
212
Mathematics
VII
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Mathematics family.
213
Mathematics
214
ABS: Absolute value computation
61
Description
Function The function computes the absolute value of the input value and assigns the result
description to the output.
The data types of the input and output values must be identical.
Note: Because of IEC 61131-3 conformity, this function also works with the UINT
and UDINT data types. This is not significant here.
Formula
OUT = IN
Representation Representation:
in FBD
ABS
Value IN OUT Result
Representation Representation:
in LD
ABS
EN ENO
215
ABS
Representation Representation:
in IL LD Value
ABS
ST Result
Representation Representation:
in ST Result := ABS (Value) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l a value is below a limit value (data types INT and DINT)
or
l an unauthorized floating point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
216
ACOS: Arc cosine
62
Description
Function The ACOS function calculates the principal arc cosine of a real value. The result is
description given in the form of an angle in radians.
Representation Representation:
in FBD
ACOS_REAL
Cos_Value IN OUT Angle
217
ACOS
Representation Illustration:
in LD
ACOS_REAL
EN ENO
Representation Representation:
in IL LD Cos_Value
ACOS_REAL
ST Angle
Representation Representation:
in ST Angle:= ACOS_REAL(Cos_Value);
Runtime errors When the absolute value Cos_Value is greater than 1, the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) changes to 1 and the system
word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
indicates the type of fault.
218
ADD: Addition
63
Description
Function The function adds the input values and assigns the result to the output.
description The data types of all input values and output values must be identical.
The number of inputs can be increased to a maximum of 32 for all functions.
For addition with values of the TIME data type, there is the block ADD_TIME
(See ADD_TIME: Addition, p. 221)
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
ADD
Value1 IN1 OUT Sum
Value2 IN2
Representation Representation:
in LD
ADD
EN ENO
Value2 IN2
219
ADD
Representation Representation:
in IL LD Value1
ADD Value2
ST Sum
Representation Representation:
in ST Sum := ADD (Value1, Value2) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range on the output is exceeded (all available data types)
or
l an unauthorized floating point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
220
ADD_TIME: Addition
64
Description
Function This function adds 2 input values of data type TIME and assigns the result to the
description output (also data type TIME).
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
ADD_TIME
TimeValue1 IN1 OUT Sum
TimeValue2 IN2
Representation Representation:
in LD
ADD_TIME
EN ENO
TimeValue2 IN2
Representation Representation:
in IL LD TimeValue1
ADD_TIME TimeValue2
ST Sum
221
ADD_TIME
Representation Representation:
in ST Sum := ADD_TIME (TimeValue1, TimeValue2) ;
Runtime error System bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
if the value range at the output is exceeded.
222
ASIN: Arc sine
65
Description
Function The ASIN function calculates the principal sine arc of a real value. The result is given
description in the form of an angle in radians.
The function call can also be carried out by ASIN_REAL.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
ASIN_REAL
Sin_Value IN OUT Angle
Representation Representation:
in LD
ASIN_REAL
EN ENO
223
ASIN
Representation Representation:
in IL LD Sin_Value
ASIN_REAL
ST Angle
Representation Representation:
in ST Angle:= ASIN_REAL(Sin_Value);
Runtime errors When the absolute value Sin_Value is greater than 1, the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) changes to 1 and the system
word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
indicates the type of fault.
224
ATAN: Arc tangent
66
Description
Function The ACOS function calculates the principal arc tangent of a real value. The result is
description given in the form of an angle in radians.
The function call can also be carried out by ATAN_REAL.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
ATAN_REAL
Tan_Value IN OUT Angle
Representation Representation:
in LD
ATAN_REAL
EN ENO
225
ATAN
Representation Representation:
in IL LD Tan_Value
ATAN_REAL
ST Angle
Representation Representation:
in ST Angle:= ATAN_REAL(Tan_Value);
Runtime errors When the absolute value Tan_Value is greater than 1, the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) changes to 1 and the system
word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
indicates the type of fault.
226
COS: Cosine
67
Description
Representation Representation:
in FBD
COS_REAL
Angle IN OUT Cos_Value
Representation Representation:
in LD
COS_REAL
EN ENO
227
COS
Representation Representation:
in IL LD Angle
COS_REAL
ST Cos_Value
Representation Representation:
in ST Cos_Value:= COS_REAL(Angle);
Runtime errors When the absolute value of Angle is greater than 2 63 , the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) changes to 1 and the system
word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
indicates the type of fault.
228
DEC: Decrementation of a variable
68
Description
229
DEC
Runtime errors In the case of overrun, the system bit %S18 (See Description of system bits %S15
to %S21, p. 448) is set to 1 and the decremented value becomes positive (32767 for
an integer for example).
230
DIV: Division
69
Description
Function The function divides the value at the Dividend with the value at the Divisor input
description and assigns the result to the output.
The data types of the input values and the output values must be identical.
For division with values of the TIME data type, you can use the block DIVTIME
(See DIVTIME: Division, p. 169).
When dividing INT, DINT, UINT and UDINT data types, any decimal places in the
result are omitted, e.g.
7÷3 = 2
( –7 ) ÷ 3 = –2
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
DIV
Dividend IN1 OUT Quotient
Divisor IN2
231
DIV
Representation Representation:
in LD
DIV
EN ENO
Divisor IN2
Representation Representation:
in IL LD Dividend
DIV Divisor
ST Quotient
Representation Representation:
in ST Quotient := DIV (Dividend, Divisor) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l an invalid division by 0 is executed (all available data types)
or
l an unauthorized floating point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
232
DIVMOD: Division and Modulo
70
Description
Function This procedure divides the value at the Dividend input by the value at the
description Divisor input. The result of the division is delivered at the Quotient output. The
remainder of the division is delivered at the Modulo output.
If there is a decimal place in the division result, the division will truncate it.
The data types of all input and output values must be identical.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
DIVMOD
Dividend IN1 DV Quotient
Divisor IN2 MD Modulo
Representation Representation:
in LD
DIVMOD
EN ENO
233
DIVMOD
Representation Representation:
in IL LD Dividend
DIVMOD Divisor, Quotient, Modulo
Representation Representation:
in ST DIVMOD (Dividend, Divisor, Quotient, Modulo);
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if an invalid division by 0 is executed.
234
EXP: Natural exponential
71
Description
Representation Representation:
in FBD
EXP_REAL
Real_Value IN OUT Exp_Real_Value
Representation Representation:
in LD
EXP_REAL
EN ENO
235
EXP
Representation Representation:
in IL LD Real_Value
EXP_REAL
ST Exp_Real_Value
Representation Representation:
in ST Log_Real_Value:= EXP_REAL(Real_Value);
Runtime errors When Real_Value is situated outside the interval ]-87.33654, 88.72283[, the
system bit %S18 (See Description of system bits %S15 to %S21, p. 448) changes
to 1 and the system word %SW17 (See Description of system words %SW12 to
%SW18, p. 451 ) indicates the type of fault.
236
EXPT_REAL_***: Exponentiation
of one value by another value
72
Description
237
EXPT_REAL_***
Exponent IN2
Runtime Errors When Value1 is negative or when there is an Expt_Real_Value overrun the
system bit %S18 (See Description of system bits %S15 to %S21, p. 448) changes
to 1 and the system word %SW17 (See Description of system words %SW12 to
%SW18, p. 451 ) indicates the type of fault.
238
INC: Incrementation of a variable
73
Description
INC
EN ENO
239
INC
Runtime errors In the case of overrun, the system bit %S18 (See Description of system bits %S15
to %S21, p. 448 ) is set to 1 and the incremented value becomes negative (-32768
for an integer for example).
240
LN: Natural logarithm
74
Description
Ln_Real_Value = Ln ( Real_Value )
Representation Representation:
in FBD
LN_REAL
Real_Value IN OUT Ln_Real_Value
Representation Representation:
in LD
LN_REAL
EN ENO
241
LN
Representation Representation:
in IL LD Real_Value
LN_REAL
ST Ln_Real_Value
Representation Representation:
in ST Ln_Real_Value := LN_REAL(Real_Value);
Runtime errors WhenReal_Value is negative, the system bit %S18 (See Description of system
bits %S15 to %S21, p. 448 ) changes to 1 and the system word %SW17 (See
Description of system words %SW12 to %SW18, p. 451) indicates the type of fault.
242
LOG : Base 10 logarithm
75
Description
Function The LOG function calculates the base 10 logarithm of a real number.
description The function call can also be carried out by LOG_REAL.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
LOG_REAL
Real_Value IN OUT Log_Real_Value
Representation Representation:
in LD
LOG_REAL
EN ENO
243
LOG
Representation Representation:
in IL LD Real_Value
LOG_REAL
ST Log_Real_Value
Representation Representation:
in ST Log_Real_Value:= LOG_REAL(Real_Value);
Runtime errors WhenReal_Value is negative, the system bit %S18 (See Description of system
bits %S15 to %S21, p. 448 ) changes to 1 and the system word %SW17 (See
Description of system words %SW12 to %SW18, p. 451) indicates the type of fault.
244
MOD: Modulo
76
Description
Function The function divides the value at the Dividend with the value at the Divisor input
description and assigns the modulo to the output.
The data types of all input values and output values must be identical.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
MOD
Dividend IN1 OUT Rest
Divisor IN2
Representation Representation:
in LD
MOD
EN ENO
Divisor IN2
Representation Representation:
in IL LD Dividend
MOD Divisor
ST Rest
245
MOD
Representation Representation:
in ST Rest := MOD (Dividend, Divisor) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if an invalid division by 0 is executed.
246
MOVE: Assignment
77
Description
Formula OUT = IN
Representation Representation:
in FBD MOVE
Representation This function can not be used in the LD (Ladder Diagram) programming language
in LD with the BOOL data type, since the same functionality can be achieved there with
contacts and coils.
Representation:
MOVE
EN ENO
247
MOVE
Representation Representation:
in IL LD Input
MOVE
ST Output
Representation Representation:
in ST Output := MOVE (Input) ;
248
MUL: Multiplication
78
Description
Function The function multiplies the input values and assigns the result to the output.
description The data types of all input values and output values must be identical.
The number of inputs can be increased to a maximum of 32.
For multiplication with values of the TIME data type, you can use the block MULTIME
(See MULTIME: Multiplication, p. 171).
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
MUL
Factor1 IN1 OUT Product
Factor2 IN2
Representation Representation:
in LD
MUL
EN ENO
Factor2 IN2
249
MUL
Representation Representation:
in IL LD Factor1
MUL Factor2
ST Product
Representation Representation:
in ST Product := MUL (Factor1, Factor2) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range at the output has been exceeded (all available data types)
or
l an unauthorized floating point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
250
NEG: Negation
79
Description
Function The function negates the input value and delivers the result at the NegatedOutput
description output.
The negation causes a sign reversal, e.g.
6 -> -6
-4 -> 4
Note: When the INT and DINT data types are processed, it is not possible to
convert very long negative values into positive ones. However, the ENO output is
not set to 0 when this error occurs.
Note: When the UINT and UDINT data types are processed, an error message is
always returned.
The data types of the input and output values must be identical.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD NEG
Input IN OUT NegatedOutput
251
NEG
Representation Representation:
in LD
NEG
EN ENO
Representation Representation:
in IL LD Input
NEG
ST NegatedOutput
Representation Representation:
in ST NegatedOutput := NEG (Input) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l a violation of the value range at the input occurs during the execution of the
function ( data types INT and DINT)
or
l an input value of the data type UDINT or UINT is to be converted.
252
SIGN: Sign evaluation
80
Description
Note: Because of IEC 61131-3 conformity, this function also works with the UINT
and UDINTdata types. This is not significant since these functions always return a
0 result.
Note: Because of the different processing of REAL and INT values, the following
behavior results for signed 0 (+/-0):
l -0.0 -> SIGN_REAL -> 1
l +0.0 -> SIGN_REAL -> 0
l -0 -> SIGN_INT/DINT -> 0
l +0 -> SIGN_INT/DINT -> 0
Representation Representation:
in FBD SIGN
Value IN OUT Negativ
253
SIGN:
Representation Representation:
in LD
SIGN
EN ENO
Negativ
Value IN OUT
Representation Representation:
in IL LD Value
SIGN
ST Negativ
Representation Representation:
in ST Negativ := SIGN (Value) ;
254
SIN: Sine
81
Description
Representation Representation:
in FBD
SIN_REAL
Angle IN OUT Sin_Value
Representation Representation:
in LD
SIN_REAL
EN ENO
255
SIN
Representation Representation:
in IL LD Angle
SIN_REAL
ST Sin_Value
Representation Representation:
in ST Sin_Value:= SIN_REAL(Angle);
Runtime errors When the absolute value of Angle is greater than 2 63 , the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) changes to 1 and the system
word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
indicates the type of fault.
256
SUB: Subtraction
82
Description
Function The function subtracts the value at the Value2 input from the value at the Value1
description input and assigns the result to the output.
The data types of the input values and the output values must be identical.
For subtraction with values of the TIME data type, you can use the block SUB_TIME
(See SUB_TIME: Subtraction, p. 259).
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
SUB
Value1 IN1 OUT Difference
Value2 IN2
Representation Representation:
in LD
SUB
EN ENO
Value2 IN2
257
SUB
Representation Representation:
in IL LD Value1
SUB Value2
ST Difference
Representation Representation:
in ST Difference := SUB (Value1, Value2) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range at the output has been exceeded (all available data types)
or
l an unauthorized floating point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
258
SUB_TIME: Subtraction
83
Description
Function The function subtracts the value at the TimeValue2 input from the value at the
description TimeValue1 input and assigns the result to the output.
The data types of the input values and the output be TIME.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
SUB_TIME
TimeValue1 IN1 OUT Difference
TimeValue2 IN2
Representation Representation:
in LD
SUB_TIME
EN ENO
TimeValue2 IN2
Representation Representation:
in IL LD TimeValue1
SUB TimeValue2
ST Difference
259
SUB_TIME
Representation Representation:
in ST Difference := SUB (TimeValue1, TimeValue2) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range at the output has been exceeded
260
SQRT_*** : Square root
84
Description
Function The SQRT_*** function extracts the square root from a variable. This function can be
description called using its generic name or one of the function names described below.
The additional parameters EN and ENO can be configured.
261
SQRT_***
Runtime errors When Value1 is of REAL type and negative, the result of the function contains -
1.#NAN and bit %S18 (See Description of system bits %S15 to %S21, p. 448) = 1.
When Value1 is of INT or DINT type and negative, the result of the function
contains the negative value Value1 and bit %S18 (See Description of system bits
%S15 to %S21, p. 448) = 1.
262
TAN: Tangent
85
Description
Representation Representation:
in FBD
TAN_REAL
Angle IN OUT Tan_Value
Representation Representation:
in LD
TAN_REAL
EN ENO
263
TAN
Representation Representation:
in IL LD Angle
TAN_REAL
ST Tan_Value
Representation Representation:
in ST Tan_Value:= TAN_REAL(Angle);
Runtime errors When the absolute value of Angle is greater than 2 63 , the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) changes to 1 and the system
word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
indicates the type of fault.
264
Statistical
VIII
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Statistical group.
265
Statistical
266
AVE: Averaging
86
Description
Function The procedure calculates the average of weighted input values and gives the result
description at the output.
Two successive inputs (K_Xn) represent one pair of values. The first K_Xn input
corresponds to K1, the next to X1, the one after that to K2, etc.
The number of K_Xn inputs can be increased to 32 by vertically modifying the size
of the block frame. This corresponds to a maximum of 16 value pairs.
The number of inputs must be even.
The data types of all input and output values must be identical.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD AVE
267
AVE
Representation Representation:
in LD
AVE
EN ENO
FirstValue K_X2
FactorSecondValue K_X3
SecondValue K_X4
Representation Representation:
in IL LD FactorFirstValue
AVE FirstValue, FactorSecondValue, SecondValue
ST Result
Representation Representation:
in ST Result := AVE (FactorFirstValue, FirstValue,
FactorSecondValue, SecondValue) ;
268
AVE
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range of the output is exceeded (all available data types)
or
l an invalid division by 0 is executed (all available data types)
or
l an unauthorized floating point number is set at an input parameter of data type
REAL. In this case, the status is also placed in %SW17 (See Description of
system words %SW12 to %SW18, p. 451).
Note: For a list of all block error codes and values, see Statistical, p. 443.
269
AVE
270
LIMIT: Limit
87
Description
Function This function transfers the unchanged input value (Input) to the output if the input
description value is not less than the minimum value (LowerLimit) and does not exceed the
maximum value (UpperLimit). If the input value (Input) is less than the minimum
value (LowerLimit), the minimum value will be transferred to the output. If the
input value (Input) exceeds the maximum value (UpperLimit), the maximum
value will be transferred to the output.
The data types of all input values and output values must be identical.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD LIMIT
LowerLimit MN OUT Output
Input IN
UpperLimit MX
271
LIMIT
Representation Representation:
in LD
LIMIT
EN ENO
Input IN
UpperLimit MX
Representation Representation:
in IL LD UpperLimit
LIMIT Input, LowerLimit
ST Output
Representation Representation:
in ST Output := LIMIT (UpperLimit, Input, LowerLimit) ;
272
LIMIT
Runtime error If there is an unauthorized floating point number at the input, an error message is
returned.
273
LIMIT
274
LIMIT_IND: Limit with indicator
88
Description
Function This procedure transfers the unchanged input value (Input) to the (Output), if the
description input value is not less than the minimum value (LimitMinimum) and does not
exceed the maximum value (LimitMaximum). If the input value (Input) is less
than the minimum value (LimitMinimum), the minimum value will be transferred to
the output. If the input value (Input) exceeds the maximum value
(LimitMaximum), the maximum value will be transferred to the output.
Additionally, a indication is given if the minimum or maximum value is violated. If the
value at the (Input) input is less than the value at the (LimitMinimum) input, the
(MinimumViolation) output becomes "1". If the value at the (Input) input is more
than the value at the (LimitMaximum) input, the (MaximumViolation) output
becomes "1".
The data types of the (LimitMinimum, Input, LimitMaximum) input values and
the (Output) output value must be identical.
EN and ENO can be configured as additional parameters.
MN_IND = 0, if IN ≥ MN
MN_IND = 1, if IN < MN
MX_IND = 0, if IN ≤ MX
MX_IND = 1, if IN > MX
275
LIMIT_IND
Representation Representation:
in FBD
LIMIT_IND
LimitMinimum MN MN_IND MinimumViolation
Input IN OUT Output
LimitMaximum MX MX_IND MaximumViolation
Representation Representation:
in LD
LIMIT_IND
EN ENO
MinimumViolation
LimitMinimum MN MN_IND
Representation Representation:
in IL LD LimitMinimum
LIMIT_IND Input, LimitMaximum, MinimumViolation,
Output, MaximumViolation
Representation Representation:
in ST LIMIT_IND (LimitMinimum, Input, LimitMaximum,
MinimumViolation, Output, MaximumViolation);
276
LIMIT_IND
277
LIMIT_IND
278
MAX: Maximum value function
89
Description
Function The function assigns the largest input value to the output.
description The data types of all input values and output values must be identical.
The number of inputs can be increased.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
MAX
Value1 IN1 OUT Maximum
Value2 IN2
Representation Representation:
in LD
MAX
EN ENO
Maximum
Value1 IN1 OUT
Value2 IN2
Representation Representation:
in IL LD Value1
MAX Value2
ST Maximum
279
MAX
Representation Representation:
in ST Maximum := MAX (Value1, Value2) ;
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451 ).
Note: For a list of all the block error messages and values, see Common Floating
Point Errors, p. 444.
280
MIN: Minimum value function
90
Description
Function The function assigns the smallest input value to the output.
description The data types of all input values and output values must be identical.
The number of inputs can be increased.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
MIN
Value1 IN1 OUT Minimum
Value2 IN2
Representation Representation:
in LD
MIN
EN ENO
Minimum
Value1 IN1 OUT
Value2 IN2
Representation Representation:
in IL LD Value1
MIN Value2
ST Minimum
281
MIN
Representation Representation:
in ST Minimum := MIN (Value1, Value2) ;
Runtime error If an unauthorized floating point number is created for an input parameter of data
type REAL, the system bit %S18 (See Description of system bits %S15 to %S21,
p. 448) is set to 1 and the status is placed in %SW17 (See Description of system
words %SW12 to %SW18, p. 451 ).
Note: For a list of all the block error messages and values, see Common Floating
Point Errors, p. 444.
282
MUX: Multiplexer
91
Description
Function This function transfers the respective input to the output depending on the value at
description the K input.
The number of inputs can be increased.
EN and ENO can be configured as additional parameters.
Data types The data types at the inputs Input0 to Inputn and at the output must be identical.
Representation Representation:
in FBD MUX
Selection K OUT Output
Input0 IN0
Input1 IN1
283
MUX
Representation Representation:
in LD
MUX
EN ENO
Input0 IN0
Input1 IN1
Representation Representation:
in IL LD Selection
MUX Input0, Input1
ST Output
Representation Representation:
in ST Output := MUX (Selection, Input0, Input1) ;
284
MUX
Runtime error An error message is returned if the value range of the Kinput (selector) is exceeded.
Note: For a list of all block error codes and values, see Statistical, p. 443.
285
MUX
286
SEL: Binary selection
92
Description
Function The function is used for binary selection between two input values.
description Depending on the state of the Selection input, either the Input0 input or Input1
input is transferred to the Output output.
Selection = 0 -> Output = Input0
Selection = 1 -> Output = Input1
The data types of the Input0 and Input1 input values and the Output output
values must be identical.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD SEL
Selection G OUT Output
Input0 IN0
Input1 IN1
Representation Representation:
in LD
SEL
EN ENO
Selection
G OUT Output
Input0 IN0
Input1 IN1
287
SEL
Representation Representation:
in IL LD Selection
SEL Input0, Input1
ST Output
Representation Representation:
in ST Output := SEL (Selection, Input0, Input1) ;
288
Strings
IX
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Strings family.
289
Strings
290
CONCAT_STR: Concatenation of
two character strings
93
Description
Representation Representation:
in FBD
CONCAT_STR
String1 IN1 OUT Result_String
String2 IN2
Representation Representation:
in LD
CONCAT_STR
EN ENO
String2 IN2
Representation Representation:
in IL LD String1
CONCAT_STR String2
ST Result_String
291
CONCAT_STR
Representation Representation:
in ST Result_String:= CONCAT_STR(String1, String2);
Runtime errors If the string Result_String is too short to contain the result, the system bit %S15
(See Description of system bits %S9 to %S13, p. 447) changes to 1 and the result
is truncated. Otherwise, the string Result_String is completed by the characters
NUL (16#00).
292
DELETE_INT: Deletion of a
sub-string of characters
94
Description
Function The DELETE_INT function removes a certain number of characters starting from a
description certain rank. The result is a character string.
Representation Representation:
in FBD
DELETE_INT
String1 IN OUT Result_String
Length_Str N
Position P
Representation Representation:
in LD
DELETE_INT
EN ENO
Length_Str N
Position P
293
DELETE_INT
Representation Representation:
in IL LD String1
DELETE_INT Length_Str, Position
ST Result_String
Representation Representation:
in ST Result_String:= DELETE_INT(String1, Length_Str, Position);
Example: Position =1
294
EQUAL_STR: Comparison of two
character strings
95
Description
Representation Representation:
in FBD
EQUAL_STR
String1 IN1 OUT Position
String2 IN2
Representation Representation:
in LD
EQUAL_STR
EN ENO
String2 IN2
Representation Representation:
in IL LD String1
EQUAL_STR String2
ST Position
Representation Representation:
in ST Position:= EQUAL_STR(String1, String2);
295
EQUAL_STR
296
FIND_INT: Finding a sub-string of
characters
96
Description
Function The FIND_INT function searches for the occurrence of a character string in another
description string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
FIND_INT
String1 IN1 OUT Position
String2 IN2
Representation Representation:
in LD
FIND_INT
EN ENO
String2 IN2
Representation Representation:
in IL LD String1
FIND_INT String2
ST Position
297
FIND_INT
Representation Representation:
in ST Position:= FIND_INT(String1, String2);
298
INSERT_INT: Insertion of a sub-
string of characters
97
Description
Function The INSERT_INT function inserts a character string into another character string
description starting from a given rank. The result is a character string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
INSERT_INT
String1 IN1 OUT Result_String
String2 IN2
Position P
Representation Representation:
in LD
INSERT_INT
EN ENO
String2 IN2
Position P
299
INSERT_INT
Representation Representation:
in IL LD String1
INSERT_INT String2, Position
ST Result_String
Representation Representation:
in ST Result_String:= DELETE_INT(String1, Length_Str, Position);
Example: Position =5
300
INSERT_INT
Runtime errors The bit %S15 (See Description of system bits %S9 to %S13, p. 447) is set to 1 in
the following cases:
l Position ≤ 0, Result_String then contains the end of string characters
(16#00).
l The maximum size of the string Result_String is too small to insert String2.
Result_String is truncated.
301
INSERT_INT
302
LEFT_INT: Extraction of
characters to the left
98
Description
Function The LEFT_INT function extracts a certain number of characters situated to the
description leftmost of a string. The result is a character string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
LEFT_INT
String1 IN OUT Result_String
Length_Str N
Representation Representation:
in LD
LEFT_INT
EN ENO
Length_Str N
Representation Representation:
in IL LD String1
LEFT_INT Length_Str
ST Result_String
303
LEFT_INT
Representation Representation:
in ST Result_String:= LEFT_INT(String1, Length_Str);
Runtime errors The bit %S15 (See Description of system bits %S9 to %S13, p. 447) is set to 1 in
the following cases:
l Length_Str ≤ 0, Result_String then contains the end of string characters
(16#00).
l The maximum size of the string Result_String is less than Length_Str,
Result_String is truncated.
304
LEN_INT: Length of character
string
99
Description
Function The LEN_INT function calculates the number of characters of a character string.
description The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
LEN_INT
String1 IN OUT Length_Str
Representation Representation:
in LD
LEN_INT
EN ENO
Representation Representation:
in IL LD String1
LEN_INT
ST Length_Str
Representation Representation:
in ST Length_Str:= LEN_INT(String1);
305
LEN_INT
306
MID_INT: Extraction of a
sub-string of characters
100
Description
Function The MID_INT function extracts a sub-string of characters starting from a certain
description rank. The result is a character string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
MID_INT
String1 IN OUT Result_String
Length_Str N
Position P
Representation Representation:
in LD
MID_INT
EN ENO
Length_Str N
Position P
307
MID_INT
Representation Representation:
in IL LD String1
MID_INT Length_Str, Position
ST Result_String
Representation Representation:
in ST Result_String:= MID_INT(String1, Length_Str, Position);
Example: Length_Str =4
Position INT Rank of first character of the sub-string to be extracted.
308
REPLACE_INT: Replacement of a
sub-string of characters
101
Description
Function The REPLACE_INT function replaces a character string in another character string
description starting from a certain rank and for a certain length. The result is a character string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
REPLACE_INT
String1 IN1 OUT Result_String
String2 IN2
Length_Str N
Position P
Representation Representation:
in LD
REPLACE_INT
EN ENO
String2 IN2
Length_Str N
Position P
309
REPLACE_INT
Representation Representation:
in IL LD String1
REPLACE_INT String2, Length_Str, Position
ST Result_String
Representation Representation:
in ST Result_String:= REPLACE_INT(String1, String2, Length_Str,
Position);
Example: Length_Str =3
Position INT Rank of first character of the sub-string to be replaced
310
REPLACE_INT
Runtime errors The bit %S15 (See Description of system bits %S9 to %S13, p. 447) is set to 1 in
the following cases:
l Position ≤ 0, Result_String then contains the end of string characters
(16#00).
l The maximum size of the string Result_String is too small to insert String2.
Result_String is truncated.
l Position is greater than or equal to the length of String1. Result_String
is composed of the characters NUL (16#00).
311
REPLACE_INT
312
RIGHT_INT: Extraction of a
character string to the right
102
Description
Function The RIGHT_INT function extracts a certain number of characters situated to the
description rightmost of a string. The result is a character string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
RIGHT_INT
String1 IN OUT Result_String
Length_Str N
Representation Representation:
in LD
RIGHT_INT
EN ENO
Length_Str N
Representation Representation:
in IL LD String1
RIGHT_INT Length_Str
ST Result_String
313
RIGHT_INT
Representation Representation:
in ST Result_String:= RIGHT_INT(String1, Length_Str);
Example: Length_Str =4
Runtime errors The bit %S15 (See Description of system bits %S9 to %S13, p. 447) is set to 1 in
the following cases:
l Length_Str ≤ 0, Result_String then contains the end of string characters
(16#00).
l The maximum size of the string Result_String is less than Length_Str.
Result_String is truncated.
314
Timer & Counter
X
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Timer & Counter family.
315
Timer & Counter
316
CTD, CTD_***: Down counter
103
Description
Note: The counter only works to the minimum values of the data type being used.
No overflow occurs.
317
CTD, CTD_***
Representation Representation:
in FBD CTD_Instance
CTD
Trigger CD Q Output
Load LD
PresetValue PV CV CountValue
Representation Representation:
in LD CTD_Instance
CTD
EN ENO
Trigger Output
CD Q
Load
LD
PresetValue PV CV CountValue
Representation Representation:
in IL CAL CTD_Instance (CD:=Trigger, LD:=Load,
PV:=PresetValue, Q=>Output, CV=>CountValue)
Representation Representation:
in ST CTD_Instance (CD:=Trigger, LD:=Load, PV:=PresetValue,
Q=>Output, CV=>CountValue) ;
318
CTD, CTD_***
319
CTD, CTD_***
320
CTU, CTU_***: Up counter
104
Description
Note: The counter only works to the maximum values of the data type being used.
No overflow occurs.
321
CTU, CTU_***
Representation Representation:
in FBD CTU_Instance
CTU
Trigger CU Q Output
Reset R
PresetValue PV CV CountValue
Representation Representation:
in LD CTU_Instance
CTU
EN ENO
Trigger Output
CU Q
Reset
R
PresetValue PV CV CountValue
Representation Representation:
in IL CAL CTU_Instance (CU:=Trigger, R:=Reset,
PV:=PresetValue, Q=>Output, CV=>CountValue)
Representation Representation:
in ST CTU_Instance (CU:=Trigger, R:=Reset, PV:=PresetValue,
Q=>Output, CV=>CountValue) ;
322
CTU, CTU_***
323
CTU, CTU_***
324
CTUD, CTUD_***: Up/Down
counter
105
Description
Function The function blocks are used for upwards and downwards counting.
description A "1" signal at the R input causes the value "0" to be assigned to the CV output. A
"1" signal at the LD input causes the value of the PV input to be allocated to the CV
output. With each transition from "0" to "1" at the CU input, the value of CV is
incremented by 1. With each transition from "0" to "1" at the CD input, the value of
CV is reduced by 1.
If there is a simultaneous "1" signal at inputs R and LD, input R has precedence.
When CV ≥ PV, output QU is "1".
Bei CV ≤ is 0, the QD output becomes "1".
Note: The down counter only works to the minimum values of the data type being
used, and the up counter only to the maximum values of the data type being used.
No overflow occurs.
325
CTUD, CTUD_***
Representation Representation:
in FBD CTUD_Instance
CTUD
UpTrigger CU QU UpDisplay
DownTrigger CD QD DownDisplay
Reset R
Load LD
PresetValue PV CV CountValue
Representation Representation:
in LD CTUD_Instance
CTUD
EN ENO
UpTrigger UpDisplay
CU QU
DownTrigger DownDisplay
CD QD
Reset
R
Load
LD
PresetValue PV CV CountValue
Representation Representation:
in IL CAL CTUD_Instance (CU:=UpTrigger, CD:=DownTrigger,
R:=Reset, LD:=Load, PV:=PresetValue, QU=>UpDisplay,
QD=>DownDisplay, CV=>CountValue)
Representation Representation:
in ST CTUD_Instance (CU:=UpTrigger, CD:=DownTrigger,
R:=Reset, LD:=Load, PV:=PresetValue, QU=>UpDisplay,
QD=>DownDisplay, CV=>CountValue) ;
326
CTUD, CTUD_***
327
CTUD, CTUD_***
328
TOF: Off delay
106
Description
Representation Representation:
in FBD TOF_Instance
TOF
StartDelay IN Q Output
PresetDelayTime PT ET InternalTime
Representation Representation:
in LD TOF_Instance
TOF
EN ENO
StartDelay Output
IN Q
PresetDelayTime PT ET InternalTime
Representation Representation:
in IL CAL TOF_Instance (IN:=StartDelay, PT:=PresetDelayTime,
Q=>Output, ET=>InternalTime)
329
TOF
Representation Representation:
in ST TOF_Instance (IN:=StartDelay, PT:=PresetDelayTime,
Q=>Output, ET=>InternalTime) ;
IN
(1)
Q
(3) (4) (2) (5) (3)
PT
ET (2) (2)
330
TON: On delay
107
Description
Representation Representation:
in FBD TON_Instance
TON
StartDelay IN Q Output
PresetDelayTime PT ET InternalTime
Representation Representation:
in LD TON_Instance
TON
EN ENO
StartDelay Output
IN Q
PresetDelayTime PT ET InternalTime
Representation Representation:
in IL CAL TON_Instance (IN:=StartDelay, PT:=PresetDelayTime,
Q=>Output, ET=>InternalTime)
331
TON
Representation Representation:
in ST TON_Instance (IN:=StartDelay, PT:=PresetDelayTime,
Q=>Output, ET=>InternalTime) ;
IN
Q
(2) (3) (1) (4)
PT
ET (1)
332
TP: Pulse
108
Description
Function The function block is used for the generation of a pulse with defined duration.
description When the function block is called for the first time, the initial state of ET is "0".
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD TP_Instance
TP
TriggerPulse IN Q Output
PulseDuration PT ET InternalTime
Representation Representation:
in LD TP_Instance
TP
EN ENO
TriggerPulse Output
IN Q
PulseDuration PT ET InternalTime
Representation Representation:
in IL CAL TP_Instance (IN:=TriggerPulse, PT:=PulseDuration,
Q=>Output, ET=>InternalTime)
333
TP
Representation Representation:
in ST TP_Instance (IN:=TriggerPulse, PT:=PulseDuration,
Q=>Output, ET=>InternalTime) ;
IN
(1) (1) (4)
Q
(2) (3) (5)
PT
ET
(1) If IN becomes "1", Q becomes "1" and the internal time (ET) starts.
(2) If the internal time reaches the value of PT, Q becomes "0" (independent of IN).
(3) The internal time stops/is reset if IN becomes "0".
(4) If the internal time has not reached the value of PT yet, the internal time is not affected by
a clock at IN.
(5) If the internal time has reached the value of PT and IN is "0", the internal time stops/is reset
and Q becomes "0".
334
Type to type
XI
Introduction
Overview This section describes the elementary functions and elementary function blocks of
the Type to type family.
335
Type to type
336
Type to type
337
Type to type
338
BCD_TO_INT: Conversion of a
BCD integer into pure binary
109
Description
Function The BCD_TO_INT function converts an integer in Binary Coded Decimal (BCD)
description format into a binary coded integer.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
BCD_TO_INT
BCD_Int IN OUT Result_Int
Representation Representation:
in LD
BCD_TO_INT
EN ENO
Representation Representation:
in IL LD BCD_Int
BCD_TO_INT
ST Result_Int
339
BCD_TO_INT
Representation Representation:
in ST Result_Int:= BCD_TO_INT(BCD_Int);
Runtime errors The bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
when the value to be converted is not a value coded in BCD. The result of the
function then returns the value of the input parameter.
340
BIT_TO_BYTE: Type conversion
110
Description
Function The function converts 8 input values of the data type BOOL to an output of the BYTE
description data type.
The input values are assigned to the individual bits of the byte at the output
according to the input names.
BIT0 (20)
BIT1 (21)
BYTE
7 6
2 2 21 20
BIT6 (26)
BIT7 (27)
341
BIT_TO_BYTE:
Representation Representation:
in FBD
BIT_TO_BYTE
InputBit0 BIT0 OUT OutputByte
InputBit1 BIT1
InputBit2 BIT2
InputBit3 BIT3
InputBit4 BIT4
InputBit5 BIT5
InputBit6 BIT6
InputBit7 BIT7
Representation Representation:
in LD
BIT_TO_BYTE
EN ENO
InputBit0
BIT0 OUT OutputByte
InputBit1
BIT1
InputBit2
BIT2
InputBit3
BIT3
InputBit4
BIT4
InputBit5
BIT5
InputBit6
BIT6
InputBit7
BIT7
Representation Representation:
in IL LD InputBit0
BIT_TO_BYTE InputBit1, InputBit2, InputBit3, InputBit4,
InputBit5, InputBit6, InputBit7
ST OutputByte
342
BIT_TO_BYTE:
Representation Representation:
in ST OutputByte := BIT_TO_BYTE (InputBit0, InputBit1,
InputBit2, InputBit3, InputBit4, InputBit5, InputBit6,
InputBit7) ;
343
BIT_TO_BYTE:
344
BIT_TO_WORD: Type conversion
111
Description
Function The function converts 16 input values of the BOOL data type to an output value of
description the WORD data type.
The input values are assigned to the individual bits of the word at the output
according to the input names.
BIT0 (20)
BIT1 (21)
WORD
15 14
2 2 21 20
BIT14 (214)
BIT15 (215)
Representation Representation:
in FBD
BIT_TO_WORD
InputBit0 BIT0 OUT WORD_Output
: :
InputBit15 BIT15
345
BIT_TO_WORD
Representation Representation:
in LD
BIT_TO_WORD
EN ENO
InputBit0
BIT0 OUT WORD_Output
: :
InputBit15
BIT15
Representation Representation:
in IL LD InputBit0
BIT_TO_WORD InputBit1, InputBit2, InputBit3, InputBit4,
InputBit5, InputBit6, InputBit7,InputBit8,
InputBit9, InputBit10, InputBit11, InputBit12,
InputBit13, InputBit14, InputBit15
ST WORD_Output
Representation Representation:
in ST WORD_Output := BIT_TO_WORD (InputBit0, InputBit1,
InputBit2, InputBit3, InputBit4, InputBit5,
InputBit6, InputBit7, InputBit8, InputBit9,
InputBit10, InputBit11, InputBit12, InputBit13,
InputBit14, InputBit15) ;
346
BOOL_TO_***: Type conversion
112
Description
Function The function converts an input value of the BOOL data type to a BYTE, WORD, DWORD,
description INT, DINT, UINT, UDINT, REAL or TIME data type.
The input value is written in the lowest bit of the output. All other output bits are set
to zero.
EN and ENO can be configured as additional parameters.
(The output ENO is not used for BOOL_TO_REAL; it always has the value "1".)
347
BOOL_TO_***
EN ENO
BOOL_variable
IN OUT ConvertedVariable
348
BYTE_AS_WORD: Type
conversion
113
Description
Function The function converts 2 input values of the BYTE data type to an output value of the
description WORD data type.
The input values are assigned to the word at the output according to the input
names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD BYTE_AS_WORD
BYTE_variable1 LOW OUT WORD_Output
BYTE_variable2 HIGH
Representation Representation:
in LD
BYTE_AS_WORD
EN ENO
BYTE_variable2 HIGH
349
BYTE_AS_WORD
Representation Representation:
in IL LD BYTE_variable1
BYTE_AS_WORD BYTE_variable2
ST WORD_Output
Representation Representation:
in ST WORD_Output := BYTE_AS_WORD (BYTE_variable1,
BYTE_variable2) ;
350
BYTE_TO_BIT: Type conversion
114
Description
Function The procedure converts an input value of the BYTE data type to 8 output values of
description the BOOL data type.
The individual bits of the byte at the input are assigned to the outputs according to
the output names.
BIT0 (20)
BIT1 (21)
BYTE
27 26 21 20
BIT14 (26)
BIT15 (27)
Representation Representation:
in FBD
BYTE_TO_BIT
BYTE_variable IN BIT0 BOOL_variable1
BIT1 BOOL_variable2
BIT2 BOOL_variable3
BIT3 BOOL_variable4
BIT4 BOOL_variable5
BIT5 BOOL_variable6
BIT6 BOOL_variable7
BIT7 BOOL_variable8
351
BYTE_TO_BIT
Representation Representation:
in LD
BYTE_TO_BIT
EN ENO
BOOL_variable1
BYTE_variable IN BIT0
BOOL_variable2
BIT1
BOOL_variable3
BIT2
BOOL_variable4
BIT3
BOOL_variable5
BIT4
BOOL_variable6
BIT5
BOOL_variable7
BIT6
BOOL_variable8
BIT7
Representation Representation:
in IL LD BYTE_variable
BYTE_TO_BIT BOOL_variable1, BOOL_variable2, BOOL_variable3,
BOOL_variable4, BOOL_variable5, BOOL_variable6,
BOOL_variable7, BOOL_variable8
Representation Representation:
in ST BYTE_TO_BIT (BYTE_variable, BOOL_variable1, BOOL_variable2,
BOOL_variable3, BOOL_variable4, BOOL_variable5,
BOOL_variable6, BOOL_variable7, BOOL_variable8);
352
BYTE_TO_BIT
353
BYTE_TO_BIT
354
BYTE_TO_***: Type conversion
115
Description
Function The function converts an input value of the BYTE data type to a BOOL, WORD, DWORD,
description INT, DINT, UINT, UDINT, REAL or TIME data type.
When converting the data type BYTE to the data type WORD, DWORD, INT, DINT,
UINT, UDINT, REAL or TIME, the bit pattern of the input is transferred to the least
significant bits of the output. The most significant bits of the output are set to zero.
When converting the data type BYTE into the data type BOOL, the least significant
bit of the input value is transferred to the output.
355
BYTE_TO_***
EN ENO
356
BYTE_TO_***
357
BYTE_TO_***
358
DATE_TO_STRING: Conversion of
a variable in DATE format into a
character string 116
Description
Function The DATE_TO_STRING function converts a variable in DATE format into a character
description string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
DATE_TO_STRING
Date1 IN OUT Result_Str
Representation Representation:
in LD
DATE_TO_STRING
EN ENO
Representation Representation:
in IL LD Date1
DATE_TO_STRING
ST Result_Str
Representation Representation:
in ST Result_Str:= DATE_TO_STRING(Date1);
359
DATE_TO_STRING
Example: ‘2000-12-27’
Note: if the maximum size of the string Result_Str is
greater than 10, Result_Str is completed by the end
of string characters (16#00).
Runtime errors If the string Result_Str is too short to contain the date (length of less than 10
characters), the date is truncated and the bit %S15 (See Description of system bits
%S9 to %S13, p. 447) is set to 1.
If Date1 in not interpretable and coherent in DATE format, the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) is set to 1 and Result_Str
=’****-**-**’
360
DBCD_TO_***: Conversion of a
double BCD integer into binary
117
Description
Function The DBCD_TO_*** function converts a double integer in Binary Code Decimal
description (DBCD) format into a double binary coded integer.
The additional parameters EN and ENO can be configured.
361
DBCD_TO_***
Runtime errors The bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
when:
l the value to be converted is not a value coded in BCD. The result of the function
then returns the value of the first half-byte by default.
l for the function DBCD_TO_INT, the value to be converted is greater in BCD than
32767. The result of the function is then -1.
362
DEG_TO_RAD : Conversion of
degrees to radians
118
Description
Function The DEG_TO_RAD function converts an angle expressed in degrees into radians.
description The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
DEG_TO_RAD
Angle_in_Degree IN OUT Angle_in_Radian
Representation Representation:
in LD
DEG_TO_RAD
EN ENO
363
DEG_TO_RAD
Representation Representation:
in IL LD Angle_in_Degree
DEG_TO_RAD
ST Angle_in_Radian
Representation Representation:
in ST Angle_in_Radian:= DEG_TO_RAD(Angle_in_Degree);
Runtime errors When Angle_in_Degree is situated outside the interval ]-737280.0, +73780.0[,
the system bit %S18 (See Description of system bits %S15 to %S21, p. 448)
changes to 1, the system word %SW17 (See Description of system words %SW12
to %SW18, p. 451) indicates the type of fault and the result displayed is 1.#NAN.
364
DINT_AS_WORD: Type
conversion
119
Description
Function The procedure converts an input value of the DINT data type to 2 output values of
description the WORD data type.
The individual words of the DINT input are assigned to the outputs according to the
output names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD
DINT_AS_WORD
DINT_variable IN LOW LowWord
HIGH HighWord
Representation Representation:
in LD
DINT_AS_WORD
EN ENO
HIGH HighWord
Representation Representation:
in IL LD DINT_variable
DINT_AS_WORD LowWord, HighWord
365
DINT_AS_WORD
Representation Representation:
in ST DINT_AS_WORD (DINT_variable, LowWord, HighWord);
366
DINT_TO_***: Type conversion
120
Description
Function The function converts an input value of the DINT data type to a BOOL, BYTE, WORD,
description DWORD, INT, UINT UDINT, REAL or TIME output value.
Note: The function converts strictly in accordance with IEC rules. Since this
function has been realized as a generic function, there will also be a few illogical
conversions, e.g. DINT_TO_BOOL.
When converting the data type DINT to the BOOL, BYTE, WORD, INT or UINT data
type, the least significant bits of the input value are transferred to the output.
Negative input values cannot be converted into data types UINT, UDINT or TIME.
EN and ENO can be configured as additional parameters.
367
DINT_TO_***
EN ENO
368
DINT_TO_***
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range on the output is exceeded (numeric data types)
l a negative input value is to be converted into an UDINT-, UINT or TIME output
value.
l an unauthorized floating point number is created during the conversion into the
REAL data type. In this case, the status is also placed in %SW17 (See Description
of system words %SW12 to %SW18, p. 451).
The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) and
system word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
are not used when data types are converted:
l BOOL
l BYTE
l WORD
l DWORD
369
DINT_TO_***
370
DINT_TO_DBCD: Conversion of a
double binary coded integer into a
double Binary Coded Decimal 121
integer
Description
Function The DINT_TO_DBCD function carries out the conversion of a double binary coded
description integer into an integer in Double Binary Coded Decimal (DBCD) format.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
DINT_TO_DBCD
D_Integer_1 IN OUT DBCD_Result
Representation Representation:
in LD
DINT_TO_DBCD
EN ENO
Representation Representation:
in IL LD D_Integer_1
DINT_TO_BCD
ST DBCD_Result
371
DINT_TO_DBCD
Representation Representation:
in ST DBCD_Result:= DINT_TO_BCD(D_Integer_1);
Runtime errors The bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
when the value to be converted is not a value between 0 and 99999999. The result
of the function then returns the value of the input parameter.
372
DT_TO_STRING: Conversion of a
variable in DT format into a
character string 122
Description
Representation Representation:
in FBD
DT_TO_STRING
Date1 IN OUT Result_Str
Representation Representation:
in LD
DT_TO_STRING
EN ENO
Representation Representation:
in IL LD Date1
DT_TO_STRING
ST Result_Str
373
DT_TO_STRING
Representation Representation:
in ST Result_Str:= DT_TO_STRING(Date1);
Example: ‘2000-12-27-23:15:50’
Note: if the maximum size of the string Result_Str is
greater than 19, Result_Str is completed by the end
of string characters (16#00).
Runtime errors If the string Result_Str is too short to contain the date (length of less than 19
characters), the date is truncated and the bit %S15 (See Description of system bits
%S9 to %S13, p. 447) is set to 1.
If Date1 in not interpretable and coherent in format DT, the system bit %S18 (See
Description of system bits %S15 to %S21, p. 448) is set to 1 and Result_Str
=’****-**-**-**:**:**’.
374
DWORD_TO_***: Type conversion
123
Description
Function The function converts an input value of the DWORD data type to a BOOL, BYTE, WORD,
description INT, DINT, UINT, UDINT, REAL or TIME data type.
Note: The function converts strictly in accordance with IEC rules. Since this
function has been realized as a generic function, there will also be a few illogical
conversions, e.g. DWORD_TO_BOOL.
When converting the data type DWORD to the BOOL, BYTE, WORD, INT or UINT data
type, the least significant bits of the input value are transferred to the output.
EN and ENO can be configured as additional parameters.
(The output ENO is not used for DWORD_TO_REAL; it always has the value "1".)
375
DWORD_TO_***
EN ENO
376
GRAY_TO_INT: Conversion of an
integer in Gray code into a binary
coded integer 124
Description
Function The GRAY_TO_INT function converts an integer expressed in GRAY code into a
description binary coded integer.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
GRAY_TO_INT
GRAY_Int IN OUT Result_Int
Representation Representation:
in LD
GRAY_TO_INT
EN ENO
Representation Representation:
in IL LD GRAY_Int
GRAY_TO_INT
ST Result_Int
377
GRAY_TO_INT
Representation Representation:
in ST Result_Int:= GRAY_TO_INT(GRAY_Int);
378
INT_AS_DINT: Concatenation of
two integers to form a double
integer 125
Description
Function The INT_AS_DINT function concatenates two integers to form a double integer.
description The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
INT_AS_DINT
Low_Word LOW OUT Double_Word
High_Word HIGH
Representation Representation:
in LD
INT_AS_DINT
EN ENO
High_Word HIGH
Representation Representation:
in IL LD Low_Word
INT_AS_DINT High_Word
ST Double_Word
379
INT_AS_DINT
Representation Representation:
in ST Double_Word:= INT_AS_DINT(Low_Word, High_Word);
380
INT_TO_***: Type conversion
126
Description
Function The function converts an input value of the INT data type to a BOOL, BYTE, WORD,
description DWORD, DINT, UINT, UDINT, REAL or TIME output value.
Note: The function converts strictly in accordance with IEC rules. Since this
function has been realized as a generic function, there will also be a few illogical
conversions, e.g. INT_TO_BOOL.
Negative input values cannot be converted into data types UINT, UDINT or TIME.
When converting an input value from the data type INT into data type WORD, the bit
pattern from the input is transferred to the output without being modified.
When converting an input value of data type INT into the data types BOOL or BYTE,
the least significant bits of the input are transferred to the output.
EN and ENO can be configured as additional parameters.
381
INT_TO_***
EN ENO
382
INT_TO_***
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range on the output is exceeded (numeric data types)
l a negative input value is to be converted into an UDINT-, UINT or TIME output
value.
l an unauthorized floating point number is created during the conversion into the
REAL data type. In this case, the status is also placed in %SW17 (See Description
of system words %SW12 to %SW18, p. 451).
The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) and
system word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
are not used when data types are converted:
l BOOL
l BYTE
l WORD
l DWORD
383
INT_TO_***
384
INT_TO_BCD: Conversion of a
binary coded integer into a Binary
Coded Decimal integer 127
Description
Function The INT_TO_BCD function carries out the conversion of a binary coded integer into
description an integer in Binary Coded Decimal (BCD) format.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
INT_TO_BCD
Integer_1 IN OUT BCD_Result
Representation Representation:
in LD
INT_TO_BCD
EN ENO
Representation Representation:
in IL LD Integer_1
INT_TO_BCD
ST BCD_Result
385
INT_TO_BCD
Representation Representation:
in ST BCD_Result := INT_TO_BCD(Integer_1);
Example: Integer_1 = 99
Runtime errors The bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
when the value to be converted is not a value between 0 and 9999. The result of the
function then returns the value of the input parameter.
386
INT_TO_DBCD: Conversion of a
binary coded integer into a double
Binary Coded Decimal integer 128
Description
Function The INT_TO_DBCD function carries out the conversion of a binary coded integer into
description an integer in Double Binary Coded Decimal (DBCD) format. This function is useful
when converting numbers with BCD coding greater than 32768.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
INT_TO_DBCD
Integer_1 IN OUT DBCD_Result
Representation Representation:
in LD
INT_TO_DBCD
EN ENO
Representation Representation:
in IL LD Integer_1
INT_TO_BCD
ST DBCD_Result
387
INT_TO_DBCD
Representation Representation:
in ST DBCD_Result:= INT_TO_BCD(Integer_1);
Runtime errors The bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1
when the value to be converted is not a value between 0 and 99999999 or when the
value to be converted is negative. The result of the function then returns the value
of the input parameter.
388
RAD_TO_DEG: Conversion of
radians to degrees
129
Description
Function The RAD_TO_DEG function converts an angle expressed in radians into degrees.
description The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
RAD_TO_DEG
Angle_in_Radian IN OUT Angle_in_Degree
Representation Representation:
in LD
RAD_TO_DEG
EN ENO
Representation Representation:
in IL LD Angle_in_Radian
RAD_TO_DEG
ST Angle_in_Degree
389
RAD_TO_DEG
Representation Representation:
in ST Angle_in_Degree:= RAD_TO_DEG(Angle_in_Radian);
Runtime errors When Angle_in_Degree is situated outside the interval ]-4096 π, 4096 π[, the
system bit %S18 (See Description of system bits %S15 to %S21, p. 448) changes
to 1 and the system bit %SW17 (See Description of system words %SW12 to
%SW18, p. 451 ) indicates the type of fault.
390
REAL_AS_WORD: Type
conversion
130
Description
Function The procedure converts an input value of the REAL data type to 2 output values of
description the WORD data type.
The individual words of the REAL input are assigned to the outputs according to the
output names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD REAL_AS_WORD
REAL_variable IN LOW LowWord
HIGH HighWord
Representation Representation:
in LD
REAL_AS_WORD
EN ENO
HIGH HighWord
Representation Representation:
in IL LD REAL_variable
REAL_AS_WORD LowWord, HighWord
391
REAL_AS_WORD
Representation Representation:
in ST REAL_AS_WORD (REAL_variable, LowWord, HighWord);
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if an unauthorized floating point number is set at the input.
392
REAL_TO_***: Type conversion
131
Description
Function The function converts an input value of the REAL data type to a BOOL, BYTE, WORD,
description DWORD, INT, DINT, UINT, UDINT data type or into the TIME data type.
Note: The function converts strictly in accordance with IEC rules. Since this
function has been realized as a generic function, there will also be a few illogical
conversions, e.g. REAL_TO_BOOL.
When converting to BOOL, BYTE, WORD, the least significant bits of the input value
are transferred to the output. A runtime error message is not given and ENO
remains 1.
When converting to INT, DINT, UINT, UDINT and TIME, the IEC 559 rules for
rounding are applied.
393
REAL_TO_***
Example The following example shows how the IEC 559 rounding is applied.
1,4 -> 1
1,5 -> 2
2,5 -> 2
3,5 -> 4
4,5 -> 4
4,6 -> 5
Negative input Negative input values cannot be converted into data types UINT, UDINT or TIME.
values
EN ENO
394
REAL_TO_***
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l an unauthorized floating point number is set at the input
l the value range on the output is exceeded (numeric data types)
l a negative input value is to be converted into an UDINT-, UINT or TIME output
value.
l an unauthorized floating point number is created during the conversion into the
REAL data type. In this case, the status is also placed in %SW17 (See Description
of system words %SW12 to %SW18, p. 451).
The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) and
system word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
are not used when data types are converted:
l BOOL
l BYTE
l WORD
l DWORD
395
REAL_TO_***
396
REAL_TRUNC_***: Type
conversion
132
Description
Function The function converts (by truncating towards zero) a REAL data type input value to
description a output value of the INT, DINT, UINT or UDINT data type.
EN and ENO can be configured as additional parameters.
Data type Negative input values cannot be converted into data types UDINT or UINT.
397
REAL_TRUNC_***
EN ENO
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1 and the status is stored in %SW17 (See Description of system words %SW12
to %SW18, p. 451) if
l a negative input value is to be converted into an UDINT or UINT output value
or
l an unauthorized floating point number is set at the input.
398
STRING_TO_*** : Conversion of a
character string to a number of the
INT, DINT or REAL type 133
Description
Description of The STRING_TO_*** function converts a character string into a one- or two-digit
the function integer or into a real number.
This function is IEC 1131.
The additional parameters EN and ENO can be configured.
399
STRING_TO_***
Execution errors The %S18 (See Description of system bits %S15 to %S21, p. 448) bit is positioned
at 1 when the content of the string to be converted is positioned outside of the
boundaries of the type chosen (INT, DINT or REAL) or when one of the characters
in the string is incorrect.
400
TYPE_AS_WORD: Type
conversion
134
Description
Function The procedure converts an input value of the TIME data type to 2 output values of
description the WORD data type.
The individual words of the TIME input are assigned to the outputs according to the
output names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD TIME_AS_WORD
TIME_variable IN LOW LowWord
HIGH HighWord
Representation Representation:
in LD
TIME_AS_WORD
EN ENO
HIGH HighWord
Representation Representation:
in IL LD TIME_variable
TIME_AS_WORD LowWord, HighWord
401
TIME_AS_WORD
Representation Representation:
in ST TIME_AS_WORD (REAL_variable, LowWord, HighWord);
402
TIME_TO_***: Type conversion
135
Description
Function The function converts an input value of the TIME data type to a BOOL, BYTE, WORD,
description DWORD, INT, DINT, UINT, UDINT or REAL data type.
Note: The function converts strictly in accordance with IEC rules. Since this
function has been realized as a generic function, there will also be a few illogical
conversions, e.g. TIME_TO_BOOL.
While converting an input value of data type TIME into an output value of data type
BOOL, BYTE, WORD, INT or UINT, the least significant bits, respectively, are
transferred from the input to the output.
EN and ENO can be configured as additional parameters.
403
TIME_TO_***
EN ENO
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range is exceeded at the output during the execution of the function.
404
TIME_TO_STRING: Conversion of
a variable in TIME format into a
character string 136
Description
Function The TIME_TO_STRING function converts a variable in TIME format into a character
description string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
TIME_TO_STRING
Time1 IN OUT Result_Str
Representation Representation:
in LD
TIME_TO_STRING
EN ENO
Representation Representation:
in IL LD Time1
TIME_TO_STRING
ST Result_Str
Representation Representation:
in ST Result_Str:= TIME_TO_STRING(Time1);
405
TIME_TO_STRING
Example: ‘119304:38:49.5’
Note: if the maximum size of the string Result_Str is
greater than 15, Result_Str is completed by the end
of string characters (16#00).
Runtime errors If the string Result_Str is too short to contain the converted value (less than 15
characters in length), it is truncated and the bit %S15 (See Description of system bits
%S9 to %S13, p. 447) is set to 1.
406
TOD_TO_STRING: Conversion of
a variable in TOD format into a
character string 137
Description
Function The TOD_TO_STRING function converts a variable in TOD format into a character
description string.
The additional parameters EN and ENO can be configured.
Representation Representation:
in FBD
TOD_TO_STRING
Time1 IN OUT Result_Str
Representation Representation:
in LD
TOD_TO_STRING
EN ENO
Representation Representation:
in IL LD Time1
TOD_TO_STRING
ST Result_Str
Representation Representation:
in ST Result_Str:= =TOD_TO_STRING(Time1);
407
TOD_TO_STRING
Example: ‘04:38:49’
Note: if the maximum size of the string Result_Str is
greater than 8, Result_Str is completed by the end of
string characters (16#00).
Runtime errors If the string Result_Str is too short to contain the converted value (less than 8
characters in length), it is truncated and the bit %S15 (See Description of system bits
%S9 to %S13, p. 447) is set to 1.
408
UDINT_AS_WORD: Type
conversion
138
Description
Function The procedure converts an input value of the UDINT data type to 2 output values of
description the WORD data type.
The individual words of the UDINT input are assigned to the outputs according to the
output names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD UDINT_AS_WORD
UDINT_variable IN LOW LowWord
HIGH HighWord
Representation Representation:
in LD
UDINT_AS_WORD
EN ENO
HIGH HighWord
Representation Representation:
in IL LD UDINT_variable
UDINT_AS_WORD LowWord, HighWord
409
UDINT_AS_WORD
Representation Representation:
in ST UDINT_AS_WORD (UDINT_variable, LowWord, HighWord);
410
UDINT_TO_***: Type conversion
139
Description
Function The function converts an input value of the UDINT data type to an output value of
description the BOOL, BYTE, WORD, DWORD, INT, DINT, UINT, REAL or TIME data type.
Note: The function converts strictly in accordance with IEC rules. Since this
function has been realized as a generic function, there will also be a few illogical
conversions, e.g. UDINT_TO_BOOL.
When converting the data type DINT to the BOOL, BYTE, WORD, INT or UINT data
type, the least significant bits of the input value are transferred to the output.
EN and ENO can be configured as additional parameters.
411
UDINT_TO_***
EN ENO
412
UDINT_TO_***
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range on the output is exceeded (numeric data types)
l a negative input value is to be converted into an UDINT-, UINT or TIME output
value.
l an unauthorized floating point number is created during the conversion into the
REAL data type. In this case, the status is also placed in %SW17 (See Description
of system words %SW12 to %SW18, p. 451).
The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) and
system word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
are not used when data types are converted:
l BOOL
l BYTE
l WORD
l DWORD
413
UDINT_TO_***
414
UINT_TO_***: Type conversion
140
Description
Function The function converts an input value of the UINT data type to an output value of the
description BOOL, BYTE, WORD, DWORD, INT, DINT, UDINT, REAL or TIME.data type.
Note: The function converts strictly in accordance with IEC rules. Since this
function has been realized as a generic function, there will also be a few illogical
conversions, e.g. UINT_TO_BOOL.
When converting an input value from the data type UINT into data type WORD, the
bit pattern from the input is transferred to the output without being modified.
When converting an input value of data type UINT into the data types BOOL or BYTE,
the least significant bits of the input are transferred to the output.
EN and ENO can be configured as additional parameters.
415
UINT_TO_***
EN ENO
416
UINT_TO_***
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l the value range on the output is exceeded (numeric data types)
l a negative input value is to be converted into an UDINT-, UINT or TIME output
value.
l an unauthorized floating point number is created during the conversion into the
REAL data type. In this case, the status is also placed in %SW17 (See Description
of system words %SW12 to %SW18, p. 451).
The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) and
system word %SW17 (See Description of system words %SW12 to %SW18, p. 451)
are not used when data types are converted:
l BOOL
l BYTE
l WORD
l DWORD
417
UINT_TO_***
418
WORD_AS_BYTE: Type
conversion
141
Description
Function The procedure converts an input value of the WORD data type to 2 output values of
description the BYTE data type.
The individual bytes of the word at the input are assigned to the outputs according
to the output names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD WORD_AS_BYTE
WORD_variable IN LOW LowByte
HIGH HighByte
Representation Representation:
in LD
WORD_AS_BYTE
EN ENO
HIGH HighByte
Representation Representation:
in IL LD WORD_variable
WORD_AS_BYTE LowByte, HighByte
419
WORD_AS_BYTE
Representation Representation:
in ST WORD_AS_BYTE (WORD_variable, LowByte, HighByte);
420
WORD_AS_DINT: Type
conversion
142
Description
Function The function converts 2 input values of the WORD data type to an output of the DINT
description data type.
The input values are assigned to the word at the output according to the input
names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD WORD_AS_DINT
WORD_variable1 LOW OUT DINT_variable
WORD_variable2 HIGH
Representation Representation:
in LD
WORD_AS_DINT
EN ENO
WORD_variable2 HIGH
421
WORD_AS_DINT
Representation Representation:
in IL LD WORD_variable1
WORD_AS_DINT WORD_variable2
ST DINT_variable
Representation Representation:
in ST DINT_variable := WORD_AS_DINT (WORD_variable1,
WORD_variable2) ;
422
WORD_AS_REAL: Type
conversion
143
Description
Function The procedure converts an input value of the 2WORD data type to output values
description of the REAL data type.
The input values are assigned to the word at the output according to the input
names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD WORD_AS_REAL
WORD_variable1 LOW OUT REAL_Output
WORD_variable2 HIGH
Representation Representation:
in LD
WORD_AS_REAL
EN ENO
WORD_variable2 HIGH
423
WORD_AS_REAL
Representation Representation:
in IL LD WORD_variable1
WORD_AS_REAL WORD_variable2, REAL_Output
Representation Representation:
in ST WORD_AS_REAL (WORD_variable1, WORD_variable2,
REAL_Output) ;
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1, if
l an unauthorized floating-point number is set at the input
l an unauthorized floating-point number is created during the conversion into the
REAL data type. In this case, the status is also placed in %SW17 (See Description
of system words %SW12 to %SW18, p. 451).
424
WORD_AS_TIME: Type
conversion
144
Description
Function The function converts 2 input values of the WORD data type to an output value of the
description TIME data type.
The input values are assigned to the word at the output according to the input
names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD WORD_AS_TIME
WORD_variable1 LOW OUT TIME_Output
WORD_variable2 HIGH
Representation Representation:
in LD
WORD_AS_TIME
EN ENO
WORD_variable2 HIGH
425
WORD_AS_TIME
Representation Representation:
in IL LD WORD_variable1
WORD_AS_TIME WORD_variable2
ST TIME_Output
Representation Representation:
in ST TIME_Output := WORD_AS_TIME (WORD_variable1,
WORD_variable2) ;
426
WORD_AS_UDINT: Type
conversion
145
Description
Function The function converts 2 input values of the WORD data type to an output value of the
description UDINT data type.
The input values are assigned to the word at the output according to the input
names.
EN and ENO can be configured as additional parameters.
Representation Representation:
in FBD WORD_AS_UDINT
WORD_variable1 LOW OUT UDINT_Output
WORD_variable2 HIGH
Representation Representation:
in LD
WORD_AS_UDINT
EN ENO
WORD_variable2 HIGH
427
WORD_AS_UDINT
Representation Representation:
in IL LD WORD_variable1
WORD_AS_UDINT WORD_variable2
ST UDINT_Output
Representation Representation:
in ST UDINT_Output := WORD_AS_UDINT (WORD_variable1,
WORD_variable2) ;
428
WORD_TO_BIT: Type conversion
146
Description
Function The procedure converts an input value of the WORD data type to 16 output values of
description the BOOL data type.
The individual bits of the word at the input are assigned to the outputs according to
the output names.
BIT0 (20)
BIT1 (21)
WORD
15 14
2 2 21 20
BIT14 (214)
BIT15 (215)
Representation Representation:
in FBD
WORD_TO_BIT
WORD_variable IN BIT0 BOOL_variable1
: :
BIT15 BOOL_variable16
429
WORD_TO_BIT
Representation Representation:
in LD
WORD_TO_BIT
EN ENO
BOOL_variable1
WORD_variable IN BIT0
: :
BOOL_variable16
BIT15
Representation Representation:
in IL LD WORD_variable
WORD_TO_BIT BOOL_variable1, BOOL_variable2,
BOOL_variable3, BOOL_variable4, BOOL_variable5,
BOOL_variable6, BOOL_variable7, BOOL_variable8,
BOOL_variable9, BOOL_variable10, BOOL_variable11,
BOOL_variable12, BOOL_variable13, BOOL_variable14,
BOOL_variable15, BOOL_variable16
Representation Representation:
in ST WORD_TO_BIT (WORD_variable, BOOL_variable1
BOOL_variable2, BOOL_variable3, BOOL_variable4,
BOOL_variable5, BOOL_variable6, BOOL_variable7,
BOOL_variable8, BOOL_variable9, BOOL_variable10,
BOOL_variable11, BOOL_variable12, BOOL_variable13,
BOOL_variable14, BOOL_variable15, BOOL_variable16);
430
WORD_TO_BIT
431
WORD_TO_BIT
432
WORD_TO_***: Type conversion
147
Description
Function The function converts an input value of the WORD data type to a BOOL, BYTE, DWORD,
description INT, DINT, UINT, UDINT, REAL or TIME data type.
When converting the WORD data type to the DWORD, DINT, UDINT, REAL or TIME
data type, the bit pattern of the input is transferred to the least significant bits of the
output. The most significant bits of the output are set to zero.
When converting the data type WORD to the data type BOOL or BYTE, the least
significant bits of the input value are transferred to the output.
433
WORD_TO_***
EN ENO
434
WORD_TO_***
Runtime error The system bit %S18 (See Description of system bits %S15 to %S21, p. 448) is set
to 1 and the status is stored in %SW17 (See Description of system words %SW12
to %SW18, p. 451) if
l an unauthorized floating-point number is created during the conversion into the
REAL data type.
435
WORD_TO_***
436
***_TO_STRING: Conversion of a
variable into a character string
148
Description
Function The ***_TO_STRING function converts an INT, DINT or REAL variable into a
description character string.
The additional parameters EN and ENO can be configured.
437
***_TO_STRING
Runtime errors If, during the conversion of a value of REAL type, Value1 is not between -
3.402824e+38 and -1.175494e-38 or +1.175494e-38 and +3.402824e+38, the bit
%S18 (See Description of system bits %S15 to %S21, p. 448) is set to 1 and the
contents of the string Result_Str is not significant.
438
Appendices
Introduction
439
Appendices
440
EFB Error Codes and Values
A
Overview
Introduction The following tables show the error codes and error values created for the EFBs of
the Base Library.
441
EFB Error Codes and Values
Introduction The following tables show the error codes and error values created for the EFBs of
the Base Library.
Date & Time Table of error codes and errors values created for EFBs of the Date & Time family.
EFB name Error code ENO Error Error Error description
state in value in value in
case of Dec Hex
error
DIVTIME E_DIVIDE_BY_ZERO F -30176 0x8A20 Divide by zero
DIVTIME E_NEGATIVE_INPUT_ F -30177 0x8A1F A negative value cannot be converted
FOR_TIME_ to data type TIME
OPERATION
DIVTIME E_ARITHMETIC_ F -30170 0x8A26 Arithmetic error
ERROR
DIVTIME E_ERR_ARITHMETIC F -30003 0x8ACD Arithmetic overflow (%S18 set)
DIVTIME FP_ERROR F - - See table Common Floating Point
Errors, p. 444
MULTIME E_ERR_ARITHMETIC F -30003 0x8ACD Arithmetic overflow (%S18 set)
MULTIME E_ARITHMETIC_ F -30172 0x8A24 Arithmetic error / Muliplication overflow
ERROR_MUL_OV
MULTIME E_ARITHMETIC_ F -30173 0x8A23 Arithmetic error / Addition overflow
ERROR_ADD_OV
MULTIME E_ARITHMETIC_ F -30171 0x8A25 Arithmetic error / Parameter exceeds
ERROR_BIG_PAR range
MULTIME E_NEGATIVE_INPUT_ F -30177 0x8A1F A negative value cannot be converted
FOR_TIME_ to data type TIME
OPERATION
MULTIME FP_ERROR F - - See table Common Floating Point
Errors, p. 444
442
EFB Error Codes and Values
Statistical Table of error codes and errors values created for EFBs of the Statistical
family.
EFB name Error code ENO Error Error Error description
state in value in value in
case of Dec Hex
error
AVE E_INPUT_VALUE_ F -30183 0x8A19 Input value is out of range
OUT_OF_RANGE
AVE E_DIVIDE_BY_ZERO F -30176 0x8A20 Divide by zero
AVE FP_ERROR F - - See table Common Floating Point
Errors, p. 444
AVE E_ARITHMETIC_ F -30170 0x8A26 Arithmetic error
ERROR
AVE E_FP_STATUS_ F -30150 0x8A3A Illegal floating point operation
FAILED
AVE E_ARITHMETIC_ F -30172 0x8A24 Arithmetic error / Muliplication overflow
ERROR_MUL_OV
AVE E_ARITHMETIC_ F -30173 0x8A23 Arithmetic error / Addition overflow
ERROR_ADD_OV
AVE E_ARITHMETIC_ F -30171 0x8A25 Arithmetic error / Parameter exceeds
ERROR_BIG_PAR range
AVE E_ARITHMETIC_ F -30174 0x8A22 Arithmetic error / Unsigned overflow
ERROR_UNSIGN_OV
MAX FP_ERROR F - - See table Common Floating Point
Errors, p. 444
MIN FP_ERROR F - - See table Common Floating Point
Errors, p. 444
MUX E_SELECTOR_OUT_ F -30175 0x8A21 Selector is out of range
OF_RANGE
443
EFB Error Codes and Values
Introduction The following table shows the commen error codes and error values created for
floating point errors.
444
System objects
B
At a Glance
Subject of this This chapter describes the system bits and words of Unity Pro language.
Chapter
Note: The symbols, associated with each bit object or system word, mentioned in
the descriptive tables of these objects, are not implemented as standard in the
software, but can be entered using the data editor.
They are proposed in order to ensure the homogeneity of their names in the different
applications.
445
System objects
General The Premium, Atrium and Quantum PLCs use %Si system bits which indicate the
state of the PLC, or they can be used to control how it operates.
These bits can be tested in the user program to detect any functional development
requiring a set processing procedure.
Some of these bits must be reset to their initial or normal state by the program.
However, the system bits that are reset to their initial or normal state by the system
must not be reset by the program or by the terminal.
446
System objects
447
System objects
448
System objects
449
System objects
CAUTION
%S16 for Quantum PLCs
On Quantum, communication errors from modules (NOM, NOE, NWM,
CRA, CRP) and MMS modules are not reported on bits %S10 and
%S16.
It is entirely your responsibility to ensure that these system bits are used
correctly
Failure to follow this precaution can result in injury or equipment
damage.
450
System objects
451
System objects
452
Glossary
%IW According to the IEC standard, %IW indicates an analog input -type language object.
%KW According to the IEC standard, %KW indicates a constant word-type language object.
%MW According to the IEC standard, %MW indicates a memory word-type language object.
%QW According to the IEC standard, %QW indicates an analog output-type language
object.
ADDR_TYPE This predefined type is used as output for ADDR function. This type is ARRAY[0..5]
OF Int. You can find it in the libset, in the same family than the EFs which use it.
ANL_IN ANL_IN is the abbreviation of Analog Input data type and is used when processing
analog values. The %IW adresses for the configured analog input module, which
were specified in the I/O component list, are automatically assigned data types and
should therefore only be occupied with Unlocated Variables.
453
Glossary
ANL_OUT ANL_OUT is the abbreviation of Analog Output data type and is used when
processing analog values. The %MW adresses for the configured analog input
module, which were specified in the I/O component list, are automatically assigned
data types and should therefore only be occupied with Unlocated Variables.
ANY There is a hierarchy between the different types of data. In the DFB, it is sometimes
possible to declare which variables can contain several types of values. Here, we
use ANY_xxx types.
The following diagram shows the hierarchically-ordered structure:
ANY
ANY_ELEMENTARY
ANY_MAGNITUDE_OR_BIT
ANY_MAGNITUDE
ANY_NUM
ANY_REAL
REAL
ANY_INT
DINT, INT, UDINT, UINT
TIME
ANY_BIT
DWORD, WORD, BYTE, BOOL
ANY_STRING
STRING
ANY_DATE
DATE_AND_TIME, DATE, TIME_OF_DAY
EBOOL
ANY_DERIVED
ANY_ARRAY
ANY_ARRAY_ANY_EDT
ANY_ARRAY_ANY_MAGNITUDE
ANY_ARRAY_ANY_NUM
ANY_ARRAY_ANY_REAL
ANY_ARRAY_REAL
ANY_ARRAY_ANY_INT
ANY_ARRAY_DINT
ANY_ARRAY_INT
ANY_ARRAY_UDINT
ANNY_ARRAY_UINT
ANY_ARRAY_TIME
ANY_ARRAY_ANY_BIT
ANY_ARRAY_DWORD
ANY_ARRAY_WORD
ANY_ARRAY_BYTE
ANY_ARRAY_BOOL
ANY_ARRAY_ANY_STRING
ANY_ARRAY_STRING
ANY_ARRAY_ANY_DATE
ANY_ARRAY_DATE_AND_TIME
ANY_ARRAY_DATE
ANY_ARRAY_TIME_OF_DAY
ANY_ARRAY_EBOOL
ANY_ARRAY_ANY_DDT
ANY_STRUCTURE
ANY_DDT
ANY_IODDT
ANY_FFB
ANY_EFB
ANY_DFB
454
Glossary
Base 10 literals A literal value in base 10 is used to represent a decimal integer value. This value can
be preceded by the signs "+" and "-". If the character "_" is employed in this literal
value, it is not significant.
Example:
-12, 0, 123_456, +986
Base 16 Literals An literal value in base 16 is used to represent an integer in hexadecimal. The base
is determined by the number "16" and the sign "#". The signs "+" and "-" are not
allowed. For greater clarity when reading, you can use the sign "_" between bits.
Example:
16#F_F or 16#FF (in decimal 255)
16#F_F or 16#FF (in decimal 224)
Base 2 Literals A literal value in base 2 is used to represent a binary integer. The base is determined
by the number "2" and the sign "#". The signs "+" and "-" are not allowed. For greater
clarity when reading, you can use the sign "_" between bits.
Example:
2#1111_1111 or 2#11111111 (in decimal 255)
2#1110_0000 or 2#11100000 (in decimal 224)
Base 8 Literals A literal value in base 8 is used to represent an octal integer. The base is determined
by the number "8" and the sign "#". The signs "+" and "-" are not allowed. For greater
clarity when reading, you can use the sign "_" between bits.
Example:
8#3_77 or 8#377 (in decimal 255)
8#34_0 or 8#340 (in decimal 224)
455
Glossary
BOOL BOOL is the abbreviation of Boolean type. This is the elementary data item in
computing. A BOOL type variable has a value of either: 0 (FALSE) or 1 (TRUE).
A BOOL type word extract bit, for example: %MW10.4.
BYTE When 8 bits are put together, this is callad a BYTE. A BYTE is either entered in
binary, or in base 8.
The BYTE type is coded in an 8 bit format, which, in hexadecimal, ranges from
16#00 to 16#FF
DATE The DATE type coded in BCD in 32 bit format contains the following information:
l the year coded in a 16-bit field,
l the month coded in an 8-bit field,
l the day coded in an 8-bit field.
The DATE type is entered as follows: D#<Year>-<Month>-<Day>
This table shows the lower/upper limits in each field:
DATE_AND_ see DT
TIME
456
Glossary
457
Glossary
458
Glossary
Representation examples:
EBOOL EBOOL is the abbrevation of Extended Boolean type. It can be used to manage rising
or falling edges, as well as forcing.
An EBOOL type variable takes up one byte of memory.
459
Glossary
Elementary see EF
Function
ENO ENO means Error NOtification, this is the output associated to the optional input EN.
If ENO is set to 0 (caused by EN=0 or in case of an execution error),
l the outputs of function blocks remain in the status they were in for the last correct
executed scanning cycle and
l the output(s) of functions and procedures are set to "0".
FFB Collective term for EF (Elementary Function), EFB (Elementary Function Block) and
DFB (Derived Function block)
Function see EF
460
Glossary
GRAY Gray or "reflected binary" code is used to code a numerical value being developed
into a chain of binary configurations that can be differentiated by the change in
status of one and only one bit.
This code can be used, for example, to avoid the following random event: in pure
binary, the change of the value 0111 to 1000 can produce random numbers between
0 and 1000, as the bits do not change value altogether simultaneously.
Equivalence between decimal, BCD and Gray:
Decimal 0 1 2 3 4 5 6 7 8 9
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Gray 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101
-INF INF
461
Glossary
Integer Literals Integer literal are used to enter integer values in the decimal system. The values can
have a preceding sign (+/-). Individual underlines (_ ) between numbers are not
significant.
Example:
-12, 0, 123_456, +986
Located A located variable is a variable for which it is possible to know its position in the PLC
variables memory. For example, the variable Water_pressure, is associated with%MW102.
Water_pressure is said to be localized.
462
Glossary
Multiple Token Operating mode of an SFC. In multitoken mode, the SFC may possess several
active steps at the same time.
Naming An identifier is a sequence of letters, numbers and underlines beginning with a letter
conventions or underline (e.g. name of a function block type, an instance, a variable or a section).
(Identifier) Letters from national character sets (e.g: ö,ü, é, õ) can be used except in project and
DFB names. Underlines are significant in identifiers; e.g. A_BCD and AB_CD are
interpreted as different identifiers. Multiple leading underlines and consecutive
underlines are invalid.
Identifiers cannot contain spaces. Not case sensitive; e.g. ABCD and abcd are
interpreted as the same identifier.
According to IEC 61131-3 leading digits are not allowed in identifiers. Nevertheless,
you can use them if you activate in dialog Tools → Project settings in tab
Language extensions the ceck box Leading digits.
Identifiers cannot be keywords.
NAN Used to indicate that a result of an operation is not a number (NAN = Not A Number).
Example: calculating the square root of a negative number.
Note: The IEC 559 standard defines two classes of NAN: quiet NAN (QNAN) and
signaling NaN (SNaN) QNAN is a NAN with the most significant fraction bit set and a
SNAN is a NAN with the most significant fraction bit clear (Bit number 22). QNANs
are allowed to propagate through most arithmetic operations without signaling an
exception. SNAN generally signal an invalid-operation exception whenever they
appear as operands in arithmetic operations (See %SW17 and %S18).
463
Glossary
Procedure Procedures are functions view technically. The only difference to elementary
functions is that procedures can take up more than one output and they support data
type VAR_IN_OUT. To the eye, procedures are no different than elementary
functions.
Procedures are a supplement to IEC 61131-3.
464
Glossary
-INF INF
Note: The IEC 559 standard defines two classes of NAN: quiet NAN (QNAN) and
signaling NaN (SNaN) QNAN is a NAN with the most significant fraction bit set and a
SNAN is a NAN with the most significant fraction bit clear (Bit number 22). QNANs
are allowed to propagate through most arithmetic operations without signaling an
exception. SNAN generally signal an invalid-operation exception whenever they
appear as operands in arithmetic operations (See %SW17 and %S18).
Real Literals An literal real value is a number expressed in one or more decimals.
Example:
-12.0, 0.0, +0.456, 3.14159_26
Real Literals with An Literal decimal value can be expressed using standard scientific notation. The
Exponent representation is as follows: mantissa + exponential.
Example:
-1.34E-12 or -1.34e-12
1.0E+6 or 1.0e+6
1.234E6 or 1.234e6
465
Glossary
Single Token Operating mode of an SFC chart for which only a single step can be active at any
one time.
STRING A variable of the type STRING is an ASCII standard character string. A character
string has a maximum length of 65534 characters.
TIME The type TIME expresses a duration in milliseconds. Coded in 32 bits, this type
makes it possible to obtain periods from 0 to 2 32-1 milliseconds.
The units of type TIME are the following: the days (d), the hours (h), the minutes (m),
the seconds (s) and the milliseconds (ms). A literal value of the type TIME is
represented by a combination of previous types preceded by T#, t#, TIME# or
time#.
Examples: T#25h15m, t#14.7S, TIME#5d10h23m45s3ms
Time literals The units of type TIME are the following: the days (d), the hours (h), the minutes (m),
the seconds (s) and the milliseconds (ms). A literal value of the type TIME is
represented by a combination of previous types preceded by T#, t#, TIME# or
time#.
Examples: T#25h15m, t#14.7S, TIME#5d10h23m45s3ms
466
Glossary
Example: TOD#23:59:45.
TOPO_ADDR_ This predefined type is used as output for READ_TOPO_ADDR function. This type
TYPE is an ARRAY[0..4] OF Int. You can find it in the libset, in the same family than the
EFs which use it.
UDINT UDINT is the abbreviation of Unsigned Double Integer format (coded on 32 bits)
unsigned. The lower and upper limits are as follows: 0 to (2 to the power of 32) - 1.
Example:
0, 4294967295, 2#11111111111111111111111111111111, 8#37777777777,
16#FFFFFFFF.
UINT UINT is the abbreviation of Unsigned integer format (coded on 16 bits). The lower
and upper limits are as follows: 0 to (2 to the power of 16) - 1.
Example:
0, 65535, 2#1111111111111111, 8#177777, 16#FFFF.
467
Glossary
Unlocated An unlocated variable is a variable for which it is impossible to know its position in
variable the PLC memory. A variable which have no address assigned is said to be
unlocated.
Variable Memory entity of the type BOOL, WORD, DWORD, etc., whose contents can be modified
by the program during execution.
WORD The WORD type is coded in 16 bit format and is used to carry out processing on bit
strings.
This table shows the lower/upper limits of the bases which can be used:
Representation examples
468
Index
B
AC
Symbols A
%S10, 447 ABS, 215
%S11, 447 Absolute value computation
%S12, 447 ABS, 215
%S13, 447 ACOS, 217
%S15, 448 ACOS_REAL, 217
%S16, 448 ADD, 219
%S17, 448 ADD_***_***, 41
%S18, 449 ADD_***_TIME, 167
%S19, 449 ADD_TIME, 221
%S20, 450 Addition
%S21, 450 ADD, 219
%S9, 447 ADD_TIME, 221
%SD18, 452 Addition of a duration to a date
%SW12, 451 ADD_***_TIME, 167
%SW13, 451 Addition of a number to elements of a table
%SW14, 451 or addition of two tables
%SW15, 451 ADD_***_***, 41
%SW16, 451 AND, 179
%SW17, 452 AND function
***_TO_STRING, 437 AND, 179
AND_***_***, 45
Arc Cosine
Numerics ACOS, 217
100MSCOUNTER, 452 ACOS_REAL, 217
1RSTSCANRUN, 447 Arc Sine
1RSTTASKRUN, 450 ASIN, 223
ASIN_REAL, 223
Arc tangent
ATAN, 225
ATAN_REAL, 225
469
Index
470
Index
471
Index
472
Index
G Limit
LIMIT, 271
GE, 147
Limit with Indicator
GRAY_TO_INT, 377
LIMIT_IND, 275
Greater than
LIMIT_IND, 275
GT, 151
LN, 241
Greater than or equal to
LN_REAL, 241
GE, 147
LOG, 243
GT, 151
LOG_REAL, 243
Logic
I AND, 179
F_TRIG, 181
INC, 239 FE, 183
Incrementation of a variable NOT, 185
INC, 239 OR, 187
INDEXOVF, 450 R_TRIG, 189
INSERT_INT, 299 RE, 191
Insertion of a sub-string of characters RESET, 193
INSERT_INT, 299 ROL, 195
INT_AS_DINT, 379 ROR, 197
INT_TO_***, 381 RS, 199
INT_TO_BCD, 385 SET, 201
INT_TO_DBCD, 387 SHL, 203
INT_TO_STRING, 437 SHR, 205
Integer regulation SR, 207
PID_INT, 125 TRIGGER, 209
PWM_INT, 133 XOR, 211
IOERR, 447 Logical AND between tables and variables
IOERRTSK, 448 AND_***_***, 45
Logical negation of tables
NOT_***, 91
L Logical OR between tables and variables
LE, 155 OR_***_***, 95
LEFT_INT, 303 LT, 159
LEN_INT, 305
Length of a table
LENGTH_***, 73
Length of character string
LEN_INT, 305
LENGTH_***, 73
Less than
LT, 159
Less than or equal to
LE, 155
LIMIT, 271
473
Index
M MIN_***, 77
Minimum value function
Math
MIN, 281
ACOS, 217
Minimum value of table elements
ACOS_REAL, 217
MIN_***, 77
ASIN, 223
MOD, 245
ASIN_REAL, 223
MOD_***_***, 79
ATAN, 225
Modulo
ATAN_REAL, 225
MOD, 245
COS, 227
MOVE, 247
COS_REAL, 227
MOVE_***_***, 83, 85
EXP, 235
Assignment to tables, 83
EXP_REAL, 235
Table conversion, 85
INC, 229, 239
MUL, 249
LN, 241
MUL_***_***, 87
LN_REAL, 241
MULTIME, 171
LOG, 243
Multiplexer
LOG_REAL, 243
MUX, 283
SIN, 255
Multiplication
SIN_REAL, 255
MUL, 249
TAN, 263
MULTIME, 171
TAN_REAL, 263
Multiplication of tables
Mathematic
MUL_***_***, 87
ADD_TIME, 221
MUX, 283
SUB_TIME, 259
Mathematics
ABS, 215 N
ADD, 219
Natural exponential
DIV, 231
EXP, 235
DIVMOD, 233
EXP_REAL, 235
EXPT_REAL_***, 237
Natural logarithm
MOD, 245
LN, 241
MOVE, 247
LN_REAL, 241
MUL, 249
NE, 163
NEG, 251
NEG, 251
SIGN, 253
Negation
SQRT_***, 261
NEG, 251
SUB, 257
NOT, 185
MAX, 279
NOT, 185
MAX_***, 75
Not equal to
Maximum of table elements
NE, 163
MAX_***, 75
NOT_***, 91
Maximum value function
MAX, 279
MID_INT, 307
MIN, 281
474
Index
475
Index
SORT_***, 103 T
SQRT_***, 261
Table conversion
Square root
MOVE_***_***, 85
SQRT_***, 261
Table functions
SR, 207
ADD_***_***, 41
Statistics
AND_***_***, 45
AVE, 267
COPY_***_***, 49
LIMIT, 271
DIV_***_***, 53
LIMIT_IND, 275
EQUAL_***, 57
MAX, 279
FIND_EQ_***, 61
MIN, 281
FIND_EQP_***, 63
MUX, 283
FIND_GT_***, 67
SEL, 287
FIND_LT_***, 69
STRING_TO_***, 399
LENGTH_***, 73
STRING_TO_DINT, 399
MAX_***, 75
STRING_TO_INT, 399
MIN_***, 77
STRING_TO_REAL, 399
MOD_***_***, 79
STRINGERROR, 448
MOVE_***_***, 83, 85
SUB, 257
MUL_***_***, 87
SUB_***_***, 105, 173
NOT_***, 91
SUB_***_TIME, 175
OCCUR_***, 93
SUB_TIME, 259
OR_***_***, 95
Subtraction
ROL_***, 99
SUB, 257
ROR_***, 101
SUB_TIME, 259
SORT_***, 103
Subtraction from tables
SUB_***_***, 105
SUB_***_***, 105
SUM_ARINT, 109
Subtraction of a duration from a date
SWAP_***, 111
SUB_***_TIME, 175
XOR_***_***, 113
Sum of table elements
TAN, 263
SUM_***, 109
TAN_REAL, 263
SUM_***, 109
Tangent
SWAP_***, 111
TAN, 263
TAN_REAL, 263
TIME_AS_WORD, 401
TIME_TO_***, 403
TIME_TO_STRING, 405
476
Index
477
Index
478