Repeat loop, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 767

Advertising
background image

L-force | PLC Designer

General Editors

DMS 4.1 EN 03/2011 TD29

765

REPEAT loop
The REPEAT loop is different from the WHILE loop because the break-off condition is
checked only after the loop has been executed. This means that the loop will run
through at least once, regardless of the wording of the break-off condition.
Syntax:
REPEAT
<Instructions>
UNTIL <Boolean expression>
END_REPEAT;
The <Instructions> are carried out until the <Boolean expression> returns TRUE.
If <Boolean expression> is produced already at the first TRUE evaluation, then
<Instructions> are executed only once. If <Boolean_expression> never assumes the
value TRUE, then the <Instructions> are repeated endlessly which causes a relative
time delay.

Note: The programmer must make sure that no endless loop is caused. He does this
by changing the condition in the instruction part of the loop, for example by
counting up or down one counter.

Example:

REPEAT
Var1 := Var1*2;
Counter := Counter-1;
UNTIL
Counter=0
END_REPEAT;

Extension to the IEC 61131-3 standard (ExST):
The CONTINUE instruction can be used within a REPEAT loop.

Advertising