Chapter 14 PLC Function
|
C200 Series
14-47
API
20
D
ADD
P
S1
S2
D
BIN Addition
Bit Devices
Word Devices
X Y M K
H KnX KnY KnM T
C
D
S
1
*
*
*
*
*
*
*
*
S
2
*
*
*
*
*
*
*
*
D
*
*
*
*
*
Operands: None
16-bit command (7 STEPS)
ADD
ADDP
32-bit command (13 STEPS)
-
-
-
-
Flag signal: M1020 Zero flag
M1021 Borrow flag
M1022 Carry flag
Explanation
1.
S
1
: Summand
S
2
: Addend
D
: Sum
2. This
instruction
adds
S
1
and
S
2
in BIN format and store the result in D.
3. The highest bit is symbolic bit 0 (+) and 1 (-), which is suitable for algebraic
addition, e.g. 3
+
(-9)
=
-6.
4. Flag changes in binary addition
16-bit command:
A.
If the operation result
=
0, zero flag M1020 = On.
B.
If the operation result
<
-32,768, borrow flag M1021 = On.
C.
If the operation result
>
32,767, carry flag M1022 = On.
Example
16-bit command:
When X0 = On, the content in D0 will plus the content in D10 and the sum will be
stored in D20.
X0
D0
D10 D20
ADD
Remarks
Flags and the positive/negative sign of the values:
-2, -1, 0 -32,768
-1, 0 1
32,767 0 1 2
-2, -1, 0 -2,147,483,648
-1, 0 1
2,147,483,647 0 1 2
16 bit: Zero flag
Zero flag
Zero flag
Borrow flag
The highest bit
of the data
= 1 (negative)
32 bit: Zero flag
Zero flag
Zero flag
The highest bit
of the data
= 0 (positive)
Carry flag
Borrow flag
Carry flag
The highest bit
of the data
= 1 (negative)
The highest bit
of the data
= 0 (positive)
Call 1(800)985-6929 for Sales
deltaacdrives.com
sales@deltaacdrives.com
Call 1(800)985-6929 for Sales
deltaacdrives.com
sales@deltaacdrives.com