6-17
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-2 POUs (Program Organization Units)
6
6-2-6 Details on Functions
In a ladder diagram, functions are represented as rectangular boxes as shown below. Refer to Express-
ing Functions in ST on page 6-18 for details about how to express functions in ST. A function consists of
the following parts.
Function in Ladder Diagram:
Function Name or Instruction Name
This is the function name or instruction name assigned in the function definition when the function is
defined.
Instance Name
Functions do not have instance names.
Algorithm
You can code the algorithm either as a ladder diagram or in ST. You can use function instructions or
user-defined functions in the algorithm of a function. You cannot use any FB instructions or user-
defined function blocks. You also cannot use a differentiated instruction (e.g., R_TRIG or UP).
You cannot use the P_First_RunMode and P_First_Run system-defined variables.
6-2-6 Details on Functions
Structure of Functions
Function name or instruction name
Input variables
Output variable
EN input
ENO output
Input parameters
Output parameter
Return value
EN ENO
Para1
MyFUN
Out1
In1
In2
Para2
ret_val
Output1
Input parameter
Input
variable
Output
variable
Output paramete
EN
(return value)
Function
Algorithm
Local variable table
In-out
variable
Internal variables
FUN instruction
User-defined
function