Mitsubishi Electronics 13JW55 Network Card User Manual


 
5 - 43
Project name QB-19
Program name MAIN
5.4.4 Calculation examples for multiplication and division including decimal points (when the multiplication
or division is used)
Example 1
Calculation example to determine a circumference
Digitalswitch value
× 3.14 Integral part and Decimal part
• Programming method
Handle the circular constant as 314 (3.14 × 100), and divide the result by 100
afterward.
Example 2
Calculation example to handle values after decimal point (division
example)
Digitalswitch value
/ 0.006 Quotient and Remainder
• Programming method
To handle 0.006 as an integer 6, multiply both the dividend and divisor by 1000.
Quotient
Remainder
(Decimal part)
X0
The calculation of
Example1 is
commanded.
D0
K4X30BINP
D1K314D0*P
X1
D10K100D1D/P
K8Y50D10DBCD
K2Y48D12BCD
K2Y40K0MOV
X1
D20
K4X30BINP
D21K1000D20*P
X0
D30K6D21D/P
K8Y50D30DBCD
K4Y40D32BCD
The calculation of
Example2 is
commanded.
Displays the integral part (quotient).
Displays the decimal part (remainder).
Imports the set value of the digital switch into D20.
Quotient
Remainder
Displays a quotient.
Displays a remainder.
Imports the set value of the digital switch into D0.
D0 314
D2
D1
D2 D1
100
D11 D10 D13 D12
D20
1000
D22 D21
D22 D21
6
D31
D30 D33 D32
REMARK
QCPU has instructions which can process actual number (floating decimal
point) operation data for highly accurate operations.
As long as the instructions are used, careful attentions for the place of the
decimal point as shown above are unnecessary.
(K2Y48)
(K8Y50)
(Circular constant)
(K4X30) (K4Y40) (K8Y50)
(K4X30)