Division - Mitsubishi Electric FX2N Beginners Manual

Hide thumbs Also See for FX2N:
Table of Contents

Advertisement

More Advanced Programming
5.4.4

Division

The MELSEC FX family's DIV instruction divides one number by another (contents of two
16-bit or 32-bit devices or constants). This is an integer operation and cannot process float-
ing-point values. The result is always an integer and the remainder is stored separately.
Ladder Diagram
0
³ Dividend
· Divisor
» Quotient (result of the division, dividend ¸ divisor = quotient)
NOTES
The divisor should never be 0. Division by 0 is not possible and will generate an error.
When two 16-bit values are divided the quotient is written to one 16-bit device and the re-
mainder is written to the next device. This means that the result of a division always requires
two consecutive 16-bit devices (= 32 bits).
When you divide two 32-bit values the quotient is written to two 16-bit devices and the re-
mainder is written to the next two 16-bit devices. This means that four consecutive 16-bit de-
vices are always required for the result of a 32-bit division.
Always take the size of these device ranges into account when you are programming and
take care not to create range overlaps by using the devices in the ranges to which the results
of the calculations are written!
Examples
Divide the contents of D0 by the contents of D1 and write the result to D2 and D3:
DIV D0 D1 D2
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:
DIV C0 D10 D200
FX Beginners Manual
DIV D0 D1 D2
D 0
D 1
Ö
40
6
C 0
D 10
Ö
36
-5
Math Instructions
Instruction List
0 DIV
D0
D1
D 2
6
Quotient (6 x 6 = 36)
D 3
4
Remainder (40 - 36 = 4)
D 200
Quotient
-7
D 201
Remainder
1
D2
5 – 25

Advertisement

Table of Contents
loading

Table of Contents