Example program · Mill

Haas M97 Local Subprogram for Repeated Features — G-Code Example

Drills the same three-hole pattern at three positions by shifting with G52 and calling a local subprogram with M97.

By cnccode · Updated

Drills the same three-hole pattern at three positions by shifting with G52 and calling a local subprogram with M97.

ItemValue
MachineCNC mill / machining centre (Fanuc-style)
UnitsMetric (G21)
Lines23

Program

G-code
O1102 (HAAS M97 PATTERN X3)
G21 G17 G40 G80 G90
T4 M06 (SPOT DRILL)
G54 G00 X0 Y0
S2500 M03
G43 H04 Z25. M08
G52 X0 Y0
M97 P100
G52 X60. Y0
M97 P100
G52 X120. Y0
M97 P100
G52 X0 Y0
M09
G91 G28 Z0
G90
M30
N100 (3-HOLE PATTERN)
G98 G81 X10. Y10. Z-2. R2. F150.
X30.
X20. Y25.
G80
M99

▶ Simulate in the G-code viewer

How it works

  • M97 calls a block number inside the same program (Haas only).
  • G52 shifts the zero for each copy; always cancel with G52 X0 Y0.
  • On Fanuc, move the pattern to a separate program and call it with M98.

Codes used in this program

Always check feeds, speeds, offsets and clearances for your own machine and tooling, and prove new programs with single block and reduced rapid.

More milling programs