- 1 -
Galil Motion Control, Inc.
·
3750 Atherton Road
·
Rocklin, CA 95765 USA
·
800-377-6329
·
Ph: 916-626-0101
·
Fax: 916-626-0102
·
www.galilmc.com
Application Note #2429
Checking for Repeating ASCII-string Data on Auxiliary Serial Port
Here is an example that uses the hand held terminal to monitor when a key is being
held down. In this example, the function keys F1 - F4 are being used to increase and
decrease the X and Y jog speed. As the key is held down, the jog speed is
continuously changed until the key is released. The F5 key is used to stop the motion
on both the X and Y axes. The terminal must be set up for fast repeat function, which
causes the terminal to send out characters every 50msec. When holding down a key,
the first character is not repeated until after approximately 2 seconds, so there is a
special case for when the key is first held down. When the key is held down, the
communication interrupt jumps to the Increase, Decrease, or STOP routine. In each
routine, the controller clears the communication buffer (P2CH), sets a new speed if
F1, F2, F3 or F4 was depressed, and waits for 50msec. If the communication
interrupt does not take control within the 50msec, then the key must have been
released and the next command causes the system to stop (ST command).
The terminal was configured with the Key Click Disabled to avoid the sound
generated when holding the key down.
#F4TEST
first=1
CC 9600,0,0,0
MG {P2},{^27},"V"
speedx=10000
speedy=10000
JG speedx,speedy
BGXY
CI 2
#LOOP
WT 1000
MG "PRESS F4 TO HOLD, THEN STOP"
JP#LOOP
EN
#COMINT
ZS
JP#STOP1,(P2CH=F4) & (first=1)
JP#STOP,(P2CH=F4)
JP#LOOP
EN
#STOP1
first=0