M800V/M80V Series PLC Programming Manual (1/2)
8 Function Instructions
8.2 Arithmetic Operation Instructions
Division result (quotient and remainder) is stored by using 32 bits.
Quotient (BCD 4-digit): Stored at the lower 16 bits
Remainder (BCD 4-digit): Stored at the upper 16 bits
When divisor S2 is "0", no operation is carried out.
Operation errors
In the following cases, an arithmetic error occurs, the error flag (SM0) turns ON, and an error code is stored at SD0.
- The BCD data of "S1","S2" or "D" is outside the 0 to 9999 range. (Error code: 80)
Program example
The following program multiplies the BCD data at X0 to XF and the BCD data at D8 when X1B goes ON, and stores the
result at D0 and D1.
X1B
0
5
XF
X0
×
9
7
5
3
Multiplicand
The following program divides the BCD data D7 by the BCD data 1234, stores the result at D502 and D503, and at the
same time outputs the quotient to Y30 to Y3F.
M400
0
8
D7
5
6
7
8
/
[Ladder mode]
B*P K4X0 D8 D0
END
(Upper 4 digits)
D8
8
6
4
2
8
Multiple
[Ladder mode]
B/P D7 H1234 D502
MOVP D502 K4Y30
END
(Upper 4 digits)
1
2
3
4
0
X3F
Steps
0
1
5
D+1
D
(Lower 4 digits)
5
4
2
6
4
2
8
Multiplication result
Steps
0
1
5
8
D+1
D
(Lower 4 digits)
0
0
4
0
7
4
2
Quotient
Remainder
X30
0
0
0
4
Quotient
189
[List mode]
Inst.
Device
LD
X1B
B*P
K4X0
D8
D0
END
[List mode]
Inst.
Device
LD
M400
B/P
D7
H1234
D502
MOVP
D502
K4Y30
END
IB-1501667-B