Example, Using communication interrupt – Galil DMC-2X00 User Manual

Page 162

Advertising
background image

These keywords may be used in an applications program to decode data and they may also be used in
conditional statements with logical operators.

Example

Instruction Interpretation

JP #LOOP,P2CD< >3

Checks to see if status code is 3 (number received)

JP #P,P1CH="V"

Checks if last character received was a V

PR P2NM

Assigns received number to position

JS #XAXIS,P1ST="X"

Checks to see if received string is X

Using Communication Interrupt

The DMC-2x00 provides a special interrupt for communication allowing the application program to be
interrupted by input from the user. The interrupt is enabled using the CI command. The syntax for the
command is CI n:

n = 0

Don't interrupt Port 2

n = 1

Interrupt on <enter> Port 2

n = 2

Interrupt on any character Port 2

n = -1

Clear any characters in buffer

The #COMINT label is used for the communication interrupt. For example, the DMC-2x00 can be
configured to interrupt on any character received on Port 2. The #COMINT subroutine is entered
when a character is received and the subroutine can decode the characters. At the end of the routine
the EN command is used. EN,1 will re-enable the interrupt and return to the line of the program where
the interrupt was called, EN will just return to the line of the program where it was called without re-
enabling the interrupt. As with any automatic subroutine, a program must be running in thread 0 at all
times for it to be enabled.

Example

A DMC-2x00 is used to jog the A and B axis. This program automatically begins upon power-up and
allows the user to input values from the main serial port terminal. The speed of either axis may be
changed during motion by specifying the axis letter followed by the new speed value. An S stops
motion on both axes.

Instruction Interpretation

#AUTO

Label for Auto Execute

speedA=10000

Initial A speed

speedB=10000

Initial B speed

CI 2

Set Port 2 for Character Interrupt

JG speedA, speedB

Specify jog mode speed for A and B axis

BGXY Begin

motion

#PRINT

Routine to print message to terminal

MG{P2}"TO CHANGE SPEEDS"

Print message

MG{P2}"TYPE A OR B"

MG{P2}"TYPE S TO STOP"

#JOGLOOP

Loop to change Jog speeds

JG speedA, speedB

Set new jog speed

JP #JOGLOOP

EN

End of main program

152

Chapter 7 Application Programming

DMC-2X00

Advertising