Programming, 2 do/until structure, 3 while structure – Lenze E94P PositionServo with MVOB User Manual

Page 47: 4 wait statement

Advertising
background image

PM94H201B_13xxxxxx_EN

L

45

Programming

2.9.2 DO/UNTIL Structure

The flowchart and code segment in Figure 14 illustrate the use of the DO/UNTIL statement. This statement is used
to execute a block of code one time and then continue executing that block until a condition becomes true (satisfied).
The difference between DO/UNTIL and WHILE statements is that the DO/UNTIL instruction tests the condition after
the block is executed so the conditional statements are always executed at least one time. The syntax for DO/UNTIL
statement is:
DO

…statements

UNTIL <condition>

… statements

DO

MOVED 3

WAIT TIME 2000

UNTIL IN_A3

…statements

Start

Move DIstance 3

units. Delay 2

seconds

Is input A3 ON?

End

YES

NO

Figure 14: DO/UNTIL Code and Flowchart

2.9.3 WHILE Structure

The flowchart and code segment in Figure 15 illustrate the syntax for the WHILE instruction. This statement is used if
you want a block of code to execute while a condition is true.
WHILE <condition>

…statements

ENDWHILE

…statements

WHILE IN_A3

MOVED 3

WAIT TIME 2000

ENDWHILE

…statements

Start

Is input A3 ON?

End

YES

NO

Move DIstance 3

units. Delay 2

seconds

Figure 15: WHILE Code and Flowchart

2.9.4 WAIT Statement

The WAIT statement is used to suspend program execution until or while a condition is true, for a specified time period
(delay) or until motion has been completed. The simplified syntax for this statement is:
WAIT UNTIL <condition>

WAIT WHILE <condition>

WAIT TIME <time>

WAIT MOTION COMPLETE

Advertising