Next/Break/Continue Instruction

Topic: CL178

Definition

The Next/Break/Continue instruction provides control of a For - Next loop. The Next instruction ends a For - Next loop and must be the only instruction on its rung. No enabling contacts are allowed on the same rung with the Next instruction. The Break instruction exits the For - Next loop immediately and jumps to the first rung of ladder after the For - Next loop. The Break instruction requires an enabling contact on the same rung. The Continue instruction skips the remaining ladder rungs in the For - Next loop for that iteration of the For - Next loop only and proceeds to the next iteration. The Continue instruction requires an enabling contact on the same rung.

Note: Break and Continue are not supported on C0-0x Series CPUs.

Setup

When the user selects the Next/Break/Continue instruction from the Instruction List, the setup dialog appears to choose the option matching the below image.

When OK is pressed, the selected instruction is inserted into the Ladder Editor at the specified position, displaying the symbol below that corresponds to the chosen option.

Example Programs

Example Program: For - Next Loop

In the following example, when X001 is ON, the Ladder Program is executed 100 times.

Example Program: Nested For - Next Loop

In the following example, when X001 is ON the outer For - Next loop executes 10 times.

Each time the outer loop iterates, when X002 is ON the middle For - Next loop executes 20 times.

Each time the middle loop iterates, when X003 is ON the inner For - Next loop executes 30 times, running the Ladder Program a maximum of 6,000 times (10 × 20 × 30).

Example Program: For - Next Loop with Break

In the following example, when X001 is ON the Ladder Program executes up to 10 times.

If C1 turns ON during any iteration, the Break instruction exits the For - Next loop immediately and execution continues with the first rung after the Next instruction, regardless of how many iterations remain.

Example Program: For - Next Loop with Continue

In the following example, when X001 is ON the Ladder Program executes up to 10 times.

If C1 turns ON during any iteration, the Continue instruction skips the remaining rungs in the current iteration and proceeds immediately to the next iteration of the For - Next loop.

The Next/Break/Continue instruction is achieved by one of several simple methods:

  1. Drag and Drop the instruction from the Instruction List then choose which instruction option
  2. Placing the Box Cursor in the rung position where you want the Next/Break/Continue instruction to appear and:
    1. Type the letter the corresponding letter(s), as shown below:
      1. "n"or "N" for Next
      2. "b" or "B" for Break
      3. "c" followed "n" or "C" followed by "N" for Continue
  3. SelectInstruction > Program Control > Next/Break/Continue

Related Topics:

For Instruction