G31

Machining center, LatheOne-shot, group 00

Skip function (moves in a straight line until a signal comes in)

Format and notes

G31 X_ Y_ Z_ F_ (lathe: G31 X(U)_ Z(W)_ F_)

Example

G00 G90 G54 X0 Y0 ;
G43 H01 Z10. ;        (probe tool length)
G31 Z-5. F200 ;       (stops on contact. Always write F)
#100 = #5063 ;        (Z where it stopped. #5063 is the Haas number)
G00 Z10. ;

A skeleton example written by Kezuriba for measuring the height of the top surface of a workpiece with a touch probe. The variable number that stores the stopped position differs by model.

Diagram: G31: how the next block moves after the signal stops the axes

Path if no signal comesActual path★ Signal① Next block incrementalG31 Z-60.★Next blockG91 X40. Z-10.② One axis absoluteG31 Z-60.★Next blockG90 X40.③ Both axes absoluteG31 Z-60.★Next blockG90 X40. Z-50.
Example: on the way to Z−60 with G31, the signal comes in at ★, the rest of the move is discarded and the control goes on to the next block. ① With an incremental command, the axes move the commanded amount from where they stopped, so the end point shifts too. ② If only one axis is absolute, only the axis you wrote goes to its commanded position; the axis you did not write (Z here) stays where it stopped. ③ If both axes are absolute, they go to the same point wherever the stop happened (redrawn by Kezuriba based on the Siemens ISO dialect and Mitsubishi Electric explanations).

Differences between controls and machines

The same code can be written or assigned differently depending on the CNC control and the machine builder. Always check your machine’s manual.

SourceMachineItemDetail
Mitsubishi ElectricLatheNotesIf no signal comes in, it moves to the commanded position and ends (no alarm). If F is omitted, the speed in parameter #1174 is used. Feed override is fixed at 100%, and dry run has no effect
HaasMachining centerNotesIf no signal comes in, it records the end point position and carries on (no alarm). Stopped positions are in #5061–#5066 (per axis). Without F, an alarm occurs. A feed below 2500 mm/min (100 inch/min) is recommended
Siemens (ISO dialect)LatheNotesIf it reaches the end point without a signal, an alarm occurs. The stopped position is in the system variable $AA_IM[axis]
Siemens (native)—FormatMEAS (a signal deletes the rest of the move), MEAW (moves on to the end point without deleting it)
LinuxCNC—CodeThere is no G31. G38.2 (error if no contact), G38.3 (no error), G38.4/G38.5 (moving away). Stopped positions are in #5061–#5069, and success or failure is in #5070

Sources

The meaning of this code agrees in two or more sources from different publishers. Explanations are written in our own words.

  1. Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Turning, 04.2007 Edition cache.industry.siemens.com
  2. Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Milling, 04.2007 Edition (6FC5398-7BP10-0BA0) cache.industry.siemens.com
  3. Mitsubishi Electric — MITSUBISHI CNC 700/70 Series Programming Manual (Lathe System) (IB-1500057) mitsubishielectric.com
  4. Haas Automation, Inc. — G31 Feed Until Skip (Group 00) (machining center, per-code explanation page) haascnc.com
  5. Haas Automation, Inc. — Lathe Operator's Manual – 16 Lathe G-Codes (online version) haascnc.com
  6. LinuxCNC project — G-Codes (LinuxCNC Documentation) linuxcnc.org
  7. Siemens AG — SINUMERIK 840D sl/840D/840Di sl/810D Fundamentals, Programming Manual, Edition 08/2005 (6FC5398-1BP10-0BA0) cache.industry.siemens.com