Parker
Hannifin
You can exit a
FOR/NEXT
loop before the counter is complete using
a
BREAK
statement. When the condition is met, the statement
immediately following the
FOR/NEXT
loop executes.
Example
The following demonstrates a
FOR/NEXT
loop with a
BREAK
statement.
FOR LV0 = 0 TO 499 STEP 1
PRINT LA0(LV0), SA0(LV0)
DWL 0.01
IF (BIT 24)
BREAK
ENDIF
NEXT
WHILE/WEND
The
WHILE/WEND
loop executes as long as its condition remains true.
You can use the
WHLE/WEND
anywhere in a program.
The
WHILE
sets the condition, and is followed by statements you
want executed when the condition is true. When the condition is
false, the statement immediately following
WEND
executes. The
condition is evaluated only at the beginning of the loop.
When using a
WHILE/WEND
statement, observe the following:
•
Do not nest
GOTO
statements in an
WHILE/WEND
statement.
•
At the start of each loop through the
WHILE
condition, the
validity of the condition is tested.
Example
The following demonstrates a
WHILE/WEND
loop. While the encoder
position for axis 2 is less than 1500 units, the
WHILE
statement
evaluates as true. As the loop runs, the array acts as a counter,
incrementing with each loop; axis X move an incremental 25 units;
the program pauses for 1.5 seconds, then prints the current value of
the array; and if the input (bit 24) is set the loop breaks. When the
encoder count exceeds 1500, the condition is false and execution
moves past the
WEND
statement.
WHILE (P6176 < 1500)
LA0(1) = LA0(1) + 1
X/25
DWL 1.5
PRINT LA0(1)
IF (BIT 24)
BREAK
ENDIF
WEND
Programming Basics 23
Содержание ACR Series
Страница 1: ......
Страница 65: ...Parker Hannifin Making Motion 65...
Страница 89: ...Parker Hannifin Servo Loop Fundamentals 89 Figure 17 Following Error...