M800V/M80V Series PLC Programming Manual (1/2)
8 Function Instructions
8.5 Program Branch Instructions
FOR, NEXT: FOR to NEXT instruction loop
Setting
Bit devices
data
X
Y
M
L
F
n
○
○
○
○
○
[Instruction symbol] [Execution condition]
FOR
NEXT
Setting data
Setting data
n
Number of repetitions of the FOR to NEXT loop (from 1 to 32767)
Functions
When the processing in the FOR to NEXT loop is executed n-times without conditions, the step following the NEXT instruc-
tion will be executed.
The value of "n" can be designated at between 1 and 32767. If it is designated at a value of from -32768 to 0, it will be exe-
cuted as though n=1.
If you do not desire to execute the processing called for within the FOR to NEXT loop, use the CJ instruction to jump.
Setting the repetition times to "0" would not allow you to skip the process between FOR and NEXT instructions.
To force an end to the repetitious execution of the FOR to NEXT loop during the execution of the loop, insert a BREAK
instruction.
Premature termination with CJ instruction, etc. will result in an arithmetic error.
FOR instructions can be nested up to 16 deep.
X0
X1
FOR
X2
Usable devices
B SB
T SM V
T
C
○
○
○
○
○
Meaning
FOR
K5
FOR
K3
FOR instructions can be
K100
nested up to 16 deep.
NEXT
NEXT
NEXT
Con-
Word devices
stant
D
R/ZR W SW SD
Z
K
○
○
○
○
○
○
○
Repeated program
259
Digit
Pointer
designa-
Index
tion
H
P
○
○
○
FOR
n
NEXT
Data type
BIN 16 bits
IB-1501667-B