Functions and function blocks are FBD elements. Their inputs and outputs are called formal parameters.
A number inside of each function/function block symbol represents its position in the execution order of the project.
Functions
A function is a POU with multiple input parameters and exactly one output parameter (return value). Functions do not contain any internal state information. Therefore, calling a function with the same values returns always the same result. In case of extensible functions (AND/AND_S, OR/OR_S), inputs can be duplicated.
Function Blocks
A function block is a POU with multiple input/output parameters and internal memory. The value a function block returns depends on the value of its internal memory (i.e., calling a function block with the same values does not necessarily return the same result).
Within a function block, it is possible to call other function blocks or functions but not the 'Main' program. Recursive FB calls are not allowed.
To call a function block in another function block or in the 'Main' program, an instance of the called FB with a unique instance name has to be created and declared in the calling POU. The graphical editor automatically creates and declares a default instance name when inserting an FB into a code worksheet. Refer to the topic "Functions/Function Blocks: Inserting" for detailed information.
The FB instance name is shown above the function block symbol.
Colors in FBD/LD code
Function and FB colors
The color of a function/function block symbol points to the origin of the respective object. Safety-related system FUs/FBs as well as safety-related library FBs are displayed in red. Standard blocks are shown gray-blue. User FUs/FBs are displayed in green.
Connection point colors
Function/FB output connection points are displayed blue, inputs have green connection points. These connection points are the starting points when drawing connection lines to other functions, function blocks, variables, or LD objects. Once the objects are connected, the connection points are no longer visible.