Using If, Else, And Endif Commands - Galil Motion Control DMC-1600 Series User Manual

Table of Contents

Advertisement

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. OR 2. If V5 is less than V6.
Using the JP Command:
If the condition for the JP command is satisfied, the controller branches to the specified label or
line number and continues executing commands from this point. If the condition is not satisfied,
the controller continues to execute the next commands in sequence.
Conditional
JP #Loop,COUNT<10
JS #MOVE2,@IN[1]=1
JP #BLUE,@ABS[V2]>2
JP #C,V1*V7<=V8*V2
JP#A
Example Using JP command:
Move the X motor to absolute position 1000 counts and back to zero ten times. Wait 100 msec
between moves.
#BEGIN
COUNT=10
#LOOP
PA 1000
BGX
AMX
WT 100
PA 0
BGX
AMX
WT 100
COUNT=COUNT-1
JP #LOOP,COUNT>0
EN

Using If, Else, and Endif Commands

The DMC-1600 provides a structured approach to conditional statements using IF, ELSE and
ENDIF commands.
DMC-1600
Meaning
Jump to #Loop if the variable, COUNT, is less than 10
Jump to subroutine #MOVE2 if input 1 is logic level high. After the subroutine
MOVE2 is executed, the program sequencer returns to the main program location
where the subroutine was called.
Jump to #BLUE if the absolute value of variable, V2, is greater than 2
Jump to #C if the value of V1 times V7 is less than or equal to the value of V8*V2
Jump to #A
Begin Program
Initialize loop counter
Begin loop
Position absolute 1000
Begin move
Wait for motion complete
Wait 100 msec
Position absolute 0
Begin move
Wait for motion complete
Wait 100 msec
Decrement loop counter
Test for 10 times thru loop
End Program
Chapter 7 Application Programming • 129

Advertisement

Table of Contents
loading

Table of Contents