Professional Documents
Culture Documents
IEC 61131-3 - Defines a wide range of standardized functions and function blocks, and also contains the
definitions of custom made functions and function blocks for manufacturers to follow.
FUNCTIONS
Are software modules which, when used only provide one result or output
Cannot contain status information, which means that the usage of a function with the same
inputs, must provide the same result or output.
Examples (Addition of Integer Values, Logic OR Functions)
Function Name
Output Parameters
Input Parameters
Parameter Names
USE OF PARAMETER NAMES WITH FUNCTIONS
The Boolean inputs or outputs of a function may be negated, by placing a circle directly outside
the rectangle.
OVERLOADED FUNCTIONS - Are functions which operate to input parameters of a different data type.
TYPE-INDEPENDENT FUNCTIONS - Are functions which operate using variables which are declared to
one data type.
TYPED FUNCTIONS - Are functions which are limited to a particular data type by the controller, Are
recognizable by their function name, where there is addition of an underline, followed by the desired
date type.
GENERIC DATA TYPES
Since there are different data types that can be used as input parameters, they have been
grouped together, a few are as shown in the table below:
Group
Definition
Name
ANY_NUM All data integer types for floating numbers such as REAL and for integer numbers such as
INT, UINT, etc.
ANY_INT All data types for integers such as INT, UINT, etc.
ANY_REAL All data types, defining floating-point numbers such as REAL or LREAL
ANY_BIT All bit sequence data types such as BOOL, BYTE, WORD, etc.
STANDARD FUNCTIONS
AND OR
XOR NOT
Name Description
SHL Shift IN by N bits to the left, fill with zeros to the right
SHR Shift IN by N bits to the right, fill with zeros to the left
This instruction shifts the IN bits to the left by N number of times, this instruction multiplies the
value of the input by 2N in Decimal Form
This instruction shifts the IN bits to the right by N number of times, this instruction divides the
value of the input by 2N in Decimal Form
COMPARISON FUNCTIONS
GT > Greater
EQ = Equal
LT < Less
Binary to Decimal – converts variables of type Byte, Word, etc., into variables of type INT
Decimal to Binary – converts variables of type INT into variables of type Byte, Word, etc.
FUNCTION BLOCKS
If a function block in a control program is to be used, a copy or instance must be created. This is
effected via the assignment of an instance name/identifier. Linked to this is a data structure
which stores the statuses of this function block copy (values of input parameters, output
parameters and internal variables). The status information of this copy remains intact from one
processing to the next.
These designations in Fig. B6.1 are for directly represented variables which means they are
referred directly to the hardware-related available inputs, outputs, and memory of the controller.
Different allocation of inputs, outputs, etc. are defined by their respective controller
manufacturer.
So long as the respective controller can support it, these resources can be addressed, and are
defined in an excess of one bit. EN 61131-3 designates the data types shown in Fig. B6.2 below
together with inputs, outputs, and flags. As a quick note, flags are one or more data bits used to
store binary values as specific program structure indicators, or in other words, are a component
of a programming language’s data structure.
Now, there is no way other than through the controller manufacturer, to know the specific
number range, which is permissible for this numbering and whether it should start with 0 or 1.
A hierarchical number of inputs, outputs and flags may be used, so long as the controller has
been suitably configured for it.
A point or dot shall be used to separate individual levels of the hierarchy.
The highest position in the number on the left must be coded.
The lower positions of the hierarchy on the right represent consecutive lower positions.
Let’s take for example I3.8.8, which can therefore be understood as follows:
5 PARTS OF THE GRAPHICAL REPRESENTATION OF A FUNCTION BLOCK
Input Output
Parameters Parameters
Parameter
Names
IEC 61131-3 permits the definition of own functions ff. the rules for graphic declaration:
Includes specification of all parts of the function (function name, parameter names,
input/output data types)
Includes specification of the names and data types of internal variables used in the function,
declared using a VAR… END_VAR construct may be used for this.
Programming of the function body in one of the languages: LD, FBD, IL, or ST.
IEC 61131-3 permits the definition of own function blocks ff. the rules for graphic declaration:
Includes specification of all parts of the function (function name, parameter names,
input/output data types)
Includes specification of the names and data types of internal variables used in the function,
declared using a VAR… END_VAR construct may be used for this.
Programming of the function body in one of the languages: LD, FBD, IL, or ST.
PROGRAMS
Consists of any language elements and constructs necessary to achieve the desired machine or
process behaviour via the PLC
Constructed in the main for functions, function blocks, and the elements of the sequential
function chart.
Program features are largely identical to those of function blocks, with some key differences:
. • Data is frequently required which contains specific information and a more complex nature.
Symbolic Addressing
• Symbolic Identifier always consists of capital or lower case letters, digits and an underline. •
An identifier must always begin with a letter or an underline.
• Several underlines are also impermissible. If the controller supports capital and lower case
letters, then the use of these letters are not significance.
Representation of Data • Within a control program, it must be possible for time values and
counter values to be specified.
• EN 61131-3 (IEC 61131-3) laid down the definitions for the representation of data to specify:
✓ Counter Values ✓ Time Values ✓ Strings
• The use of individual underlines between the digits is permissible to improve readability.
However, the underline is not significant.
• The specification of a time duration consists of an introductory part and a sequence of time
related sections.
• Capitals may also be used instead of lower case letters and individual underlines inserted for
the purpose of better readability. • Another method of representing data is the use of sequence
of characters known as strings. A String consists of zero or several characters, introduced and
ended by a simple inverted comma.
Data Types
• EN 61131-3 (IEC 61131-3) defines a large number of data types for different tasks.
• INT and UINT define integer numbers. • The range of values of data type INT covers both
negative and positive numbers. • Type UINT variables permit positive values only. • SINT (Short
integer) and DINT (double integer) have smaller or greater range of values than type INT. • Data
type TIME used to specify time and may contain a time duration.
Variable Declaration
• With the use of data, the right of access to this data must be clearly defined.
• All variable declarations always start with a keyword which designates the position of the
variable in the organization unit of the controller and end with the keyword END_VAR.
• EN 61131-3 (IEC 61131-3) differentiates between six different types of access to variables
namely:
• Input Variable - variables specified in this way represent input variables fed externally to an
organization unit. These can be read only within the organization unit.
• Output variables are defined with the keywords VAR_OUTPUT and END_VAR
• In-/Output Variable - variables containing input and output values are permitted through the
use of this keywords VAR_IN_OUT and END_VAR.
• In-/Output Variable - this represents a third option and permits the declaration of variables,
which may be read and used within the organisation unit.
• Local Variable - the variables specified here are local to an organisation unit and can only be
used within. The are unknown in all other organisation units.