Galil DMC-2X00 user manual

Models: DMC-2X00

1 267
Download 267 pages 56.53 Kb
Page 146
Image 146

ELSE

ELSE command for 2nd IF statement

MG "ONLY INPUT 1 IS ACTIVE

Message executed if 2nd IF is false

ENDIF

End of 2nd conditional statement

ELSE

ELSE command for 1st IF statement

MG"ONLY INPUT 2 IS ACTIVE"

Message executed if 1st IF statement

ENDIF

End of 1st conditional statement

#WAIT

Label to be used for a loop

JP#WAIT,(@IN[1]=0) (@IN[2]=0)

Loop until Input 1& 2 are not active

RI0

End Input Interrupt Routine without restoring

 

trippoints

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.

An example of a subroutine to draw a square of 500 counts per side is given below. The square is drawn at vector position 1000, 1000.

Instruction

Interpretation

#M

Begin Main Program

CB1

Clear Output Bit 1 (pick up pen)

VP 1000,1000;LE;BGS

Define vector position; move pen

AMS

Wait for after motion trip point

SB1

Set Output Bit 1 (put down pen)

JS #SQUARE;CB1

Jump to SQUARE subroutine

EN

End Main Program

# SQUARE

SQUARE subroutine

v1=500;JS #L

Define length of side

v1=-v1;JS #L

Switch direction

EN

End subroutine

#L;PR v1,v1;BGA

Define A,B; Begin A

AMA;BGB;AMB

After motion on A, Begin B

EN

End subroutine

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-2x00 has a special label for automatic program execution. A program which has been saved into the controller’s non-volatile memory can be automatically executed upon power up or reset by

DMC-2X00

Chapter 7 Application Programming y 91

Page 146
Image 146
Galil DMC-2X00 user manual