Example program · Mill
Machining Multiple Parts with G54–G57 — G-Code Example
Runs the same operation on four vises by switching work offsets and calling one subprogram.
Runs the same operation on four vises by switching work offsets and calling one subprogram.
| Item | Value |
|---|---|
| Machine | CNC mill / machining centre (Fanuc-style) |
| Units | Metric (G21) |
| Lines | 25 |
Program
O1009 (4 PARTS G54-G57)
G21 G17 G40 G49 G80 G90
T4 M06 (SPOT DRILL)
S2500 M03
G54 G00 X0 Y0
G43 H04 Z25. M08
M98 P1109
G55 G00 X0 Y0
M98 P1109
G56 G00 X0 Y0
M98 P1109
G57 G00 X0 Y0
M98 P1109
M09
G91 G28 Z0
G90
M30
O1109 (HOLE PATTERN)
G98 G81 X10. Y10. Z-2. R2. F150.
X30.
X30. Y20.
X10.
G80
M99▶ Simulate in the G-code viewer
How it works
- Each vise has its own work offset; the subprogram is written once.
- Probe or indicate every offset before the first run.
Codes used in this program
- G54 — Work Coordinate System 1
- G55 — Work Coordinate System 2
- G56 — Work Coordinate System 3
- G57 — Work Coordinate System 4
- M98 — Subprogram Call
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
- Face Milling Program (Zig-Zag Passes)
- Outside Contour with Cutter Compensation (G41)
- Circular Pocket with Helical Entry
- Bolt Hole Circle with Polar Coordinates (G16)
- Peck Drilling a Hole Grid (G83)
- Rigid Tapping Program (M8 × 1.25)
- Internal Thread Milling M12 × 1.75
- Rectangular Pocket in Depth Passes Using a Subprogram
- Counterbore Holes for M6 Socket Head Screws
- Fine Boring a Precision Bore (G76 on a Mill)
- Milling a Slot with Ramping Entry
- Chamfering an Outside Edge with a Chamfer Mill
- Parametric Bolt Circle Macro (WHILE Loop)
- Spindle Warm-Up Program
- Setting a Work Offset Automatically with a Probe (G31)
- GRBL Router: Rectangle Cut-Out in Depth Passes
- GRBL / LinuxCNC Touch Plate Z Probe (G38.2)
- Haas G12 / G13 Circular Pocket in One Line
- Haas M97 Local Subprogram for Repeated Features
- High-Speed Peck Drilling in Aluminum (G73)
- Helical Boring a Ø20 Hole with a 10 mm End Mill