Function blocks

A function block is an instruction block that has input and output parameters and works on internal data (parameters). It can be written in structured text (ST), ladder diagram (LD), or function block diagram (FBD) languages.

Instruction block format

An instruction block is represented by a single rectangle and has a fixed number of input and output connection points. An elementary instruction block performs a single function.
Instruction block example
Instruction block
Item
Name
Description
Callout1
Block name
The name of the function to be performed by the instruction block is written inside its rectangle shape (at the top).
Callout2
Input
Each input of an instruction block is labeled and has a defined type.
Callout3
Output
Each output of an instruction block is labeled and has a defined type.
Callout4
Input connection
Inputs are connected on the left border.
Callout5
Output connection
Outputs are connected on the right border.
Callout6
Output value
Output values are displayed when the controller is online. It is "??" when the controller is offline and there is no default value.

Calling a function block

When a function block is called in a program, an instance of the block is called. The instance uses the same code, but the input and output parameters are instantiated, which means local variables are copied for each instance of the function block. The values of the variables of a function block instance are stored from one cycle to the other.
A function block can be called by a program or another function block. Function blocks cannot be called by functions because functions are not instantiated.

Defining function block and parameter names

The interface of a function block must be explicitly defined with a type and a unique name for each of its calling (input) parameters or return (output) parameters. Function blocks can have more than one output parameter. The value of a return parameter for a function block is different for each programming language (FBD, LD, and ST).
Function block names and function block parameter names can contain up to 128 characters. Function block parameter names can begin with a letter or an underscore, followed by letters, numbers, and single underscore characters.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal