Subroutines - Galil Motion Control DMC-18 2 Series User Manual

Table of Contents

Advertisement

Command Format - IF, ELSE and ENDIF
FORMAT:
IF conditional statement(s)
ELSE
ENDIF
Example using IF, ELSE and ENDIF:
#TEST
II,,3
MG "WAITING FOR INPUT 1, INPUT 2"
#LOOP
JP #LOOP
EN
#ININT
IF (@IN[1]=0)
IF (@IN[2]=0)
MG "INPUT 1 AND INPUT 2 ARE ACTIVE"
ELSE
MG "ONLY INPUT 1 IS ACTIVE
ENDIF
ELSE
MG"ONLY INPUT 2 IS ACTIVE"
ENDIF
#WAIT
JP#WAIT,(@IN[1]=0) | (@IN[2]=0)
RI0

Subroutines

A subroutine is a group of instructions beginning with a label and ending with an end command (EN).
Subroutines are called from the main program with the jump subroutine instruction JS, followed by a
label or line number, and conditional statement. Up to 8 subroutines can be nested. After the
subroutine is executed, the program sequencer returns to the program location where the subroutine
was called unless the subroutine stack is manipulated as described in the following section.
DMC-18x2
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
DESCRIPTION
Execute commands proceeding IF command (up to ELSE command) if
conditional statement(s) is true, otherwise continue executing at ENDIF
command or optional ELSE command.
Optional command. Allows for commands to be executed when argument
of IF command evaluates not true. Can only be used with IF command.
Command to end IF conditional statement. Program must have an ENDIF
command for every IF command.
Begin Main Program "TEST"
Enable input interrupts on input 1 and input 2
Output message
Label to be used for endless loop
Endless loop
End of main program
Input Interrupt Subroutine
IF conditional statement based on input 1
nd
2
IF conditional statement executed if 1
Message to be executed if 2
ELSE command for 2
Message to be executed if 2
nd
End of 2
conditional statement
ELSE command for 1
Message to be executed if 1
st
End of 1
conditional statement
Label to be used for a loop
Loop until both input 1 and input 2 are not active
End Input Interrupt Routine without restoring trippoints
Chapter 7 Application Programming • 123
st
IF conditional true
nd
IF conditional is true
nd
IF conditional statement
nd
IF conditional is false
st
IF conditional statement
st
IF conditional statement

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

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

Table of Contents