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

Table of Contents

Advertisement

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-18x2 provides a structured approach to conditional statements using IF, ELSE and ENDIF
commands.
Using the IF and ENDIF Commands
An IF conditional statement is formed by the combination of an IF and ENDIF command. The IF
command has as it's arguments one or more conditional statements. If the conditional statement(s)
evaluates true, the command interpreter will continue executing commands which follow the IF
command. If the conditional statement evaluates false, the controller will ignore commands until the
associated ENDIF command is executed OR an ELSE command occurs in the program (see discussion
of ELSE command below).
Note: An ENDIF command must always be executed for every IF command that has been executed. It
is recommended that the user not include jump commands inside IF conditional statements since this
causes re-direction of command execution. In this case, the command interpreter may not execute an
ENDIF command.
Using the ELSE Command
The ELSE command is an optional part of an IF conditional statement and allows for the execution of
command only when the argument of the IF command evaluates False. The ELSE command must
occur after an IF command and has no arguments. If the argument of the IF command evaluates false,
the controller will skip commands until the ELSE command. If the argument for the IF command
evaluates true, the controller will execute the commands between the IF and ELSE command.
Nesting IF Conditional Statements
The DMC-18x2 allows for IF conditional statements to be included within other IF conditional
statements. This technique is known as 'nesting' and the DMC-18x2 allows up to 255 IF conditional
statements to be nested. This is a very powerful technique allowing the user to specify a variety of
different cases for branching.
122 ● Chapter 7 Application Programming
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
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
DMC-18x2

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dmc-1812Dmc-1822Dmc-1832Dmc-1842

Table of Contents