Structured Text Programming
Rockwell Automation Publication 1756-RM006K-EN-P - November 2018 525
Enters the RUN mode.
Leaves the step of an SFC if configuring the SFC for Automatic reset. This applies
only embedding the assignment in the action of the step or using the action to call
a structured text routine via a JSR instruction.
Use the FOR_DO loop to perform an action a number of times before doing
anything else.
When enabled, the FOR instruction repeatedly executes the Routine until the
Index value exceeds the Terminal value. The step value can be positive or negative.
If it is negative, the loop ends when the index is less than the terminal value.. If it is
positive, the loop ends when the index is greater than the terminal value.
Each time the FOR instruction executes the routine, it adds the Step size to the
Index.
Do not loop too many times in a single scan. An excessive number of repetitions
causes the controller watchdog to timeout and causes a major fault.
Operands
FOR count:= initial_value TO
final_value BY increment DO
<statement>;
END_FOR;
Operand Type Format Description
count SINT INT DINT Tag Tag to store count position as the FOR_DO executes
initial_ value SINT INT DINT Tag expression
Immediate
Must evaluate to a number
Specifies initial value for count
final_ value SINT INT DINT Tag expression
Immediate
Specifies final value for count, which determines
when to exit the loop
increment SINT INT DINT Tag expression
Immediate
(Optional) amount to increment count each time
through the loop
If you don’t specify an increment, the count
increments by 1.