Delta Electronics Programmable Logic Controller DVP-PLC User Manual
Page 227
![background image](/manuals/75807/227/background.png)
6 Application Instructions API 00-49
DVP-PLC Application Manual
6-15
API Mnemonic Operands
Function
08
FOR
Start of a FOR-NEXT Loop
Controllers
ES/EX/SS SA/SX/SC EH/SV
Bit Devices
Word Devices
Program Steps
Type
OP
X Y M S K H
KnX
KnY KnM KnS T C D E F
S
* *
*
*
*
*
*
*
*
*
*
FOR: 3 steps
PULSE 16-bit 32-bit
ES EX SS SA SX SC EH SV ES EX SS SA SX SC EH SV ES EX SS SA SX SC EH SV
Operands:
S
: The number of repeated nested loops
Explanations:
1.
No contact to drive the instruction is required.
2.
See the specifications of each model for their range of use.
API Mnemonic
Function
09
NEXT
End of a FOR-NEXT Loop
Controllers
ES/EX/SS SA/SX/SC EH/SV
OP Descriptions
Program
Steps
N/A
NEXT: 1 steps
PULSE 16-bit 32-bit
ES EX SS SA SX SC EH SV ES EX SS SA SX SC EH SV ES EX SS SA SX SC EH SV
Explanations:
1.
No operand. No contact to drive the instruction is required.
2.
FOR instruction indicates FOR ~ NEXT loops executing back and forth N times before escaping for the next
execution.
3.
N = K1 ~ K32,767. N is regarded as K1 when N ≤
1.
4.
When FOR~NEXT loops are not executed, the user can use the CJ instruction to escape the loops.
5.
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.
6.
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.