Calling function blocks

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Calling function blocks

mapp Services V5.16

In Structured Text (ST), a function block is called by writing the name of the instance of the function block and then assigning the desired values to the parameters in parentheses.

Function blocks are called once in the context of a background task or once per cycle in a cyclic interpreter task.

Syntax

<fub_instance> ( <parameter1> := <expression1>, <parameter2> := <expression2>, ... <parameterN> := <expressionN> );

The order of assignments to parameters is irrelevant.

The result variables are addressed with the name of the function block instance, a subsequent period and the name of the result variable.

Example

TON_0(IN := Var1, PT := T#10s);
Var2 := TON_0.Q;

Instance "TON_0" of a timer is called. Parameters "IN" and "PT" are assigned in the call. Result variable "Q" is then assigned to variable "Var2".

Simplified call

When calling a function block, not all parameters must be assigned values. A function block can also be called without assigning a value to a parameter. The opening parenthesis is immediately followed by the closing parenthesis. In this case, a function block can also be called with simplified syntax. The parenthesis can be omitted; it is sufficient to specify the name of the function block instance with a semicolon at the end.