Differences Between Functions and Function Blocks
It is important to clearly understand what is different between functions and function blocks.
- A FunctionA function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. ( ) is called once and it performs an action. This is synchronous.
- A Function BlockA function block groups an algorithm and a set of private data. It has inputs and outputs. ( ) or "FB" is an instance that has its own set of data. A FB very likely maintains its own, internal machine state and very often has an output to indicate when the work is done. A FB is most likely to be asynchronous.
The best way to work with a function block is to call it during multiple scan. This triggers the action the first time, then you may monitor the status of this action, especially via the "done" output.