ADTECH9 Series CNC Programming Manual
1.3.2 Main program and subroutine
The processing programs include main programs and subroutines. Generally, NC executes the instructions of
main program; however, NC will turn to execute subroutine when executes a subroutine calling instruction,
and will return to the main program when executes the return instruction in subroutine.
When the processing program needs to run same track for several times, edit this track into the subroutine and
save in the program memory of the machine tool, and this subroutine can be called when this track should be
executed in the program.
When the main program calls a subroutine, this subroutine can call another subroutine, which is called double
nesting. Generally, the machine tool allows up to quadruple subroutine nesting. In calling subroutine
instruction, the subroutine can be repeated for 999 times.
Fig. 1.3.2 Main Program and Subroutine
Subroutine format:
OXXXX ; Subroutine name
………… ;
………… ; Subroutine content
………… ;
M99 ; Subroutine ends, and returns to previous program