For Loop - GE PACSystems RX7i Cpu Programmer's Reference Manual

Hide thumbs Also See for PACSystems RX7i:
Table of Contents

Advertisement

Chapter 4. Ladder Diagram (LD) Programming
4.5.4

For Loop

When FOR_LOOP receives power flow, it saves the START, END, and INC (Increment) operands and
uses them to evaluate the number of times the rungs between the FOR_LOOP and its END_FOR
instructions are executed. Changing the START and END operands while the FOR loop is executing
does not affect its operation.
When an END_FOR receives power flow, the FOR loop is terminated and power flow jumps directly
to the statement following the END_FOR instruction.
There can be nothing after the FOR_LOOP instruction in the rung and the FOR_LOOP instruction
must be the last instruction to be executed in the rung. An EXIT_FOR statement can be placed only
between a FOR instruction and an END_FOR instruction. The END_FOR statement must be the only
instruction in its rung.
A FOR_LOOP can assign decreasing values to its index variable by setting the increment to a
negative number. For example, if the START value is 21, the END value is 1, and the increment value
is –5, the statements of the FOR loop are executed five times, and the index variable is decremented
by 5 in each pass. The values of the index variable will be 21, 16, 11, 6, and 1.
When the START and END values are set equal, the statements of the FOR loop are executed only
once.
When START cannot be incremented or decremented to reach the END, the statements within the
FOR loop are not executed. For example, if the value of START is 10, the value of END is 5, and the
INCREMENT is 1, power flow jumps directly from the FOR statement to the statement after the
END_FOR statement.
Note: If the FOR_LOOP instruction has power flow when it is first tested, the rungs between the
FOR and its corresponding END_FOR statement are executed the number of times initially
specified by START, END, and INCREMENT. This repeated execution occurs on a single sweep
of the PLC and may cause the watchdog timer to expire if the loop is long.
Nesting of FOR loops is allowed, but it is restricted to five FOR/END_FOR pairs. Each FOR instruction
must have a matching END_FOR statement following it.
Nesting with JUMPs and MCRs is allowed, provided that they are properly nested. MCRs and
ENDMCRs must be completely within or completely outside the scope of a FOR_LOOP/END_FOR
pair. JUMPs and LABEL instructions must also be completely within or completely outside the scope
of a FOR_LOOP/END_FOR pair. Jumping into or out of the scope of a FOR/END_FOR is not allowed.
112
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
A FOR loop repeats rung logic a specified number of times
while varying the value of the INDEX variable in the loop.
A FOR loop begins with a FOR_LOOP instruction and ends
with an END_FOR instruction.
The logic to be repeated must be placed between the FOR
and END_FOR instructions.
The optional EXIT_FOR instruction enables you to exit the loop
if a condition is met before the FOR loop ends normally.
GFK-2950C

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pacsystems rx3iPacsystems rsti-ep

Table of Contents