Galil DMC-1800, DMC-1700 user manual Example - Command Error w/Multitasking

Models: DMC-1800 DMC-1700

1 253
Download 253 pages 18.39 Kb
Page 160
Image 160
Example - Command Error

Example - Command Error

#BEGIN

Begin main program

IN “ENTER SPEED”, SPEED

Prompt for speed

JG SPEED;BGX;

Begin motion

JP #BEGIN

Repeat

EN

End main program

#CMDERR

Command error utility

JP#DONE,_ED<>2

Check if error on line 2

JP#DONE,_TC<>6

Check if out of range

MG “SPEED TOO HIGH”

Send message

MG “TRY AGAIN”

Send message

ZS1

Adjust stack

JP #BEGIN

Return to main program

#DONE

End program if other error

ZS0

Zero stack

EN

End program

The above program prompts the operator to enter a jog speed. If the operator enters a number out of range (greater than 8 million), the #CMDERR routine will be executed prompting the operator to enter a new number.

In multitasking applications, there is an alternate method for handling command errors from different threads. Using the XQ command along with the special operands described below allows the controller to either skip or retry invalid commands.

OPERAND

FUNCTION

_ED1

Returns the number of the thread that generated an error

_ED2

Retry failed command (operand contains the location of the failed command)

_ED3

Skip failed command (operand contains the location of the command after the

 

failed command)

The operands are used with the XQ command in the following format: XQ _ED2 (or _ED3),_ED1,1

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

#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

152 • Chapter 7 Application Programming

DMC-1700/1800

Page 160
Image 160
Galil DMC-1800, DMC-1700 user manual Example - Command Error w/Multitasking