Chapter 5 Instruction Specifications
5-108
Syntax of FOR to NEXT
FOR 1 (WR0010)
NEXT 2
NEXT 5
FOR 5 (WM04F)
Program
Program
Program
Program
Program
NEXT 3
FOR 3
Program
Program
Program
FOR 3 (WR10)
NEXT 3
SB1
NEXT 2
FOR 3(WR0003)
RTS
SB2
NEXT 3
FOR 4(WR0004)
RTS
INT0
NEXT 4
NEXT 1
RT1
FOR 1(WR0001)
FOR 2(WR0002)
END
FOR3
Program
FOR 1 (WM001)
NEXT 1
Program
Program
FOR 2 (WM002)
NEXT 2
FOR 1 (WM001)
CJMP 10 (X00000)
NEXT 1
LBL10
FOR 1(WR0001)
FOR 2(WR0002)
FOR 3(WR0003)
FOR 4(WR0004)
FOR 5(WR0005)
FOR 6(WR0006)
NEXT 6
NEXT 5
NEXT 4
NEXT 3
NEXT 2
NEXT 1
X00000
JMP 1
FOR 1(WM001)
NEXT 1
LBL 1
Program C
WR0010=1
WR0010=20
FOR 1(WR0010)
Program A
NEXT1
R005
Program B
FOR 1(WM001) to NEXT 1 will execute
normally.
•
Nesting error
When WM002=0
Since FOR 1(WM001) to NEXT 1 is
prioritized, jump will not be performed
over NEXT 1 from FOR 2 to NEXT 2.
At this time, NEXT 2 generates a FOR
2 undefined error.
When WM002
≠
0
FOR 2 will not do anything. Therefore,
NEXT 2 will generate a FOR 2
undefined error.
•
When R005 is off
Program B is executed after program A is repeated 20
times.
•
When R005 is on
The repeat counter WR0010 changes to 1, and since the
NEXT 1 processing subtracts 1 from it, the content of
WR0010 becomes 0. Therefore, the repeating of
program A is terminated and program B is execute
4] Use FOR to NEXT as a nest.
8] The number of repeats may be modified within the
program.
The content of WR0010
decrements by 1 and a jump is
performed to FOR 1 (WR0010).
1] A NEXT instruction with the same code number as the
code number n of the FOR instruction is required after
the FOR instruction.
5] It is possible to escape from a FOR to NEXT loop
using a jump instruction.
•
NEXT undefined error
The NEXT instruction with
respect to the FOR instruction
does not exist within the user
program.
•
FOR undefined error
The FOR instruction does not exist
before the NEXT instruction.
•
NEXT to FOR error
The NEXT instruction exists
before the FOR instruction.
The FOR 1 to NEXT 1 loop is
escaped when X00000 turns on
before the loop has been repeated
for the set number of repeats
(content of WM001).
2] An overlap of FOR and NEXT instructions with the
same code number n is not allowed.
6] FOR to NEXT may be nested up to 5 levels. When a
subroutine is included, the FOR to NEXT within the
subroutine is counted.
•
Nesting overflow error
•
FOR duplicate-definition error
A FOR instruction with the same
code number n is programmed.
•
NEXT duplicate-definition error
A NEXT instruction with the same
code number n is programmed.
Note: FOR and NEXT duplicate-
definition errors will occur
during operation pre-processing.
3] FOR and NEXT must be within the same area.
7] Do not include a startup condition between FOR and
NEXT. If a startup condition is required, create a
circuit as shown below:
Program head
Normal scan
Subroutine
SB1
Subroutine
SB2
Interrupt scan
[Operation description]
When X00000 is off, program C is
repeatedly executed for the
number of WM 1 times.
When X00000 is on, program C is
not executed since a jump is
performed from JMP 1 to LBL 1.
NE
X
T
n
Summary of Contents for HIDIC MICRO-EH
Page 1: ...HITACHI PROGRAMMABLE CONTROLLER APPLICATION MANUAL NJI 350B X ...
Page 12: ...MEMO ...
Page 14: ...Chapter 1 Features 1 2 MEMO ...
Page 50: ...Chapter 4 Product lineup and wiring 4 18 MEMO ...
Page 196: ...Chapter 5 Instruction Specifications 5 146 ...
Page 263: ...Chapter 11 Communication Specifications 11 10 MEMO ...