Function Block InstancesΒΆ

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

Each instance possesses its own identifier (the Instance name), and a data structure which contains its inputs, outputs, and internal variables. Instances are declared locally or globally as variables, whereas the name of the function block is indicated as the type of an identifier.

Regard the Recommendations on the naming Recommendations \ on the naming of identifiers.

Example

Example of an instance with the name INSTANCE of the FUB function block:

fubInstance: FUB;

Function blocks are always called through the instances described above.

Only the input and output parameters can be accessed from outside of an Function Block instance, not its internal variables.

Example for accessing an input variable

The function block FB has an input variable in1 of the type INT.

PROGRAM prog

VAR
fbinst1:fb;
END_VAR

LD 17
ST fbinst1.in1
CAL fbinst1

END_PROGRAM

The declaration parts of Function Block and programs can contain instance declarations. Instance declarations are not permitted in Function.

Access to a Function Block instance is limited to the POU in which it was declared unless it was declared globally.

The instance name of a Function Block instance can be used as the input for a function or a Function Block.

Note

All values are retained after processing a Function Block until the next it is processed. Therefore, Function Block calls with the same arguments do not always return the same output values!

Note

If at least one of the Function Block variables is a retain variable, the total instance is stored in the retain area.