A probing move is a feed move with an exit condition: advance until the probe input trips, remember exactly where that happened, stop. It's how machines find part corners, bore centers, surface heights, and tool lengths — the bridge between where the part actually is and where the work offsets say it is.
This is also the least portable corner of G-code. Three unrelated spellings exist for the same operation:
G38.2–G38.5— LinuxCNC and GRBL (the RS-274/NGC family)G31(withP1–P4multi-step variants, Mach4G31.1–.3) — FANUC and Mach, where it's called the skip functionM115/M116/M125/M126— Centroid's protected probing moves (no G-code probing at all)
; Find the top of the part and set G54 Z0 there (LinuxCNC/GRBL dialect)
G91 ; incremental — probe moves are usually relative
G38.2 Z-25 F100 ; feed down max 25mm until the probe trips
G0 Z2 ; back off the surface
G38.2 Z-5 F25 ; second touch, slower, for repeatability
G90 ; absolute again
G10 L20 P1 Z0 ; "current (tripped) position is G54 Z0"
G0 Z10
The two-touch pattern — fast find, slow confirm — is standard because trip
accuracy scales with approach speed. The result lands in parameters
(#5061+ on LinuxCNC/FANUC; GRBL reports a PRB: message), and the
G10 L20 line is what turns a measurement into a usable work offset.
#Error or no error: choosing the variant
G38.2 alarms if it travels the full distance without contact. That's a
feature: "part not found" should stop a program, not let it cut air — or
worse, cut where the part isn't. G38.3 (no error) exists for search
patterns that legitimately expect misses. The away-variants G38.4/.5
release from a surface — used to find the back side of a trip point and
in tool-setter routines. Centroid mirrors the same choices with L1 on
its M-codes suppressing the error.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Probe toward work, error if no contact | G38.2 |
G38.2 |
M115 / M116 |
G31 |
G31 |
G31 |
FANUC syntax: G31 P1–P4 for multi-step skip. Centroid has NO G31/G38 — it probes with protected-move M-codes. Centroid: protected-move probing; M115 minus, M116 plus |
| Probe toward work, no error if no contact | G38.3 |
G38.3 |
M115/M116 L1 |
— | — | — | Centroid: L1 suppresses the no-contact error |
| Probe away from surface | G38.4 / G38.5 |
G38.4 / G38.5 |
M125 / M126 |
— | — | — | G38.4 errors if still in contact; G38.5 does not. Centroid: probe-away variants |
| Multiple probe inputs | — | — | — | — | — | G31.1 / G31.2 / G31.3 |
Select among several probe inputs. |
| Move an axis until a switch trips | — | — | M105 / M106 |
— | — | — | Feeds the named axis until a PLC switch/input opens (P > 0) or closes (P < 0). Centroid: M105 minus, M106 plus |
— means the control has no equivalent code. Full cross-control tables: the complete G-code & M-code reference.
#Common mistakes
- Probing at rapid, or with G0. A probe move is a feed move; the trip has to out-run the machine's stopping distance. Fast approach, slow touch — never G0 at a surface with a probe.
- No overtravel allowance. The probe stylus must be able to physically stop after the trip. Commanding a probe move that ends exactly at the expected surface leaves zero margin — always probe past where you expect contact.
- Assuming the program continues after a failed probe. With the erroring variants it doesn't — which is correct, but the routine needs to be written knowing it (retract before re-trying, don't leave the stylus buried).
- Porting probe routines between controls. The G38↔G31↔M115 gulf is total: different codes, different result parameters, different error semantics. This is a rewrite, not a rename.
- Probing with the wrong offset stack active. A leftover G92 shift or the wrong G5x system silently corrupts every measurement into the wrong offset — the probe did its job; the bookkeeping lied.