6 Programming
6-10
NJ-series CPU Unit Software User’s Manual (W501)
Algorithm
You can code the algorithm either as a ladder diagram or in ST. You can use any instruction, user-
defined function, or user-defined function block in the algorithm.
Local Variable Table
The local variable table is used to define input variables, output variables, in-out variables, internal
variables, and external variables.
Refer to Variable Designations for Function Blocks on page 6-11 for details.
Parameters
Input Parameters to Input Variables
An input parameter passes a value to an input variable in a function block when function block exe-
cution begins. An input parameter can be either a variable or a constant.
Output Parameters from Output Variables
An output parameter receives a value from an output variable in a function block when function block
execution is completed. A variable is given as the parameter.
In-Out Parameters Shared between In-Out Variables
The value of the in-out parameter changes within the function block. The same variable is used for
both the input and output.
You can omit input and output parameters. Refer to information on operation when parameters
are omitted in 6-2-7 Operation That Applies to Both Functions and Function Blocks for details.
]
The following example shows how to call function blocks from ST.
instance_name(input_variable_1:=input_parameter_1, ... input_variable_N:=input_parameter_N,in-
out_variable_1:=in-out_parameter_1, ... in-out_variable_N:=in-
out_parameter_N,output_variable_1=>output_parameter_1, ...
output_variable_N=>output_parameter_N);
You can also omit input variable names and other variable names, and give only the parameters. (If you
do, the parameters must be given in the order that they are given in the function block definition.) Also,
the number of parameters must match the number of input variables and other variables in the function
block definition.
Function Blocks Expressed in ST:
Calling Function Blocks from ST
TON
PT
In
ET
b
d
a
Q
TON_instance
c
TON_instance(In:=a, PT:=b, Q=>c, ET=>d);
TON_instance(In:=a, PT:=b, Q=>c); (*The ET output is omitted here.*)
TON_instance(a,b,c,d); (*Input and output variables are omitted here.*)
Instance name