Mitsubishi Electric MELSEC iQ-F FX5 Programming Manual page 44

Program design
Hide thumbs Also See for MELSEC iQ-F FX5:
Table of Contents

Advertisement

■Function call statement
Format
Function name(Variable1, Variable2, ...);
Assigning to variables stores the execution result of the function.
Function
Calling a function with one input variable (Example: ABS)
Calling a function with three input variables (Example:
MAX)
Calling a function with EN/ENO (excluding standard
functions) (Example: MAX_E)
Calling a standard function (Example: MOV)
A user-defined function that does not return a value and a function that includes a VAR_OUTPUT variable in the argument of
a call statement can be executed as a statement by adding a semicolon (;) at the end.
■RETURN statement
Syntax
Format
RETURN;
■RETURN
A user-defined function that does not return a value and a function that includes a VAR_OUTPUT variable in the parameter of
a call statement can be executed as a statement by adding a semicolon (;) at the end.
Conditional statement
Syntax
Format
IF <Boolean expression> THEN
■IF
<Statement> ;
END_IF;
IF <Boolean expression> THEN
■IF...ELSE
<Statement 1> ;
ELSE
<Statement 2> ;
END_IF;
IF <Boolean expression 1> THEN
■IF...ELSIF
<Statement 1> ;
ELSIF <Boolean expression 2> THEN
<Statement 2> ;
ELSIF <Boolean expression 3> THEN
<Statement 3> ;
END_IF;
6 ST LANGUAGE
42
6.1 Configuration
Description
Enclose an argument by "()" after the function name.
When using multiple arguments, delimit them by "," (comma).
Example
Outout1
:= ABS(Input1);
Outout1
:= MAX(Input1, Input2, Input3);
Output1
:= MAX_E(boolEN, boolENO, Input1, Input2, Input3);
boolENO
:= MOV(boolEN, Input1, Output1);
(The execution result of the function is ENO and the first argument (Variable1) is EN.)
Description
The RETURN statement is used to end a program, function
block, or function in the middle of processing.
When the RETURN statement is used in a program, the
processing jumps to the next step after the last line of the
program.
When the RETURN statement is used in a function block, the
processing is returned from the function block.
When the RETURN statement is used in a function, the
processing is returned from the function.
One pointer type label is used by the system for one RETURN
statement.
Description
The statement is executed when the value of Boolean
expression (conditional expression) is TRUE. The statement is
not executed if the value of Boolean expression is FALSE.
Any expression that returns TRUE or FALSE as the result of the
Boolean operation with a single bit type variable status, or a
complicated expression that includes many variables can be
used for the Boolean expression.
Statement 1 is executed when the value of Boolean expression
(conditional expression) is TRUE.
Statement 2 is executed when the value of Boolean expression
is FALSE.
Statement 1 is executed when the value of Boolean expression
(conditional expression) 1 is TRUE. Statement 2 is executed
when the value of Boolean expression 1 is FALSE and the
value of Boolean expression 2 is TRUE.
Statement 3 is executed when the value of Boolean expression
1 and 2 are FALSE and the value of Boolean expression 3 is
TRUE.
Example
IF
bool1
THEN
RETURN;
END_IF;
Example
IF
bool1
THEN
intV1:=intV1+1;
END_IF;
IF
bool1
THEN
intV3:=intV3+1;
ELSE
intV4:=intv4+1;
END_IF;
IF
bool1
THEN
intV1:=intV1+1;
ELSIF
bool2
THEN
intv2:=intV2+2;
ELSIF
bool3
THEN
intV3:=intV3+3;
END_IF;

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents