Examples, If, else, and endif – Galil DMC-2X00 User Manual
Page 144

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 This statement will cause the program to jump to the label #TEST under two conditions; 1. If V1 is Examples If the condition for the JP command is satisfied, the controller branches to the specified label or line Instruction Interpretation JP #LOOP,count<10 Jump to #LOOP if the variable, count, is less than 10 JS #MOVE2,@IN[1]=1 Jump to subroutine #MOVE2 if input 1 is logic level high. After JP #BLUE,@ABS[v2]>2 Jump to #BLUE if the absolute value of variable, v2, is greater JP #C,v1*v7<=v8*v2 Jump to #C if the value of v1 times v7 is less than or equal to the JP#A Jump to #A Move the A motor to absolute position 1000 counts and back to zero ten times. Wait 100 msec Instruction Interpretation #BEGIN Begin Program count=10 Initialize loop counter #LOOP Begin loop PA 1000 Position absolute 1000 BGA Begin move AMA Wait for motion complete WT 100 Wait 100 msec PA 0 Position absolute 0 BGA Begin move AMA Wait for motion complete WT 100 Wait 100 msec count = count -1 Decrement loop counter JP #LOOP, count >0 Test for 10 times thru loop EN End Program If, Else, and Endif The DMC-2x00 provides a structured approach to conditional statements using IF, ELSE and ENDIF 134 • Chapter 7 Application Programming DMC-2X00
less than V2 and V3 is less than V4. OR 2. If V5 is less than V6.
number and continues executing commands from this point. If the condition is not satisfied, the
controller continues to execute the next commands in sequence.
the subroutine MOVE2 is executed, the program sequencer
returns to the main program location where the subroutine was
called.
than 2
value of v8*v2
between moves.
commands.