Functions and Function Blocks
Differences Between Functions and Function Blocks
| Item | Function | Function Block |
|---|---|---|
| Retains internal variables | No | Yes |
| Instance | Not needed | Required |
| Use | Calculations | Processing that retains state |
| Example | MOVE、ADD | TON, TOF, communication FBs |
Function
![]()
A function executes its processing every time it is called. It does not retain internal state.
Examples: MOVE, INC, etc.
Function Block (FB)
![]()
Function blocks (FBs) are used by creating instances
The created instances always run while the PLC is in RUN mode, and execute a series of processing triggered by the start instruction on an input variable
FBs normally handle processing that spans multiple scans, so the outputs indicate whether processing is in progress or has completed normally or with an error
Because FBs can retain internal variables, information from the previous scan can be used in the next scan.
What Is an Instance?
FBs are used by creating instances, but what is an instance...
In textbook terms, the FB is the blueprint and the instance is the actual object
For TON
For example, with the on-delay timer TON,
you create instances and name the first one TON000 and the second one TON001

TON000 and TON001 are the TON instances
TON000 → holds its elapsed time
TON001 → holds a different elapsed time
Even with the same TON, the internal data is managed separately
In everyday terms
If a washing machine blueprint is the FB,
you create two instances of the washing machine FB and name the first "Washer 1" and the second "Washer 2"
Now you have two washing machines with the same function
Each can wash something different, so put clothes in Washer 1 and a blanket in Washer 2, set the parameters for each and wash
When processing completes, clean clothes and a clean blanket are output

