Instruction Parameters
Supported PLC Series
| PLC-AES | PLC-FB | PLC-ES |
|---|---|---|
| ✓ | ✓ | ✓ |
Supported Data Registers
| M | X | Y | K | L | F | T | C | S | Z | R | Q | D | @D | Constant | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| n | ✓ | ✓ | ✓ | ✓ | ✓ | – | ✓ | ✓ | – | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Supported Flags
| Flag | Bit | Support |
|---|---|---|
| Error | F11.0 | ✓ |
| Zero | F11.1 | – |
| Carry | F11.2 | – |
Number of Steps
| Steps |
|---|
| 1 |
Operands
| Operand | Description |
|---|---|
| n | The only operand. Entries are WORD data registers or constants. This is the number of times to repeat the instructions inside the loop statement. The value range is 1 ~ 32,767 (215-1). |
Notice
Error Flag (F11.0) Notice
The error flag, F11.0, will be ON for one scan when the address of the data register assigned by @D exceeds the range of the data register, D. The range of the data register, D, is dependent on the CPU type.
- Compile errors occur under the following conditions:
- When the value of n exceeds the range 1 ~ 32,767 (215-1).
- When the FOR ~ NEXT instructions are not used as a pair.
- When the FOR ~ NEXT instructions exceed 16 levels.
Instruction Behavior
The FOR instruction behaves as follows:
- Instructions within the bounds of the FOR ~ NEXT instruction are executed n times.
- When the loop ends, the instruction after the NEXT instruction is executed.
- Nesting FOR ~ NEXT instructions is possible up to 16 nests.
- The FOR ~ NEXT instructions must be used in pairs.
Excessive Use
If the FOR ~ NEXT instructions are used excessively, the scan time increases. The system might be overloaded causing the CPU to shut down or initialize.
Ladder Diagram Examples
FOR

The FOR instruction defines the beginning of n loops.

- The order of execution is as follows:
- The INCP D100 instruction will increase the data register, D100, by 1 every second.
- The INCP D0 instruction will increase the data register, D0, by 1 every second.
- Step 1 and step 2 will repeat 500 times.
- After 500 times in the loop, 1 scan is finished.
- After 500 times in the loop, the DECP D200 instruction will resume execution.
