Mitsubishi Electric MELSEC iQ-F Series Programming Manual page 58

Hide thumbs Also See for MELSEC iQ-F Series:
Table of Contents

Advertisement

■Using the operator "-" for sign inversion in an arithmetic operation
When the operator "-" is used to invert the sign of the minimum value of a data type, the minimum value evaluates to the same
value.
For example, -(-32768), where the operator "-" is used with the minimum value of INT type, evaluates to -32768. Thus, an
unintended result may be produced if the operator "-" is used to invert the sign of a variable whose data type will be
automatically converted.
Ex.
When the value of varInt1 (INT type) is -32768, and the value of varDint1 (DINT type) is 0.
varDint2
:=
-varInt1
In the example above, the value of (-varInt1) evaluates to -32768 and -32768 is assigned to varDint2.
When using the operator "-" to invert the sign of a variable in an arithmetic operation, perform automatic conversion of the
data type of the variable before the arithmetic operation. Alternatively, avoid using the operator "-" for sign inversion in the
program.
Ex.
Performing automatic conversion of the data type before an arithmetic operation
varDint3
:= varInt;
varDint2
:=
-varDint3
Ex.
Avoiding the use of the operator "-" for sign inversion
varDint2
:=
varDint1
■When a bit type label is used
Once the Boolean expression (conditional expression) is satisfied in a conditional statement or an iteration statement, the bit
type label that is turned ON in <Statement> is always set to ON.
Ex.
Program whose bit type label is always set to on
ST program
IF
bLabel1
THEN
bLabel2
:= TRUE;
END_IF;
To avoid the bit device to be always set to ON, add a program to turn OFF the bit type label as shown below.
Ex.
Program to avoid the bit type label to be always set to ON
*1
ST program
IF
bLabel1
THEN
bLabel2
:= TRUE;
ELSE
bLabel2
:= FALSE;
END_IF;
*1 The above program can also be described as follows.
bLabel2 := bLabel1;
or
OUT(bLabel1,bLabel2);
However, when the OUT instruction is used in <Statement>, the program status becomes the same as the program whose bit type label
is always set to on.
6 ST LANGUAGE
56
6.1 Configuration
+ varDint1;
+ varDint1;
- varInt1;
Ladder program equivalent to ST program
bLabel1
Ladder program equivalent to ST program
bLabel1
SET
bLabel2
bLabel2

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melsec iq-f fx5

Table of Contents