Function BlockΒΆ

A function block is a POU which provides one or more values during the procedure.

As opposed to a Function, a function block provides no return value.

A function block declaration begins with the keyword FUNCTION_BLOCK. Regard the Recommendations \ on the naming of identifiers.

Reproductions or Function Block Instances (copies) of a Function Block can be created.

The Calling a function block is done via a function block instance.

Example in IL of a function block with two \ input variables and two output variables:

One output (iMulErg) is the product of the two inputs, the other (xVergl) is a comparison for equality:

Declaration part:

FUNCTION_BLOCK FUB
VAR_INPUT
    iPar1:INT;
    iPar2:INT;
END_VAR
VAR_OUTPUT
    iMulErg:INT;
    xVergl:BOOL;
END_VAR

Implementation part in IL:

LD iPar1
MUL iPar2
ST iMulErg

LD iPar1
EQ iPar2
ST xVergl