Hint, Precautions, 2 instructions – Omron SYSMAC CP CP1E-N@@D@-@ User Manual

Page 93

Advertising
background image

2-57

2 Instructions

CP1E CPU Unit Instructions Reference Manual(W483)

Sequ

ence C

ontr

ol I

n

stru

ctio

ns

2

FOR/NEXT

Hint

There are two ways to repeat a program section until a given execution condition is input.

FOR-NEXT Loop with BREAK

Start a FOR-NEXT loop with a maximum of N repetitions. Program BREAK(514) within the loop with
the desired execution condition. The loop will end before N repetitions if the execution condition is
input.

JME(005)-JMP(004) Loop

Program a loop with JME(005) before JMP(004). The instructions between JME(005) and JMP(004)
will be executed repeatedly as long as the execution condition for JMP(004) is OFF. (A Cycle Time
Too Long error will occur if the execution condition is not turned ON or END(001) is not executed
within the maximum cycle time.)

Precautions

Program FOR(512) and NEXT(513) in the same task. Execution will not be repeated if these instruc-

tions are not in the same task.

If a loop repeats in one cycle and a differentiated instruction is used in the FOR-NEXT loop, that

instruction will be executed only once.It is not executed the number of loops.

UP(521),DOWN(522)

DIFU(013),DIFD(014)

Differentiated up instruction(Differentiation variation:@)

Differentiated down instruction(Differentiation variation:%)

FOR-NEXT loops can be nested up to 15 levels.

In the example above, program sections A, B, and C are executed as follows:
A

→ B → B → C, A → B → B → C, and A → B → B → C

Use BREAK(514) to escape from a FOR-NEXT loop. Several BREAK(514) instructions (the number

of levels nested) are required to escape from nested loops.

The remaining instructions in the loop after BREAK(514) are processed as NOP(000) instructions.

A

FOR

&3

B

FOR

&2

C

NEXT

NEXT

Advertising
This manual is related to the following products: