Next – Delta Electronics Extension Digital I/O Module DOP-EXIO14RAE User Manual
Page 92
![background image](/manuals/79046/92/background.png)
Appendix D Use of Application Instructions|DOP-EXIO Series
Revision March, 2008, Doc. Name: 2007PDD23000014
D-11
Mnemonic
Operands Function
FOR
S
Start of a FOR-NEXT Loop
Bit Devices
Word Devices
X Y M S K H
KnX
KnY
KnM KnS
T
C
D
E
F
S
y
Note:
1. No contact to drive the instruction is required.
16-bit instruction (3 Steps)
FOR
Continuous
execution
- -
32-bit instruction
- -
- -
y
Flags: None
Operands:
S
: The number of repeated nested loops
Mnemonic
Operands Function
NEXT
None
End of a FOR-NEXT Loop
Bit Devices
Word Devices
X Y M S K H
KnX
KnY
KnM KnS
T
C
D
E
F
y
Note:
1. No
operand.
2. No contact to drive the instruction is required.
16-bit instruction (1 Step)
NEXT
Continuous
execution
- -
32-bit instruction
- -
- -
y
Flags: None
Explanations:
1. FOR instruction indicates FOR ~ NEXT loops executing back and forth N times before escaping
for the next execution.
2. N = K1 ~ K32,767. N is regarded as K1 when N ≤ 1.
3. When FOR~NEXT loops are not executed, the user can use the CJ instruction to escape the
loops.
4. Error will occur when
a)
NEXT instruction is before FOR instruction.
b)
FOR instruction exists but NEXT instruction does not exist.
c)
There is NEXT instruction after FEND or END instruction.
d)
The number of instructions between FOR ~ NEXT differs.
5. FOR~NEXT loops can be nested for maximum five levels. Be careful that if there are too many
loops, the increased PLC scan time may cause timeout of watchdog timer and error. Users can
use WDT instruction to modify this problem.
Program Example 1:
After program A has been executed for 3 times, it will resume its execution after NEXT instruction.
Program B will be executed for 4 times whenever program A is executed once. Therefore, program B
will be executed 3 × 4 = 12 times in total.