Galil Motion Control DMC-21 5 Series User Manual page 92

Table of Contents

Advertisement

For example, using variables named v1, v2, v3 and v4:
JP
#test,((v1<v2)&(v3<v4))
In this example, this statement will cause the program to jump to the label #test if v1 is less than v2 and v3 is less
than v4. To illustrate this further, consider this same example with an additional condition:
JP
#test,(((v1<v2)&(v3<v4)) | (v5<v6))
This statement will cause the program to jump to the label #TEST under two conditions;
1. If v1 is less than v2 and v3 is less than v4
2. If v5 is less than v6.
Using the JP Command:
If the condition for the
continues executing commands from this point. If the condition is not satisfied, the controller continues to execute
the next commands in sequence.
Example Using JP command:
Move the A motor to absolute position 1000 counts and back to zero ten times. Wait 100 msec between moves.
#begin;
count=10;
SH
A
;
#loop;
PA
1000;
BG
A;
AM
A;
WT
100;
PA
0;
BG
A;
AM
A;
WT
100;
count=count-1;
JP
#loop,(count>0);
MO
A
;
EN;
Using If, Else, and Endif Commands
The DMC-21x5 provides a structured approach to conditional statements using IF,
Using the IF and ENDIF Commands
An IF conditional statement is formed by the combination of an
have one or more conditional statements. If the conditional statement(s) evaluate true, the command interpreter
will continue executing commands which follow the
controller will ignore commands until the associated
the program (see discussion of
NOTE: An
command must always be executed for every
ENDIF
recommended that the user not include jump commands inside
direction of command execution. In this case, the command interpreter may not execute an
Chapter 7 Application Programming ▫ 87
command is satisfied, the controller branches to the specified label or line number and
JP
'program label
'initialize loop counter
'enable A axis
'label for loop
'position absolute move to 1000
'begin move
'wait for motion to finish
'wait 100 msec
'position absolute move to 0
'begin move
'wait for motion complete
'wait 100 msec
'decrement loop counter
'jump to #loop while count is greater than 0
'disable A axis
'end program
command below).
ELSE
IF
and
ENDIF
IF
command. If the conditional statement evaluates false, the
ENDIF
command is executed or an
command that has been executed. It is
IF
conditional statements since this causes re-
IF
and
commands.
ELSE
ENDIF
command. The
IF
command can
ELSE
command occurs in
command.
ENDIF
DMC-21x5 User Manual 1.0a1

Advertisement

Table of Contents
loading

Table of Contents