Chapter 8 Logic Instructions
The input and output variables are allowed to be of different data types in this instruction. When the
data types of input and output variables are different, the range of the data type of the output
variable must include the valid ranges of data types of all input variables. Otherwise, there will be an
error during the compiling of the software. For example, if the data types of In1 and In2 are INT and
DINT respectively, the data type of Out is DINT. There will be an error during the compiling of the
software if the data type of Out is INT. No error will occur during the compiling of the software if the
data type of Out is LINT.
Precautions for Correct Use
The input variables are not allowed to omit. An error will occur during the compiling of the software if
any input variable is omitted. But the output variable is allowed to omit.
The input value of In2 can not be 0. In other words, the divisor in the division operation can not be 0.
The value of Out will be 0 if the value of In2 is 0.
The division result of In1 and In2 may be out of the valid range of the data type of Out.
For example, the data types of “DIV _In1” and “DIV _In2” are both INT with their respective values,
-32768 and -1. If the data type of the output variable is INT, the output variable value will be -32768
as shown in the following table, variable 1. If the data type of the output variable is set to DINT, the
output variable value will be 32768 as shown in the following table, variable 2.
Variable 1
Variable 2
DIV_In2
INT
-1
Out1
DINT
32768
The Program
1
DIV
EN ENO
In1 Out
In2
DIV_EN
DIV_In1
DIV_In2
Out1
The result is always an integer for the division of two integers. Even if there is a remainder for the
division of two integers, the remainder is cut.
For example, the data types of In1 and In2 are both INT with their respective values, 10 and 3. And
the data type of Out is INT and Real and thus its value is 3 and 3.0 respectively as illustrated in the
following figure.
In1 In2/
=
Division result
Out1
INT
3 INT10 3 3
Out2 3.0 REALINT INT
8-63