Combining Math Instructions - Mitsubishi Electric FX2N Beginners Manual

Hide thumbs Also See for FX2N:
Table of Contents

Advertisement

Math Instructions
Division with 32-bit values:
DDIV D0 D2 D4
Adding a "P" suffix to the DIV instructions executes the instructions in pulse-triggered mode
(DIV -> DIVP, DDIVPL -> DMULP). In the following example the counter value of C12 is only
divided by 4 in the program cycle in which input X30 is switched on:
Ladder Diagram
X30
0
5.4.5

Combining math instructions

In real life one calculation is seldom all you want to perform. The FX controllers allow you to
combine math instructions to solve more complex calculations. Depending on the nature of the
calculation you may have to use additional devices to store intermediate results.
The following example shows how you could calculate the sum of the values in data registers
D101, D102 and D103 and then multiply the result by the factor 4:
Ladder Diagram
M101
0
First the contents of D101 and D102 are added and the result is stored in D200.
If (and only if) the sum of D101 and D102 does not exceed the permitted range it is then
added to the value in D103.
If the sum of D101 through D103 does not exceed the permitted range it is multiplied by the
factor 4 and the result is written to D104 and D105.
5 – 26
D1
D0
65238
DIVP C12 K4 D12
ADD D101 D102 D200
M8022
ADD D200 D103 D200
M8021 M8022
MUL D200 K4 D104
More Advanced Programming
D3
D2
D5
Ö
27643
2
D7
9952
Instruction List
0 LD
1 DIVP
Instruction List
0
LD
1
ADD D101
8
MPS
9
ANI
10 ADD D200
17 MPP
18 ANI
19 ANI
20 MUL D200
D4
Quotient
D6
Remainder
X30
C12
K4
M101
D102
D200
M8022
D103
D200
M8021
M8022
K4
D104
MITSUBISHI ELECTRIC
D12

Advertisement

Table of Contents
loading

Table of Contents