Example - command error w/multitasking, Example - communication interrupt – Galil DMC-2X00 User Manual

Page 150

Advertising
background image

Where the “,1” at the end of the command line indicates a restart; therefore, the existing program stack
will not be removed when the above format executes.

The following example shows an error correction routine which uses the operands.

Example - Command Error w/Multitasking

Instruction Interpretation

#A

Begin thread 0 (continuous loop)

JP#A
EN

End

of

thread

0

#B

Begin

thread

1

n=-1

Create

new

variable

KP n

Set KP to value of N, an invalid value

TY

Issue

invalid

command

EN

End

of

thread

1

#CMDERR

Begin command error subroutine

IF (_TC=6)

If error is out of range (KP -1)

N=1

Set N to a valid number

XQ _ED2,_ED1,1

Retry KP N command

ENDIF
IF (_TC=1)

If error is invalid command (TY)

XQ _ED3,_ED1,1

Skip invalid command

ENDIF
EN

End of command error routine

Example - Communication Interrupt

A DMC-2x10 is used to move the A axis back and forth from 0 to 10000. This motion can be paused,
resumed and stopped via input from an auxiliary port terminal.

Instruction Interpretation

#BEGIN

Label for beginning of program

CC 9600,0,0,0

Setup communication configuration for auxiliary serial
port

CI 2

Setup communication interrupt for auxiliary serial port

MG {P2}"Type 0 to stop motion"

Message out of auxiliary port

MG {P2}"Type 1 to pause motion"

Message out of auxiliary port

MG {P2}"Type 2 to resume motion"

Message out of auxiliary port

rate=2000

Variable to remember speed

SPA=rate

Set speed of A axis motion

#LOOP

Label for Loop

PAA=10000

Move to absolute position 10000

BGA

Begin Motion on A axis

AMA

Wait for motion to be complete

PAA=0

Move to absolute position 0

BGA

Begin Motion on A axis

AMA

Wait for motion to be complete

JP #LOOP

Continually loop to make back and forth motion

140

Chapter 7 Application Programming

DMC-2X00

Advertising