User guide

28
6000 Series Programmer's Guide
All commands between WHILE and NWHILE are repeated as long as the WHILE condition is
true. The following example illustrates how a typical WHILE/NWHILE conditional loop
works. In this example, the WHILE loop will execute if the expression is true. If the
expression is false, the WHILE loop will not execute.
VAR5=0 ; Initializes variable 5 to 0
DEL prog10 ; Delete a program before defining it
DEF prog10 ; Defines program prog10
INFNC1-A ; Input 1 is not assigned a function, used with IN
INFNC2-A ; Input 2 is not assigned a function, used with IN
INFNC3-A ; Input 3 is not assigned a function, used with IN
INFNC4-A ; Input 4 is not assigned a function, used with IN
OUTFNC1-A ; Output 1 is programmable
A50 ; Acceleration is 50
AD50 ; Deceleration is 50
V5 ; Sets velocity to 5
D25000 ; Distance is 25,000
WHILE(IN=b1110 OR VAR5>10) ; While the inputs 1-4 are 1110, respectively or
; VAR5 is greater than 10, the loop will continue.
GO1 ; Executes the move (Go)
VAR5=VAR5+1 ; Variable 5 counts up from 0
NWHILE ; End WHILE command
OUT1 ; Turn on output 1 when finished with WHILE loop
END ; End program definition
; *****************************************************
; * To run prog10, execute the "RUN prog10" command *
; *****************************************************
Conditional
Branching
You can use the IF command for conditional branching. All commands between IF and
ELSE are executed if the expression contained within the parentheses of the IF command is
true. If the expression is false, the commands between ELSE and NIF are executed. If the
ELSE is not needed, it may be omitted. The commands between IF and NIF are executed if
the expression is true. Examples of these commands are as follows.
DEL prog10 ; Delete a program before defining it
DEF prog10 ; Defines program prog10
INFNC1-A ; Input 1 is not assigned a function, used with IN
INFNC2-A ; Input 2 is not assigned a function, used with IN
INFNC3-A ; Input 3 is not assigned a function, used with IN
INFNC4-A ; Input 4 is not assigned a function, used with IN
A50 ; Acceleration is 50
AD50 ; Deceleration is 50
V5 ; Sets velocity to 5
IF(VAR1>0) ; IF variable 1 is greater than zero
D25000 ; Distance is 25,000
ELSE ; Else
D50000 ; Distance is 50,000
NIF ; End if command
IF(IN=b1110) ; If inputs 1-4 are 1110, initiate axis 1 move
GO1 ; Executes the move (Go)
NIF ; End IF command
END ; End program definition
; *****************************************************
; * To run prog10, execute the "RUN prog10" command *
; *****************************************************