Arithmetic status flags, Fault conditions – Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual
Page 35
Publication 1756-PM007D-EN-P - November 2012
35
Program Structured Text Chapter 1
These diagrams show how a REPEAT...UNTIL loop executes and how an
EXIT statement leaves the loop early.
Arithmetic Status Flags:
Not affected
Fault Conditions:
Example 1:
While the bool_expression is false, the controller
executes only the statements within the
REPEAT…UNTIL loop.
To stop the loop before the conditions are false, use
an EXIT statement.
Statement 1
Statement 2
Statement 3
BOOL expression
False
True
Rest of the routine
BOOL expression
False
True
Rest of the routine
Statement 1
Statement 2
Statement 3
Yes
No
A major fault will occur if
Fault type
Fault code
The construct loops too long
6
1
If you want this
Enter this structured text
The REPEAT...UNTIL loop executes the statements in the
construct and then determines if the conditions are true before
executing the statements again.
This differs from the WHILE...DO loop because the WHILE...DO
The WHILE...DO loop evaluates its conditions first. If the
conditions are true, the controller then executes the
statements within the loop. The statements in a
REPEAT...UNTIL loop are always executed at least once. The
statements in a WHILE...DO loop might never be executed.
pos := -1;
REPEAT
pos := pos + 2;
UNTIL ((pos = 101) OR (structarray[pos].value = targetvalue))
end_repeat;