G-code reference

G31 G-Code: Skip Function (Probing Move)

Skip Function (Probing Move) — Moves like G01 until the skip signal (usually a touch probe) triggers. The axis then stops and the trigger position is stored in system variables (#5061–#5066…

By cnccode · Updated
PropertyValue
CodeG31
FunctionSkip Function (Probing Move)
Modal group00
TypeOne-shot (non-modal) — active only in its own block
Used onMills and lathes
SyntaxG31 X_ Y_ Z_ F_

What does G31 do?

Moves like G01 until the skip signal (usually a touch probe) triggers. The axis then stops and the trigger position is stored in system variables (#5061–#5066 on Fanuc).

G31 is a one-shot code: it only acts in the block where it is written, and the previously active modal codes take over again afterwards.

Syntax and parameters

Format
G31 X_ Y_ Z_ F_
AddressMeaning
X Y ZTarget (must lie beyond the expected contact)
FProbing feed

G31 example program

Example
G31 Z-20.0 F100.
#100 = #5063 (Z skip position)

▶ Open this example in the G-code viewer

Tips and common mistakes

  • If no contact occurs the move completes — macros must check for that.
  • Use slow, constant feed for repeatable measurements.
  • Renishaw cycles (O9810/9811) wrap G31 with protected moves.

Controller compatibility

G31 follows the ISO/Fanuc dialect used by Fanuc, Haas, Brother, Doosan, Hurco (ISO mode), Mazak (EIA/ISO mode), Okuma (G-code mode) and Siemens in ISO dialect mode. Parameters, option packages and builder-specific behaviour can differ, so confirm the details in your machine's programming manual before running a new program.

Frequently asked questions

Is G31 modal?
No. G31 is a one-shot (group 00) code and only acts in the block where it appears.
What does G31 mean in CNC?
G31 means Skip Function (Probing Move). Moves like G01 until the skip signal (usually a touch probe) triggers. The axis then stops and the trigger position is stored in system variables (#5061–#5066 on Fanuc).
What is the difference between G31 and G65?
G31 is Skip Function (Probing Move), while G65 is Macro Call (Non-Modal). See the G65 page for its syntax and examples.
Can I use G31 on a lathe?
Yes, G31 is used on both mills and lathes, although some parameters differ between them.