Differences Between a Function and a Function Block
A function:
ois a POU (Program Organization Unit) that returns one immediate result.
ois directly called with its name (not through an instance).
ohas no persistent state from one call to the other.
ocan be used as an operand in other expressions.
Examples: boolean operators (AND), calculations, conversion (BYTE_TO_INT)
A function block:
ois a POU (Program Organization Unit) that returns one or more outputs.
oneeds to be called by an instance (function block copy with dedicated name and variables).
oeach instance has a persistent state (outputs and internal variables) from one call to the other from a function block or a program.
Examples: timers, counters
In the example, Timer_ON is an instance of the function block TON: