Chapter 14 PLC Function
|
C200 Series
14-48
API
21
D
SUB
P
S1
S2
D
Subtraction
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)
SUB
SUBP
32-bit command (13 STEPS)
-
-
-
-
Flag signal: M1020 Zero flag
M1021 Borrow flag
M1022 Carry flag
Explanation
1.
S
1
: Minuend
S
2
: Subtrahend
D
: Remainder
2. This instruction subtracts
S
1
and
S
2
in BIN format and stores the result in
D
.
3. The highest bit is symbolic bit 0 (+) and 1 (-), which is suitable for algebraic
subtraction.
4. Flag changes in binary subtraction
In 16-bit instruction:
If the operation result
=
0, zero flag M1020 = On.
If the operation result
<
-32,768, borrow flag M1021 = On.
If the operation result
>
32,767, carry flag M1022 = On.
Example
In 16-bit BIN subtraction:
When X0 = On, the content in D0 will minus the content in D10 and the remainder will
be stored in D20.
X0
D0
D10 D20
SUB
Call 1(800)985-6929 for Sales
deltaacdrives.com
sales@deltaacdrives.com
Call 1(800)985-6929 for Sales
deltaacdrives.com
sales@deltaacdrives.com