G31 Skip Function and CNC Probing: Complete Setup and Safety Guide
Configure the G31 skip function for touch probing on Fanuc, Siemens, and Mitsubishi. Learn parameters, fix active alarms, and prevent probe collisions.
Avoiding Probing Collisions and Probe Damage
A faulty spindle probe, a broken signal wire, or an uncleared cutter compensation register can instantly cause a catastrophic hard collision on the CNC machine tool. When a touch-trigger probe is loaded in the spindle or turret to check part alignment, the controller expects a G31 skip signal to immediately halt travel, record coordinates, and delete the remaining distance-to-go. If the skip signal fails to register due to a wiring failure or if an operator has mistakenly kept tool radius compensation active, the axis will traverse the entire programmed distance at high feedrate. The delicate ruby stylus and probe body will slam directly into a table-mounted vise jaw, a spindle chuck, or workpiece clamps, shattering the measuring head, shutting down the control with a severe overload alarm, and leaving the operator with a completely ruined scrap part.
G31 Skip Function Technical Summary
| Technical Specification | Details |
|---|---|
| Command Code | G31 |
| Modal Group | Group 00 / Non-modal (One-shot) |
| Supported Brands | Fanuc, Siemens, Mitsubishi |
| Critical Parameters | Parameter No. 3401 (Fanuc), MD 18800 (Siemens), Parameter #1174 (Mitsubishi) |
| Main Constraint | Cutter compensation (G41/G42) must be cancelled using G40 prior to execution |
Quick Read: Probing and Skip Rules
- Cutter compensation must be cancelled with G40 before programming G31 or G160.
- Probing feedrate must be set low enough to prevent mechanical coasting from exceeding the physical deflection limit of the probe stylus.
- Do not initiate G31 with a pre-deflected probe, as this will immediately trigger Alarm 21700.
- Subsequent incremental (G91) movements are calculated relative to the actual contact point, so absolute (G90) retracts are highly recommended to avoid collisions.
- Turning ON the machine lock or Z-axis cancel switch will cause the control to ignore the skip signal, leading to a crash.
- Multi-step skip inputs use P-addresses (P1-P8 for Fanuc, P1-P4 for Siemens, P1-P255 bitmask for Mitsubishi).
Basic Concepts of the G31 Skip Command
The G31 skip function is an essential tool for automatic measurement, workpiece alignment, and tool setting in modern CNC machining. When the control executes G31, it drives the machine axes along a programmed path at a specified feedrate. During this linear travel, the controller actively monitors an external digital input connected to a touch-trigger probe. The moment the probe stylus makes physical contact with the workpiece, vise jaw, or tool setter, it triggers the skip signal.
Upon receiving the active skip signal, the CNC controller instantly executes a distance-to-go deletion, halting all axis movement. The controller records the precise machine coordinates at the moment of contact into dedicated system macro variables and immediately advances to the next block in the part program. This real-time coordinate capture allows macro programs to dynamically calculate part offsets, detect workholding alignment errors, and identify broken tools without operator intervention.
Implementing a G31 cycle requires strict adherence to modal programming rules. Because G31 is a non-modal, one-shot command belonging to Group 00, it applies only to the block in which it is written. Programmers must cancel active tool radius compensation (G41/G42) with a G40 command before executing G31. Failure to do so causes positioning conflicts, and the control will trigger a program error alarm.
G31 Command Structure and Syntax
The basic G31 command requires coordinate targets and a feedrate to define the probing path. The coordinate values determine the endpoint of the probing movement. If the probe fails to trigger a skip signal before reaching this coordinate, the machine will stop at the programmed endpoint and proceed to the next block. A feedrate (F-code) must be active or specified in the G31 block, as the machine cannot execute a probing move at zero speed.
For advanced probing configurations, controllers support multi-step skip commands using a P-address or modified G-codes. The P-address determines which physical input channel the control monitors during the skip move. This allows machines equipped with multiple probes (such as a spindle probe and a table-mounted tool setter) to selectively monitor different inputs without changing the wiring. On some controls, the P-address acts as a binary bitmask to monitor multiple inputs simultaneously.
Standard G31 syntax and basic command structure:
G31 X... Y... Z... F... [P...] ;
| Address / Parameter | Description |
|---|---|
| X, Y, Z | Absolute or incremental coordinates specifying the probing target endpoint. |
| F | Probing feedrate in mm/min (or inches/min), defining the speed of the touch move. |
| P | Multi-step skip input selector or bitmask (brand and option dependent). |
| R | Acceleration/deceleration time constant method (primarily used on Mitsubishi controls). |
Brand Applications: Fanuc, Siemens, and Mitsubishi
Fanuc
On Fanuc systems, G31 commands travel along designated axes at a controlled feedrate. The G-code System selection (A, B, or C) configured via Parameter No. 3401 determines how the coordinate addresses are parsed. In Lathe System A, absolute coordinates use X and Z while incremental coordinates use U and W. For Systems B and C, absolute and incremental modes are toggled via modal G90 and G91. Default power-up or reset modal states are controlled by Parameter No. 3402.
A typical Fanuc probing block utilizes G31 with coordinate targets and a specified feedrate. When using the multi-input skip option, programmers specify the address P (ranging from P1 to P8) to select the physical input channel.
| Fanuc Technical Detail | Description / Value |
|---|---|
| Core Parameters | Parameter No. 3401 (G-code System configuration), Parameter No. 3402 (Modal states at reset) |
| Alarm Codes | Alarm 21700 (Probe stuck active at start), Alarm PS0370 (P-address programmed without option), Alarm PS0010 (Improper G31 command without option installed) |
| Version / Option Differences | Option levels support a single input, four inputs (P1-P4), or eight inputs (P1-P8) |
Warning: Initiating a G31 probing move with an active tool nose radius compensation (G41/G42) will cause positioning offsets and trigger verification alarms. Always program G40 to cancel compensation before probing.
Siemens
To execute G31 on SINUMERIK controls, the parser must be switched to ISO Dialect Mode using G291. Channel-specific machine data MD 20154 defines the active G-codes upon power-on or reset. The external language interpreter option is enabled by machine data MD 18800.
The Siemens compiler translates the ISO-style G31 instruction. Programmers can specify P1 to P4 to select from four touch-trigger inputs defined by the machine configuration.
| Siemens Technical Detail | Description / Value |
|---|---|
| Core Parameters | MD 18800 (External language activation), MD 20154 (Active reset G-codes) |
| Alarm Codes | Alarm 21700 (Probe deflected at block start), Alarm 14800 (Feedrate zero or not programmed), Alarm 61800 (External CNC language option missing) |
| Version / Option Differences | SINUMERIK 840D sl allows parameter modification; SINUMERIK 802D sl parameters are write-protected |
Warning: If G31 is executed without an active or programmed feedrate and no fixed feedrate is defined, the control will instantly halt the cycle with Alarm 14800.
Mitsubishi
On Mitsubishi systems, the default probing feedrate is defined by parameter #1174. The selection between this default skip speed and the active modal feedrate is controlled by parameter #12022 bit 2.
Mitsubishi supports multi-step skip commands G31.1, G31.2, and G31.3 mapped to parameter-defined inputs. Additionally, G31 can be commanded with a P-address bitmask (1 to 255) to evaluate a logical sum of active skip signals.
| Mitsubishi Technical Detail | Description / Value |
|---|---|
| Core Parameters | #1174 (Default skip feedrate skip_F), #12022 (Skip speed specification bit), #2102 and #2103 (Skip acceleration/deceleration time constants), #1366 (Multi-system skip interlock), #12058 (Overtravel pre-check) |
| Alarm Codes | Program Error P608 (Active cutter compensation), Program Error P35 (P-value outside 1-255 range), Program Error P603 (Feedrate F is 0 and #1174 is 0), MCP Alarm Y51 15/16 (Invalid time constants) |
| Version / Option Differences | M80V TypeB restricts concurrent high-speed G-codes; C80 Series supports PLC integration using ZR device variables (#50000 to #52749) |
Warning: Attempting to run G31 or G160 with cutter compensation active will instantly trigger Program Error P608. Ensure G40 is active before starting measurement.
Brand Comparison for G31 Probing
| Topic | Fanuc | Siemens | Mitsubishi |
|---|---|---|---|
| Interpreter Structure | Standard ISO dialect parser | Bilingual interpreter (ISO dialect mode G291 to Siemens mode G290 transition) | Native Mitsubishi CNC G-code parser |
| Multi-Input Channels | Support for P1 to P8 inputs (option dependent) | Support for P1 to P4 inputs, mapped via system machine data | Support for P1 to P255 inputs, evaluated as logical sum bitmask |
| Sensorless Probing | — (no source) | — (no source) | Native G160 Torque Limitation Skip function |
| Option Verification | Strict option checking (triggers Alarm PS0370 if not enabled) | Missing external dialect option triggers Alarm 61800 | P-command value check triggers Program Error P35 if outside 1-255 range |
| EGB Sync Skip | Dedicated G31.8 EGB skip function | — (no source) | Dedicated G31.8 EGB skip function |
In-Depth Technical Analysis of Probing Behaviors
The comparative evaluation of G31 implementation across the three control brands highlights major structural differences in interpreter behavior, input signal mapping, and safety handling. The bilingual interpreter of Siemens controls operates by translating G31 commands under G291 ISO mode into internal variables. The control can transition to native Siemens mode (G290) to read these transfer parameters and execute high-level measuring cycles. Fanuc and Mitsubishi, on the other hand, execute the G31 skip function directly within their primary G-code compilers, ensuring execution speeds but requiring macro-based variable mapping.
Safety functions also show major brand-specific variances. Siemens controls enforce a unique safety retraction function using G10.6 (Rapid Lift), which is triggered by a digital input. For G10.6 to run, the system must have the interrupt program CYCLE3106.spf preloaded in the memory, otherwise the control halts with Alarm 14011. Mitsubishi takes sensorless safety a step further by offering G160 (Torque Limitation Skip). G160 operates without a physical probe; it monitors spindle or axis motor current limits (Q) and droop deviation values (D) to detect physical contact with raw stock, workholding vise jaws, or chucks, stopping the axes immediately when limits are exceeded.
Input selection methods reflect different configuration philosophies. Fanuc uses standard option checks; using a P-address (P1-P8) without the multi-step skip option enabled immediately halts the machine with Alarm PS0370. Siemens maps its P1-P4 inputs directly through channel-specific machine data. Mitsubishi processes multi-input skips with a strict P-address bitmask ranging from 1 to 255. In this mode, the P-value represents a logical sum of active skip signals, and any value programmed outside the 1 to 255 range triggers Program Error P35.
Program Examples and Dry Runs
Fanuc
G40 ;
G90 G31 Z-50.0 F100.0 ;
G10.6 Z5.0 ;
dry run
First, the G40 command cancels any active tool radius or tool nose radius compensation to prevent positioning calculation conflicts. Next, G31 initiates a linear probing motion in absolute coordinates toward Z-50.0 at a feedrate of 100 mm/min. If the spindle probe contacts the workpiece surface (e.g., at Z-32.4), the skip signal triggers, the CNC instantly stops Z-axis travel, stores Z-32.4 in the system variable, deletes the remaining 17.6 mm distance-to-go, and proceeds to the next block. Finally, G10.6 retracts the probe to Z5.0. If the probe does not contact the workpiece by Z-50.0, the machine stops at the target Z-50.0 and continues to the retraction block.
Siemens
G291 ;
G40 ;
G31 P2 Z120.0 F200.0 ;
G290 ;
dry run
The G291 command switches the bilingual SINUMERIK control to ISO Dialect Mode to parse standard Fanuc-style G-codes. G40 cancels any active cutter radius compensation to ensure safe linear interpolation. G31 P2 command begins a linear probing path towards Z120.0 at a feedrate of 200 mm/min, monitoring the physical input channel mapped to P2. If the probe stylus contacts the vise jaw or fixture at Z105.5, the skip signal triggers, axis motion terminates immediately, the actual coordinates are saved, and the remaining travel is discarded. The bilingual parser then executes G290 to switch back to native Siemens mode for subroutines or standard Siemens milling cycles.
Mitsubishi
G40 ;
G31 Z-50.0 R1 F100.0 ;
G160 Z-25.0 Q80 D0.5 F40.0 ;
dry run
The G40 command cancels active tool radius compensation, avoiding Program Error P608. G31 Z-50.0 R1 F100.0 starts Z-axis probing at 100 mm/min. The R1 address commands the controller to apply automatic acceleration and deceleration according to parameters #2102 and #2103 to prevent violent stopping. When the touch-trigger probe closes the circuit, axis travel decelerates to a stop, the actual coordinates are stored in variable #5061, and the remaining path is discarded. The subsequent G160 block performs sensorless torque probing along the Z-axis at 40 mm/min. If the spindle motor torque load exceeds 80% (Q80) or the servo droop deviation exceeds 0.5 mm (D0.5), the control registers a torque skip event, stops the Z axis, deletes the distance-to-go, and stores the contact coordinates.
Error Analysis and Troubleshooting
| Brand | Alarm Code | Trigger Condition | Operator Symptom | Root Cause / Fix |
|---|---|---|---|---|
| Fanuc | Alarm 21700 | Skip signal is active before G31 starts | Control halts immediately with alarm, cycle stops | Probe stylus is deflected, stuck, or there is an electrical fault. Clear obstacle or reset sensor. |
| Fanuc | Alarm PS0370 | P-address (P1-P8) programmed but multi-step skip option is not active | Cycle halts on G31 block, alarm displayed | The multi-input option is not purchased/configured. Remove the P command or enable the option. |
| Siemens | Alarm 14800 | G31 executed with feedrate F set to 0 or omitted | Probing move fails to start, control alarms out | No active modal F-code and no default parameter value. Specify feedrate F in the block. |
| Siemens | Alarm 61800 | G31 executed but external language compiler not enabled | Cycle halts on G291 or G31 command | Parameter MD 18800 or option bit 19800 is disabled. Enable external language support. |
| Mitsubishi | Program Error (P608) | G31 or G160 executed with active tool compensation | Control halts, cycle aborts at block start | Active tool radius/nose radius compensation (G41/G42). Program G40 before G31/G160. |
| Mitsubishi | Program Error (P35) | P-value programmed outside valid range of 1 to 255 | Probing cycle stops immediately with program error | Incorrect P-value mask programmed. Correct the P address to be within the 1 to 255 range. |
| Mitsubishi | Program Error (P603) | G31 or G160 issued without F-word and parameter #1174 is 0 | Probing fails to execute, cycle halts | Feedrate omitted and default skip feedrate parameter #1174 is unconfigured. Specify F or set #1174. |
Probing Application Note
Shattered probe styluses and measuring inaccuracies occur when programmers ignore signal latency and axis deceleration during probing cycles. When a probe stylus touches a workpiece, the machine cannot stop instantaneously; the axis coasts a specific distance determined by the formula: δ0 = (F / 60) × (Tp + t1 ± t2), where F is the feedrate, Tp is the position loop time constant, t1 is the response delay time, and t2 is the response error time. If the feedrate F is programmed too high, the resulting coasting distance will exceed the maximum mechanical deflection limit of the stylus, breaking the ruby ball and probe head. To prevent this, programmers must command a slow, controlled feedrate and compensate for this delay in the macro program by reading the skip coordinates from variable #5061 and subtracting the coasting offset (e.g., #102 = #110 × #111 / 60, where #110 is the feedrate and #111 is the response delay t1). Additionally, operators must verify that machine lock or the Z-axis cancel switch is turned OFF before probing. If machine lock is active, the skip signal is completely ignored, and the axis will traverse the full programmed distance, leading to a severe physical crash.
Related Command Network
- G28 Automatic Return to Reference Position: Used to return the machine axes to the home position prior to loading the touch probe into the spindle.
- G29 Return from Reference Position: Commands movement back from the reference position to position the probe near the workpiece.
- G30 Reference Position Return: Returns axes to secondary home positions, which is frequently used for automatic tool change sequences to load the probe.
- G10.6 Rapid Lift: Commands a high-speed tool retract and recovery sequence triggered by a digital signal in case of emergency.
- G160 Torque Limitation Skip: Performs axis movement in a torque-limited state, allowing sensorless measurement.
Best Practices Conclusion
Automating workholding measurement and tool detection with G31 requires precise programming structures and a clear understanding of brand-specific behaviors. By canceling cutter compensation before probing and utilizing absolute coordinate retracts, programmers can implement reliable inspection cycles that improve shop floor throughput and eliminate manual setup errors.
Frequently Asked Questions (FAQ)
Why does G31 trigger an alarm when the probe is not yet touching the part?
This alarm, typically Fanuc/Siemens Alarm 21700, occurs because the skip signal input is already active before axis motion begins. This is caused by a physically deflected stylus, a stuck probe internal contact, or a broken/shorted signal wire. Operators should inspect the physical probe stylus for damage and verify the signal state in the CNC diagnostic registers before restarting the cycle.
Can I program G31 while tool radius compensation is active?
No, attempting to run G31 or G160 with active tool radius or tool nose radius compensation (G41/G42) will cause positioning calculation conflicts and trigger a program error alarm such as Mitsubishi P608. Programmers must cancel compensation with an explicit G40 command prior to executing the probing block.
Why do incremental movements immediately following G31 behave unpredictably?
After a G31 skip signal triggers, the CNC controller deletes the remaining distance-to-go and makes the actual contact coordinate the new reference point. Consequently, any incremental (G91) move programmed in the next block calculates its path relative to this contact point, shifting the entire subsequent path. Always program retract moves in absolute (G90) coordinates to ensure the tool pulls away to a fixed safety clearance.
Still not resolved?
Ask our AI assistant about this topic in natural language. Grounded in verified sources, no hallucinations.

- CNC CARE Co-Founder (May 2025 - Present)
- Mitsubishi Electric NC Sales & Service Section Manager (2008 - 2025)
- Reis CNC Service Engineer (2003 - 2008)
- Ören Kalıp CNC Mold Line Team Leader (1999 - 2002)
With over 25 years of experience working in all areas of the CNC machine industry, I continue my activities as a co-founder of CNC CARE, where we offer brand-independent consulting, engineering, and original spare parts services.
Related Articles
Other articles on this topic
G71 Metric Dimensioning Guide for Siemens SINUMERIK Controls
Learn how to program G71 and G710 metric dimensioning on Siemens SINUMERIK controls, including parameter MD 10240, alarm codes, and G-code syntax errors.
G69 Balance Cut Cancel: Coordinate Recovery & Crash Prevention
Learn how to program the G69 balance cut cancel command for Fanuc, Siemens, and Mitsubishi turning centers. Cancel dual slide synchronization and prevent crashes.
G70 CNC Finishing Cycle Guide for Fanuc, Siemens, and Mitsubishi
Learn the G70 finishing cycle for CNC turning. Master syntax, parameters, and alarm codes for Fanuc, Siemens CYCLE95, and Mitsubishi controls to avoid crashes.
G69 Coordinate System Rotation Cancel: Modals, Alarms, and Setup
Learn to cancel G68 facing turret mirrors and coordinate rotations using G69 on Fanuc, Siemens, and Mitsubishi CNCs to prevent turret crashes.