14
3 PROGRAM ORGANIZATION UNIT (POU)
3.1 Function (FUN)
Operation overview
The program of a function is stored in the FB/FUN file and called by the calling source program when executed
You can nest all function blocks and functions up to 32 times.
Labels defined by a function
The labels defined by a function are assigned in the temporary areas of the storage-target memory during execution of the
function, and the areas are freed after the processing completes.
The following figure shows the label assignments while the above functions are being executed.
For the types of labels that can be defined by a function, refer to the following.
Page 23 Class
The label to be defined by a function must be initialized by a program before the first access because the label
value will be undefined.
Number of steps
To call a function, the number of steps required is not only for the program itself but also for the processing that passes the
argument and return value, the processing that calls the program, and additional steps used by the system.
■Program
The number of steps required for a function program is the total number of instruction steps plus at least additional 13 steps
used by the system. For the number of steps required for each instruction, refer to the following.
Programming manual (Instructions, Standard Functions/Function Blocks)
FUN1
(Program file)
Main program
(FB file)
FUN1 program
(FB file)
FUN3 program
(FB file)
FUN2 program
FUN3
FUN2
Execution flow
1
2
3
4
5
7
6
Main program being
executed
Main program being
executed
Main program being
executed
FUN1 being executed
(before FUN3 is called)
FUN1 being executed
(after FUN3 is executed)
FUN3 being executed
FUN2 being executed
Label area of FUN1
Label area of FUN2
Label area of FUN1 Label area of FUN1
Label area of FUN3
1 2 3 4
5 6 7