Mitsubishi Electric MELSEC iQ-R Series Programming Manual page 69

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

Advertisement

Precautions
■ When an assignment statement is used
• Up to 255 characters can be assigned to a string. If characters are assigned exceeding the valid range, a conversion error
occurs.
• Timer type and counter type contacts and coils cannot be used at the left side of an assignment statement.
• Instances of function blocks cannot be used at the left side of an assignment statement. Use the input variable, output
variable, or external variable of an instance.
■ When the step relay (S) or SFC block device (BL) is used
If the step relay (S) or SFC block device (BL) is used at the left side of an assignment statement or as an input argument of a
function or function block, a conversion error may occur. If an error occurs, change the assignment statement.
Ex.
The following is the example of rewriting.
Before change
M0 := S0;
In addition, to use the digit-specified step relay (S) or the step relay with block specification (BL\S), the data size must be
specified correctly. Since the step relay (S) and the step relay with block specification (BL\S) are not targeted for
automatic conversion of data type, a conversion error may occur if the data size is not the same.
Ex.
The following is the example of rewriting.
Before change
(*Conversion error because K4S0 is 16 bits and D0:UD is 32 bits*)
D0:UD := K4S0;
(*Conversion error because BL1\K4S10 is 16 bits and the second argument of
DMOV is 32 bits*)
DMOV(TRUE,BL1\K4S10,D100);
■ When the result of an arithmetic operation is assigned
When assigning the result of an arithmetic operation to a data type variable with larger data size, convert the variable of the
arithmetic operational expression to the data type of the left side in advance.
Ex.
To assign the arithmetic operation result with a data size of 16 bits (INT type) to the 32-bit data type (DINT type):
varDint1 := varInt1 * 10; //The varInt1 is an INT type variable, and the varDint1 is a DINT type variable.
The result of the arithmetic operation will be the same data type as the input operand. For this reason, if the operation result of
varInt1*10 in the above program exceeds the INT type range (-32768 to 32767), the operation result of overflow or underflow
is assigned to varDint1.
In this case, convert the operand of the operational expression to the data type of the left side in advance.
varDint2 := INT_TO_DINT( varInt1 ); //An INT type variable is converted to a DINT type variable.
varDint1 := varDint2 * 10; //Multiplication is performed in DINT type, and the operation result is assigned.
After change
IF S0 THEN
M0 := TRUE;
ELSE
M0 := FALSE;
END_IF;
After change
(*Assign data to the 16-bit device.*)
D0 := K4S0;
(*Specify 32-bit data for DMOV.*)
DMOV(TRUE, BL1\K8S10, D100:UD);
6 STRUCTURED TEXT LANGUAGE
6
67
6.1 Configuration

Advertisement

Table of Contents
loading

Table of Contents