Each FFB is made up of an operation (name of the FFB), the operands are required for the operation (formal and actual parameters) and an instance name for elementary/derived function blocks.
Call of a function block in the FBD programming language:
Formal call of a function block in the ST programming language:
The operation determines which function is to be executed with the FFB, e.g. shift register, conversion operations.
The operand specifies what the operation is to be executed with. With FFBs, this consists of formal and actual parameters.
Inputs and outputs are required to transfer values to or from an FFB. These are called formal parameters.
Objects are linked to formal parameters; these objects contain the current process states. They are called actual parameters.
At program runtime, the values from the process are transferred to the FFB via the actual parameters and then output again after processing.
The data type of the actual parameters must match the data type of the input/output (formal parameters). The only exceptions are generic inputs/outputs whose data type is determined by the actual parameter. If the actual parameters consist of literals, a suitable data type is selected for the function block.
In text languages IL and ST, FFBs can be called in formal and in informal form. For detail, refer to chapter
Programming Language.
Example of a formal function call:
out:=LIMIT (MN:=0, IN:=var1, MX:=5);
Example of an informal function call:
out:=LIMIT (0, var1, 5);
NOTE: The use of EN and ENO is only possible for formal calls.
FFBs are often used to read a variable at an input (input variables), to process it and to output the altered values of the same variable (output variables).
This special type of input/output variable is also called a VAR_IN_OUT variable.
The input and output variable are linked in the graphic languages (FBD and LD) using a line showing that they belong together.
Function block with VAR_IN_OUT variable in FBD:
Function block with VAR_IN_OUT variable in ST:
MY_EXAMP1 (IN1:=Input1, IN2:=Input2, IO1:=Comb_IN_OUT,
OUT1=>Output1, OUT2=>Output2);
The following points must be considered when using FFBs with VAR_IN_OUT variables:
The following additional limitations apply to the graphic languages (FBD and LD):
-
When using graphic connections, VAR_IN_OUT outputs can only be connected with VAR_IN_OUT inputs.
-
Only one graphical link can be connected to a VAR_IN_OUT input/output.
-
Different variables/variable components can be connected to the VAR_IN_OUT input and the VAR_IN_OUT output. In this case the value of the variables/variable component on the input is copied to the output variables/variable component.
-
No negations can be used on VAR_IN_OUT inputs/outputs.
-
A combination of variable/address and graphic connections is not possible for VAR_IN_OUT outputs.