7. APPLICATION INSTRUCTIONS
7 − 21
MELSEC-A
Program Example NEG
(1) Program which calculates "D10 - D20" when XA turns on, and obtains the
absolute value when the result is negative.
(
)
X00A
0
< D10 D20
P
- D20 D10
When D10 < D20, M3 turns on.
D10 – D20 is executed.
• Coding
0 LD X00A
1 AND< D10 D20
6 OUT M3
7 LD X00A
8 -P D20 D10
13 AND M3
14 NEGP D10
17 END
P
NEG D10
When M3 is on, absolute value (2’s complement)
is obtained.
M3
X00A
7
M3