44
•
Chapter 7 Application Programming
CDS-3310
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 controller is used to jog the A and B axis. This program 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 ST stops motion on both axes.
#AUTO
Label for Auto Execute
speedA=10000
Initial A speed
speedB=10000
Initial B speed
CI 2,1
Set Port 1 for Character Interrupt
JG speedA, speedB
Specify jog mode speed for A and B axis
BGXY Begin
motion
Routine to print message to terminal
MG"TO CHANGE SPEEDS"
Print message
MG"TYPE A OR B"
MG"TYPE S TO STOP"
#JOGLOOP
Loop to change Jog speeds
JG speedA, speedB
Set new jog speed
JP #JOGLOOP
EN
End of main program
#COMINT Interrupt
routine
JP #A,P1CH="A"
Check for A
JP #B,P1CH="B"
Check for B
JP #C,P1CH="S"
Check for S
ZS1;CI2;JP#JOGLOOP
Jump if not X,Y,S
#A;JS#NUM
speedA=val
New A speed
ZS1;CI2;JP#PRINT
Jump to Print
#B;JS#NUM
speedB=val
New B speed
ZS1;CI2;JP#PRINT
Jump to Print
#C;ST;AMX;CI-1
Stop motion on S
MG{^8}, "THE END"
ZS;EN,1 End-Re-enable
interrupt
#NUM
Routine for entering new jog speed
MG "ENTER",P1CH{S},"AXIS SPEED"
{N}
Prompt for value
#NUMLOOP; CI-1
Check for enter
#NMLP
Routine to check input from terminal
JP #NMLP,P1CD<2
Jump to error if string
JP #ERROR,P1CD=2
Read value
val=P1NM
EN End
subroutine
#ERROR;CI-1 Error
Routine
MG "INVALID-TRY AGAIN"
Error message
Содержание CDS-3310
Страница 26: ...18 i Chapter 2 Getting Started CDS 3310 THIS PAGE LEFT PLANK INTENTIONALLY...
Страница 32: ...24 i Chapter 3 Connecting I O CDS 3310 THIS PAGE LEFT PLANK INTENTIONALLY...
Страница 124: ...CDS 3310 Chapter 8 Hardware Software Protection i 63 THIS PAGE LEFT PLANK INTENTIONALLY...
Страница 138: ...CDS 3310 Chapter 10 Theory of Operation i 77 THIS PAGE LEFT BLANK INTENTIONALLY...