Functions

Functions have an output parameter and one or more input parameters.

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

FactoryTalk Design Workbench
does not support recursive function calls. When a function of the Functions section is called by itself or one of its called functions, a run-time error occurs. Functions do not store the local values of their local variables. Because functions are not instantiated, they cannot call function blocks.
  • A function can be called by a program, a function, or a function block.
  • Any program of any section can call one or more functions. A function can have local variables.
  • A function has no instance, which means that local data is not stored and is typically lost from one call to the other.
  • Because the execution of a function is driven by its parent program, the execution of the parent program is suspended until the function ends.
Calling function diagram
A diagram describing the function-calling rules

Defining function and parameter names

The interface of a function must be explicitly defined with a type and a unique name for each of its calling (input) parameters or return (output) parameters. A function has one return parameter. The value of a return parameter for a function block is different for each programming language (structured text, ladder diagram, or function block diagram languages).
Function names and function parameter names can contain up to 128 characters. Function 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