Subroutines; Stack Manipulation; Dmc-14X5/6; Auto-Start Routine - Galil Motion Control DMC-14 5 Series Manual

Table of Contents

Advertisement

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.
Example:
An example of a subroutine which draws a square 500 counts per side is given below. The square is
drawn at vector position 1000,1000.
Instruction
#M
CB1
VP 1000,1000;LE;BGS
AMS
SB1
JS #Square;CB1
EN
#Square
V1=500;JS #L
V1=-V1;JS #L
EN
#L;PR V1,V1;BGX
AMX;BGY;AMY
EN

Stack Manipulation

It is possible to manipulate the subroutine stack by using the ZS command. Every time a JS
instruction, interrupt or automatic routine (such as #POSERR or #LIMSWI) is executed, the subroutine
stack is incremented by 1. Normally the stack is restored with an EN instruction. Occasionally it is
desirable not to return back to the program line where the subroutine or interrupt was called. The ZS1
command clears 1 level of the stack. This allows the program sequencer to continue to the next line.
The ZS0 command resets the stack to its initial value. For example, if a limit occurs and the #LIMSWI
routine is executed, it is often desirable to restart the program sequence instead of returning to the
location where the limit occurred. To do this, give a ZS command at the end of the #LIMSWI routine.

Auto-Start Routine

The DMC-14XX has two special labels for automatic program execution. A program which has been
saved into the controllers non-volatile memory can be automatically executed upon power up or reset
by beginning the program with the label #AUTO. On power up, if there is a checksum error, then
#AUTO does not execute, but #AUTOERR executes
volatile memory using the command, BP.
106
Chapter 7 Application Programming
i
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
Loop until both input 1 and input 2 are not active
End Input Interrupt Routine without restoring trippoints
Interpretation
Begin Main Program
Clear Output Bit 1 (pick up pen)
Define vector position; move pen
Wait for after motion trippoint
Set Output Bit 1 (put down pen)
Jump to square subroutine
End Main Program
Square subroutine
Define length of side
Switch direction
End subroutine
Define X,Y; Begin X
After motion on X, Begin Y
End subroutine
instead.
The program must be saved into non-

DMC-14x5/6

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dmc-14 6 seriesDmc-1415Dmc-1416Dmc-1425

Table of Contents