Download Q-series basic Course(for GX Developer)

Transcript
5.4
Arithmetic Operations Instruction
Path name
Project name
Program name
5.4.1
+(P)
BIN 16 bit data addition
-(P)
BIN 16 bit data subtraction
S
D
+P
K5
D0
S1
S2
D
D0
K100
D1
X2
0
X3
4
1
+P
1
2
• The device content specified as D is added the device content specified as S ,
D
and the result is stored in
device every time the input condition is turned ON.
D
S
+
D0
(Input condition)
First ON
Second ON
Third ON
2
A: SCHOOL
QB-16
MAIN
D
(5)
D0
5
+
0 (Assumption)
5
+
5
5
+
10
D0 contents are changed
5
10
15
• The device content specified by S1 is added the device content specified by S2
D
and the result is stored in
device when the input condition is turned ON.
S2
S1
+
D0
(Input condition)
ON
15 (Assumption)
D
(100)
D1
115
+ 100
D0 contents are not changed.
CAUTION
should always be used for add-subtract instructions.
+
or is used for the instructions, add-subtract operation is
• When
performed upon every scanning. To use + or - for the instructions,
operands must have been converted to pulse beforehand.
•
+P
or
-P
X2
+P
X2
K5
D0
M0
+
PLS
M0
K5
D0
REFERENCE
• The following two instructions work on the same principle in add-subtract operation.
(Addition)
(Subtraction)
5 - 32
+P
K1
D0
INCP
-P
K1
D2
DECP D2
D0