User guide
92
6250 Servo Controller User Guide
WHILE 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.
Command Description
> VAR5=Ø Initializes variable 5 to 0
> DEF prog1Ø Defines program prog1Ø
- 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
- A5Ø Acceleration is 50 rps
2
- AD5Ø Deceleration is 50 rps
2
-V5 Sets velocity to 5 rps
- D4ØØØ Distance is 4,000 steps
- WHILE(IN=b111Ø OR VAR5>1Ø) While the inputs 1-4 are 111Ø, 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
> RUN prog1Ø Initiate program prog1Ø
The WHILE loop in the example above will execute if the expression is true. If the expression is
false, the WHILE loop will not execute.
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 provided below.
Command Description
> DEF prog1Ø Defines program prog1Ø
- 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
- A5Ø Acceleration is 50 rps
2
- AD5Ø Deceleration is 50 rps
2
-V5 Sets velocity to 5 rps
- IF(VAR1>Ø) IF variable 1 is greater than zero
- D4ØØØ Distance is 4,000 steps
- ELSE Else
- D8ØØØ Distance is 8,000 steps
- NIF End if command
- IF(IN=b111Ø) If inputs 1-4 are 111Ø, initiate axis 1 move
- GO1 Executes the move (Go)
- NIF End IF command
- END End program definition
> RUN prog1Ø Initiate program prog1Ø
Program Interrupts
While executing a program, the 6250 can interrupt the program based on input conditions,
user status, or variables. The interrupt to the program is generated by ON conditions. These
ON conditions are enabled with the ONCOND command, and are defined with the ONIN,
ONVARA, ONVARB, and the ONUS commands. An ON condition interrupt can occur at any
point in program execution, and is serviced by the ONP program. When the ON conditions are
enabled, the 6250 will monitor them.
NOTE