M-Series Operator’s Manual 4/9/15
Suppose that a drilling pattern of 4 holes is needed in 3 different locations.
This subprogram would handle the drilling and incremental moves between the holes:
O9101 ;Program O9101.cnc
G91 F10 ;Incremental positioning
G81 X0 Y0 R -.4 Z-.6 ;Drill lower left hole
Y1.5 R -.4 Z-.6 ;Drill upper left hole
X1 R -.4 Z-.6 ;Drill upper right hole
Y-1.5 R-.4 Z-.6 ;Drill lower right hole
G80 ;Cancel canned cycles
M99 ;End of subprogram
The main program would call this subprogram three times:
:Main program
G90 G0 X2 Y5 Z0.5 ;Move to first hole pattern
M98 P9101 L1 ;Call subprogram O9101.cnc
G90 G0 X4Y1 Z0.5 ;Move to second hole pattern
M98 P9101 L1 ;Call subprogram
G90 G0 X6 Y5 Z0.5 ;Move to third hole pattern
M98 P9101 L1 ;Call subprogram
:End program
Another example is "looping" or consecutively repeating a section of code. Here, the subprogram will be part of the
main program.
:Main program
G90 G0 X0 Y0 Z0.1
G1 Z0 F30
O9100 ;Beginning of subprogram
G91 G1 Z-0.1 F5
G90 X2 F30
Y2
X0 Y0
M99 ;End of subprogram 9100
M98 P9100 L3 ;Repeat O9100 3 times
M25 G49 ;End main program