6-21
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-2 POUs (Program Organization Units)
6
6-2-6 Details on Functions
Return Values
• Return values are blank in ladder diagrams.
• The calling instruction is not required to use the return value in either a ladder diagram or ST.
• If you set the return value within a function algorithm, set the value to a variable with the same
name as the function.
For example, the return value of a function called MyFUN is MyFUN.
A function is executed when EN is TRUE. The function stops processing when EN changes to FALSE.
Case Ladder diagram notation ST language notation
Using return values variable_q:=
MyFUN1(variable_i);
Not using a return
value
MyFUN2(In1:=variable_i1,In2:=v
ariable_i2,
OutEQ=>variable_q1,
OutNE=>variable_q4 );
Execution Conditions for Functions
Input variables Algorithm in FUN ENO Operations other than ENO
EN = TRUE Executed. Normal end TRUE Output parameters: Values are updated according to
the internal algorithm.
In-out parameters: Values are updated according to
the internal algorithm.
Error end FALSE Output parameters: Values are retained.
In-out parameters: Values are updated according to
the internal algorithm.
EN = FALSE Not executed. FALSE Output parameters and in-out parameters: Values
are retained.
Inside a master
control region
Not executed. FALSE Output parameters and in-out parameters: Values
are retained.
Variable