Chapter 16 PLC Function ApplicationsMS300
API
ADD
20
D
bit device
X
Y
M
S1
S2
D
Notes on operand usage: none
16-bit commend:
1.
2.
3.
32-bit commend:
1.
2.
3.
P
Word device
K
H
KnX KnY KnM
*
*
*
*
*
*
*
*
*
*
*
*
S1: Augend. S2: Addend. D: Sum.
Adds S1 and S2 using the BIN method and stores result in D.
The highest bit of any data defines the sign: bit = 0 indicates (positive) bit = 1
indicates (negative); enables the use of algebraic addition operations (for
instance, 3 + (-9) = -6).
Flag changes connected with the addition.
When calculation results are 0, the zero flag M1020 is ON.
When calculation results are less than -32,768, the borrow flag M1021 is ON.
When calculation results are greater than 32,767, the carry flag M1022 is ON.
When calculation results are 0, the zero flag M1020 is ON.
When calculation results are less than -2,147,483,648, the borrow flag M1021 is
ON.
When calculation results are greater than 2,147,483,6477, the carry flag M1022
is ON.
16-bit BIN addition: When X0 = ON, saves the result of the content of addend
D0 plus the content of augend D10 in the content of D20.
Relationship between flag actions and negative/positive numbers:
16 bit: Zero flag
-2, -1, 0
-32,768
The highest bit
Borrow flag
of the data
= 1 (negative)
32 bit: Zero flag
-2, -1, 0 -2,147,483,648
The highest bit
Borrow flag
of the data
= 1 (negative)
BIN addition
16-bit command (7 STEP)
ADD
T
C
D
*
*
*
32-bit command (13 STEP)
*
*
*
DADD
*
*
*
Flag signal: M1020 Zero flag
Zero flag
-1, 0
1
32,767
The highest bit
of the data
= 0 (positive)
Zero flag
2,147,483,647 0 1 2
-1, 0
1
The highest bit
of the data
= 0 (positive)
714
Continuous
ADDP
execution type
execution type
Continuous
DADDP
execution type
execution type
M1021 Borrow flag
M1022 Carry flag
Refer to the following supplementary
explanation
Zero flag
0
1 2
Carry flag
Zero flag
Carry flag
Pulse
Pulse