-

IEC 61131-3 Functions and Function Blocks

IEC 61131-3 functions

A function (in short FU) is a POU with multiple input parameters and exactly one output parameter (return value). Calling a function with the same values returns always the same result. Return values can be single data types. Within a function it is possible to call another function but not a function block or a program. Recursive calls are not allowed.

Functions can only process elementary data types. The use of user-defined data types like STRUCTs and ARRAYs in function POUs results in a compiler error (CIL generator error).

IEC 61131-3 describes standard functions. Depending on the used hardware and controller type possibly not all standard functions are available or additional firmware functions are provided.

IEC 61131-3 defines the following groups of standard functions:

IEC 61131-3 function blocks

A function block (in short FB) is a POU with multiple input/output parameters and internal memory. The value a function block returns depends on the value of its internal memory. Within a function block it is possible to call another function block or functions but not a program. Recursive calls are not allowed.

IEC 61131-3 describes standard function blocks. Depending on the used hardware and controller type possibly not all standard function blocks are available or additional firmware function blocks are provided.

To call a function block in another function block or program, an instance of the called FB with a unique instance name has to be created and declared in the calling POU. The instance declaration must be added to the 'Variables' table (directly or while editing code). In the 'Variables' table each FB instance has its own declaration consisting of the unique FB instance name, the function block name and the declaration keyword ('Usage') 'Local'.

Further Info
For information on the instantiation of function blocks, See "Function block instantiation".

IEC 61131-3 defines the following groups of standard function blocks: