Division - Mitsubishi MELSEC System Q Manual

Hide thumbs Also See for MELSEC System Q:
Table of Contents

Advertisement

Math Instructions
6.4.4

Division

The DIV instruction divides one number by another
Ladder Diagram
³ Dividend
· Divisor
» Quotient (result of the division, dividend ÷ divisor = quotient)
In the above example the contents of data register D1 is divided by the contents of D2. The
result is stored in D3.
NOTE
The divisor should never be 0. Division by 0 is not possible and will generate an error which
stops the PLC CPU. (This case is possible when, as shown in the above example, the divi-
sion is performed with the contents of data registers and these registers have been cleared
with a RESET operation. To avoid a stop of the PLC the data register containing the divísor
should be set to an defined value by the PLC program before execution of the DIV instruc-
tion.)
The data types of the input and output variable of the DIV instruction must be identical. When
integer values (INT or DINT) are devided, the quotient will be also an integer value. To deter-
mine the remainder of the calculation the MOD instruction can be used.
Ladder Diagram
The input variables of the MOD instruction are the same as for the DIV instruction. In the above
example the contents of data register D1 is divided by the contents of D2. The quotient is
stored in D3 and the remainder in D4:
D 1
40
The signs of the values are taken into account by the DIV instruction. In this example the coun-
ter value of C0 is divided by the value in D10:
6 – 30
D2
D3
Ö
6
6
D 4
4
More Advanced Programming
IEC Instruction List
Quotient (6 x 6 = 36) (Output of the DIV instruction)
Remainder (40 - 36 = 4) (Output of MOD instruction)
C 0
D 10
Ö
36
-5
IEC Instruction List
LD
D1
DIV
D2
ST
D3
LD
D1
DIV
D2
ST
D3
LD
D1
MOD
D2
ST
D4
D 200
-7
MITSUBISHI ELECTRIC

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents