6. BASIC INSTRUCTIONS
6 − 35
MELSEC-A
Program Examples INC
Program which outputs the present value of counters C0 to C20 in BCD to Y30 to 3F
each time X8 turns on.
(When the present value < 9999)
DEC
Down counter program.
The present value of C(0+Z) is output to the Y30 to 3F in BCD.
X008
P Z K4
BCD C0 Y030
0
P
INC Z
Z + 1 is executed
K
= 21 Z
9
Z is set to 0 when Z = 21 or by X7 (reset input).
X007
• Coding
0 LD X008
1 BCDP C0Z K4Y030
6 INCP Z
9 LD= K21 Z
14 OR X007
15 RST Z
18 END
RST Z
(
)
X007
0
6
P K
MOV 100 D8 When X7 turn on, 100 is transferred to D8.
X008
11
M38
P
DED D8
K
= 0 D8
When M38 is off, D8 – 1 is executed if X8 turns from
off to on.
M38
When D8 = 0, M38 turns on.
• Coding
0 LD X007
1 MOVP K100 D8
6 LD X008
7 ANI M38
8 DECP D8
11 LD= K0 D8
16 OUT M38
17 END