Example program · Mill
GRBL / LinuxCNC Touch Plate Z Probe (G38.2) — G-Code Example
Probes down onto a 15 mm touch plate, sets work Z0 on the top of the stock with G10 L20, and retracts.
Probes down onto a 15 mm touch plate, sets work Z0 on the top of the stock with G10 L20, and retracts.
| Item | Value |
|---|---|
| Machine | CNC mill / machining centre (Fanuc-style) |
| Units | Metric (G21) |
| Lines | 10 |
Program
(Z TOUCH PLATE - PLATE THICKNESS 15.0 MM)
G21 G90
G91
G38.2 Z-30 F100 (fast find)
G0 Z2
G38.2 Z-5 F25 (slow, accurate)
G10 L20 P1 Z15.0 (current position = Z15 in G54)
G0 Z10
G90
M30▶ Simulate in the G-code viewer
How it works
- Clip the plate wire on the bit and test the probe input before running.
- G38.2 stops with an error if no contact is found — protecting the bit.
- L20 P1 writes G54 so the current position becomes Z = plate thickness.
Codes used in this program
- G38.2 — Straight Probe Toward Workpiece (Stop on Contact, Error if Not)
- G10 — Programmable Data Input (Set Offsets)
- G91 — Incremental Programming
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
- Machining Multiple Parts with G54–G57
- 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
- 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