Chapter 7 Second Development Platform VP3000
298
API Instruction code Operand Function
317 BREAK P D Jump out of a FOR-NEXT loop
Type
Operand
Bit devices Word devices
16-bit instruction (3 steps)
BREAK
Continuous
execution
type
BREAKP
Pulse
execution
type
32-bit instruction
- - - -
Associated flag: none
X Y M K H KnX KnY KnM T C D
D
Caution for using operand
Only escape the FOR-NEXT loop of the level
After triggering, do not perform the operation from BREAK to NEXT
of the level.
Description
D: the number of nested loop not completed (including the loop jumps out this time)
An error occurs when:
1. The number of instructions between FOR and NEXT differs.
2. FOR and NEXT are not paring (the NEXT that appears first finds the closest FOR of it in
front to pair, and the FOR and the NEXT have been paired cannot be paired for the
following instruction).
3. FEND or END is between the paired FOR-NEXT.
4. BREAK is out of the paired FOR-NEXT.
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. You can
increase D1000 to change the time for watchdog
The input variable of FOR must be positive (K1–K32767), otherwise FOR-NEXT program
operation will be ignored.
The number of FOR loop operation is mainly based on the input variable when the FOR
operation is reached. The number won’t be changed by changing the input value midway.
When BREAK is triggered, the programs between this triggered BREAK and the NEXT of this
level does not perform operation.
Example
Constants cannot be entered into FOR, the following examples are only for explanations.
Example 1
fter program A executes three times, the programs after NEXT continue to execute. Program
B executes four times whenever program A executes once. Therefore, program B executes 3
x 4 = 12 times in total.
FOR K3
FOR K4
NEXT
NEXT
AB