POUs and Tasks
What Is a POU?
The elements of user programs, functions and function blocks
These are the ones shown here
| Type | Characteristics | Use |
|---|---|---|
| Program | Assigned to a task and executed | Controls the whole machine |
| Function | Does not retain state | For calculations |
| Function Block | Retains state | For processing that needs to retain state |
What Is a Task?
The unit for executing programs that perform a series of processing.
POUs are assigned to tasks. Some tasks run at a fixed period, and the execution period and priority can be set for each task
With the settings above, Program0 runs every 1 ms, and program1 → program2 run in that order every 10 ms
(Periodic task 17 at 50 ms is empty)
Guidelines for task periods and assigning POUs
What is the primary periodic task?
The most important task on the NJ/NX series.
It is linked to the EtherCAT communication cycle, so control processing is normally placed here.
Basically
Try putting all programs in the primary periodic task and running them
Turn on program start conditions and so on to put load on the program
If the maximum execution time in the task execution time monitor is within 80%, there should be no problem

If you can lengthen the primary periodic task period
Try lengthening the period of the primary periodic task
[ Effect on EtherCAT slaves ]
Lengthening the primary periodic task period also lengthens the EtherCAT communication cycle, so I/O of connected slaves becomes slower
For servos and analog, fine control may no longer be possible, accuracy may get worse and the machine cycle may get longer
If there is an HMI
HMI I/O does not need to be very fast: a response of about 50 ms for buttons and updating display data every 50 ms is enough, so create a 20 to 50 ms periodic task and put the HMI processing there
If there is communication processing
When connecting to external devices via serial or Ethernet, data processing tends to be large, so if it lengthens the time, try putting it in a separate task
If calculations are not needed every period
If a large amount of complex calculation does not need to run every period, try putting it in a separate task
Task period guidelines
| Use | Period |
|---|---|
| Servo control | 1ms |
| I/O control | 1〜10ms |
| Communication processing | 10〜50ms |
| HMI processing | 0〜100ms |
| File processing | 100 ms or more |
Bonus: Time-Consuming Instructions
CONCAT
An instruction that concatenates strings; this is slow in any language
The program gets longer, but when a lot of string manipulation is needed, processing with byte arrays is faster
LrealToFormatString
An instruction that converts LREAL to a string
Converting to an integer type first and then to a string is faster
FAQ
What is a POU?
A program component defined by IEC 61131-3. There are Programs, Functions and Function Blocks.
What is the difference between a Function and a Function Block?
A Function does not retain state. A Function Block retains state.
How many tasks should I create?
It is best to start with a single primary periodic task and split it according to functions and load.
