G37 Automatic Tool Length Measurement: Fanuc, Siemens, Mitsubishi
Learn G37 automatic tool length measurement on Fanuc, Siemens, and Mitsubishi controls. Master syntax, parameters, alarms like PS0080, and safety rules.
Introduction to Closed-Loop Probing and Collision Risks
Executing an automatic tool offset calibration cycle with an active cutter radius compensation command (G41 or G42) can cause a catastrophic spindle head or turret collision, instantly fracturing the electrical touch sensor, distorting the workpiece coordinate alignment, and leaving the operator with a ruined scrap part. In modern automated manufacturing, turning center turrets and milling spindles rely on automatic calibration to maintain part tolerances across long runs. Failing to cancel radius compensation with a G40 command before executing automatic measurement forces the interpreter to calculate an offset trajectory, shifting the path and driving the tool holder directly into table clamps, a vise jaw, or the rotating spindle chuck.
Another common source of calibration failure is sensor propagation latency. The CNC control requires between 0 and 2 milliseconds to process the touch-trigger signal. If the operator programs an excessively high measurement feedrate to shorten cycle times, the axis travels beyond the probe deflection limit during this processing delay, shattering the probe stylus. To ensure shop floor safety, the deceleration offset parameter must always exceed the sensor search range, and the workpiece coordinate system (G54-G59) must match the active programming coordinate system to prevent subsequent machining passes from cutting too deep.
Technical Summary
| Feature | Specification |
|---|---|
| Command Code | G37 (Standard), G36 / G37.1 / G37.2 (Expanded / Lathe depending on brand) |
| Modal Group | Group 00, Non-modal (Unmodal) |
| Brands | Fanuc, Siemens (using G291 ISO Mode G31 or native cycles), Mitsubishi |
| Critical Parameters | Fanuc Parameter No. 6241 (Measurement feedrate) & No. 6254 (Search tolerance); Mitsubishi #8004 (Measurement speed) & #8005 (Deceleration zone) |
| Main Constraint | Cutter and tool nose radius compensation (G41/G42) must be canceled with G40 before calling the cycle. Probing coordinates must be programmed in absolute mode (G90). |
Quick Read
- Program a G40 command to cancel active tool nose or cutter radius compensations before calling an automatic tool measurement cycle.
- Select absolute coordinate programming (G90) prior to the measurement block to prevent tool path retraction offsets.
- Pre-load and activate the tool length offset code (H or T) in a separate block before initiating G37 calibration.
- Adjust machine parameters so the deceleration offset zone is larger than the search range limit.
- Set the measurement feedrate low enough to prevent physical probe damage during the controller signal propagation latency (0 to 2 ms).
- Verify the workpiece coordinate system matches the active programming coordinate system to avoid deep machining cuts.
Basic Concepts of Automatic Tool Length Measurement
Automatic tool length measurement establishes a closed-loop setup sequence that allows a CNC machine tool to dynamically calibrate its tool geometry offsets before cutting material. The tool or turret moves at rapid traverse toward the expected sensor coordinate. At the deceleration limit, the feedrate is reduced to the measurement feedrate. The tool continues to advance at this lower speed until it makes contact with the touch sensor, triggering a touch-trigger probe signal that stops axis motion instantly, calculates the deviation from the expected target, and registers the correction.
When the tool has an active offset in the control register, the CNC adds the measured deviation to the wear offset register. If the active offset is zero, the control registers the new value directly as the tool length shape or geometry offset. This dynamic update prevents errors that occur during manual data entry, saving setup time and preventing scrap.
Maintaining safety coordinates during this cycle requires defining an axis travel safety envelope where the starting point is far enough from the sensor to prevent premature triggers. If a manual interrupt is applied while the tool is moving at the measuring feedrate, the operator must return the tool to its pre-interrupt coordinate before restarting execution to prevent path distortion.
Command Structure and Programming Syntax
G37 is an unmodal Group 00 preparatory command that is only active in the block where it is commanded. The programmer must specify the coordinate of the target axis to be measured. The controller executes a fast approach segment followed by a slow measurement search segment, switching feedrates when it crosses the safety boundary.
For variable-lead threading operations like G34 variable lead threading or G35 decreasing lead threading, the controller must calculate dynamic lead transitions. Constant lead threading on Siemens controls is executed via G33 thread cutting. In contrast, G37 performs a straight probing move along a single axis until an external contact signal interrupts motion.
Syntax Formats
Fanuc Turning (Lathe) Mode:
G36 X xa ; (or G37 Z za ;)
Fanuc Turning Expanded Mode:
G37.1 X xa ; (or G37.2 Z za ;)
Fanuc Machining Center (Milling) Mode:
G90 G37 Z za ;
Siemens ISO Dialect Mode:
G31 Z za F fp ;
Mitsubishi Machining Center Mode:
G37 Z za R r D d F fp ;
Mitsubishi Turning Mode:
G37 X xa R r D d F fp ; (or G37 Z za R r D d F fp ;)
Parameters
| Address | Brand | Description | Range / Limit |
|---|---|---|---|
X, Z | Fanuc, Mitsubishi, Siemens | Absolute expected coordinate of the measurement position. | Coordinate limits |
R | Mitsubishi | Deceleration distance from the expected measurement coordinate (incremental value). | 0 to 99999.999 mm |
D | Mitsubishi | Search tolerance range (allowable touch window). | 0 to 99999.999 mm |
F | Mitsubishi, Siemens | Measurement feedrate for the probing approach. | Positive integer |
P | Siemens | Probe input channel selection (1 to 4). | P1 to P4 |
Brand Applications: Fanuc, Siemens, and Mitsubishi
Fanuc
Fanuc systems configure turning and milling offsets differently. Turning controls utilize unmodal Group 00 G-codes G36 and G37, or G37.1 and G37.2, to calibrate the X and Z axes, writing the corrections directly to geometry or wear registers. Milling systems utilize a single G37 command along the specified axis, which requires the tool length offset code H to be activated in a prior block.
Parameter settings define the safety boundaries and feedrates. Parameter No. 6241 sets the probing feedrate, and parameters No. 6251 and No. 6252 set the deceleration offset distance ($y$). Parameters No. 6254 and No. 6255 define the allowable search tolerance zone ($\epsilon$). Turning systems toggle between standard and expanded mode via parameter No. 3405 bit 3.
| Parameter | Description | Default / Range |
|---|---|---|
| No. 3405 Bit 3 | Lathe G-code system configuration (0 = G36/G37, 1 = G37.1/G37.2). | 0 or 1 |
| No. 6241 | Measurement feedrate ($F_p$) used during sensor approach. | Positive mm/min |
| No. 6251 / No. 6252 | Deceleration offset distance ($y$) for X and Z axes. | Positive offset |
| No. 6254 / No. 6255 | Allowable search range / tolerance zone ($\epsilon$) for X and Z axes. | Positive value |
| No. 6210 Bit 7 | Milling CCM parameter (0 = standard compensation, 1 = with actual offset). | 0 or 1 |
| No. 0001 Bit 1 | FCV parameter (1 = legacy Series 15 program format). | 0 or 1 |
Executing G37 while the touch sensor is depressed or failing to trigger the sensor before the coordinate boundary results in Alarm PS0080. Operators must verify starting clearances to avoid crashes.
Siemens
Siemens controls do not feature a native G37 command. Automatic tool calibration is executed interactively via HMI Operating Softkeys ("Meas. tool") in JOG mode, or through option-locked macro Measuring cycles. In ISO Dialect Mode (G291), the parser translates the unmodal probing command G31 into the measuring cycle CYCLE328.spf, allowing programmers to use standard G-code formats.
Machine data parameters govern the ISO dialect translation behavior. Parameter MD 18800 must be set to 1 to enable external language interpretation, and MD 10890 configures tool change programming. Parameter MD 10760 controls whether tool length and radius compensation are suppressed under G53, G153, and SUPA.
| Machine Data | Description | Value Range |
|---|---|---|
| MD 18800 | Activation of external NC languages (global ISO Dialect interpreter option). | 0 or 1 (must be 1) |
| MD 10890 | Configuration of tool change programming. Bit 2 controls D or H offset selection. | Bit-configured |
| MD 10760 | Suppression of tool length and radius compensation for G53, G153, and SUPA. | 2 to 4 |
If the touch probe signal is active before G31 starts, the control halts execution and triggers Alarm 21700. If no feedrate is active, Alarm 14800 is triggered. In addition, when G91 incremental coordinates are programmed in the block immediately following G31, Siemens calculates the retraction relative to the actual contact coordinate rather than the programmed coordinate, which can cause retract collisions if absolute coordinates are not used.
Mitsubishi
Mitsubishi controls use unmodal G-codes G37 or G37.1 to calibrate tools. When the tool tip makes contact with the touch sensor, the G31 skip signal is triggered, distance-to-go is deleted, and the coordinate registers are updated. The control adds the deviation to the wear register if the offset is non-zero, or writes the geometry offset if it is zero.
In-block addresses R, D, and F specify the calibration parameters, overriding the system defaults. Parameter #8004 SPEED defines the default feedrate, and parameters #8005 ZONE r and #8006 ZONE d define the default safety zones. Parameter #1080 Dril_Z restricts measurements to the Z-axis, and parameter #1381/bit0 TolOfsCmdCheck_M checks for zero-value offsets.
| Parameter | Description | Default / Range |
|---|---|---|
| #8004 SPEED | Default measuring feedrate ($F_p$) used during sensor approach. | 0 to 60000 mm/min (lathe), 0 to 1000000 mm/min (milling) |
| #8005 ZONE r | Default deceleration range ($r$) when R is omitted. | 0 to 99999.999 mm |
| #8006 ZONE d | Default search range limit ($d$) when D is omitted. | 0 to 99999.999 mm |
| #1080 Dril_Z | Milling parameter. If 1, Z is strictly enforced as the only valid measuring axis. | 0 or 1 |
| #1238 set10/bit0 | Lathe parameter. Toggles whether G36 is CCW circular threading (1) or X-axis tool measurement (0). | 0 or 1 |
| #1381/bit0 | TolOfsCmdCheck_M. If 1, calling offset H with a compensation value of 0 triggers program error. | 0 or 1 |
If the probe is triggered outside the search range or fails to detect the signal, the system triggers Program error P607. When manual interrupt is applied during measurement, the operator must manually return the axis to its pre-interrupt position before resuming to prevent path distortion.
Brand Comparison
| Feature / Option | Fanuc | Siemens | Mitsubishi |
|---|---|---|---|
| Native Probing Command | G37 (Z-axis / Milling), G36/G37 or G37.1/G37.2 (Lathe) | — (no source) | G37 / G37.1 (Milling), G36/G37 or G37.1/G37.2 (Lathe) |
| Safety Zone Configuration | Parameters No. 6251 and No. 6254 | Programmed through cycles or softkeys | Dynamic in-block coordinates (R and D addresses) |
| Alarm Reporting | Consolidated Alarm PS0080 | Alarms 21700, 14800, 61800, 14011 | Multi-tier Program Errors P600 to P607 |
| Multi-Start Offset | — (no source) | — (no source) | — (no source) |
Technical Analysis
Three distinct programmatic behaviors clearly distinguish Fanuc's automatic tool measurement from Siemens and Mitsubishi controls. First, Fanuc utilizes a unified alarm reporting structure. Fanuc aggregates all out-of-boundary touches, premature triggers, and failure-to-contact events into a single, standardized alarm code PS0080. Mitsubishi controls, in contrast, utilize a highly structured, multi-tier program error numbering format ranging from P600 to P607. Second, Fanuc turning controls map automatic offsets to specific coordinates using G36/G37 or G37.1/G37.2 depending on Parameter No. 3405. Mitsubishi lathe controls, conversely, map automatic tool length measurement exclusively to unmodal G-codes G37 and G37.1, requiring the programmer to define the incremental deceleration offset via address R and allowable tolerance via D directly inside the G-code block. Third, Fanuc implements G37 as a native, hardware-level unmodal Group 00 motion command that directly overrides modal coordinates. Siemens controls, by comparison, do not utilize a native G37 G-code; instead, they handle tool length and diameter probing via conversational operating softkeys or high-level measuring cycles (such as CYCLE971) that require a dedicated software option to adapt program-support subroutines. When operating in Siemens ISO Dialect mode, standard measuring commands are mapped to G31, which is translated under the hood into native Siemens subroutines (such as CYCLE328.spf). In addition, Siemens implements strict G91 retrospective coordinate referral, where subsequent incremental moves align with the actual trigger coordinate, whereas Fanuc and Mitsubishi controls utilize more rigid coordinate-overwrite parameters.
Program Examples
Fanuc Example
T0101 ; Selects tool 1 with offset 1
G37 Z150.0 ; Executes Z-axis automatic offset to expected absolute coordinate 150.0
G43 H11 Z50.0 ; Activates tool length offset number 11 in a prior block
G90 G37 Z-120.0 ; Executes Z-axis automatic measurement to absolute Z-120.0
dry run
- Turret indexes to Tool 1 with offset 1 (T0101).
- The Z-axis moves rapidly toward Z150.0.
- At the deceleration limit (Z150.0 minus parameter No. 6252), feed drops to Parameter No. 6241 measurement speed.
- The tool contacts the sensor, halting motion instantly and writing the correction to geometry offset 1.
- Next, tool offset 11 is activated.
- The Z-axis moves rapidly to coordinate Z-120.0, decelerating at the safety threshold.
- Contact triggers the approach end signal, and the deviation is stored in H11.
Siemens ISO Mode Example
G291 ; Switches the interpreter parser from native Siemens to ISO Dialect mode
T1 D1 ; Calls tool T1 and activates cutting edge D1 for measurement
G31 Z-120. F100 ; Probing move along Z-axis toward absolute Z-120.0 at a feedrate of 100 mm/min
G290 ; Switches the interpreter parser back to native Siemens mode
dry run
- Interpreter shifts parser to ISO Dialect (G291).
- Tool T1 and cutting edge D1 are selected.
- Probing cycle (G31) starts along the Z-axis toward absolute Z-120.0.
- At feedrate F100, the tool moves until the touch probe is triggered.
- Axis motion is deleted, coordinate registers are read, and the value is recorded into Siemens tool list for D1.
- Interpreter returns to native Siemens Mode (G290).
Mitsubishi Example
G43 H01 ; Activates tool length compensation number 1 modal beforehand
G37 Z-400. R200. D150. F100 ; Z-axis tool length calibration to expected coordinate -400.0, deceleration range 200.0, search limit 150.0
dry run
- Tool length offset 1 (H01) is modalized.
- G37 command executes Z-axis calibration.
- The tool approaches target Z-400.0 at rapid traverse.
- At a distance of 200.0 mm (R200.0) from the target, feedrate drops to F100.
- Probing search occurs within the 150.0 mm (D150.0) tolerance window.
- Contact triggers G31 skip input, halting feed and adding the coordinate deviation to wear offset 1.
Error Analysis
| Brand | Alarm Code | Trigger Condition | Operator Fix |
|---|---|---|---|
| Fanuc | Alarm PS0080 | Sensor approach end signal activated prematurely in the deceleration zone, or never triggered before reaching the safety boundary. | Check starting clearance and increase search limit parameters (No. 6254 / No. 6255). |
| Siemens | Alarm 21700 | Probing command (G31) initiated while the touch-trigger probe signal is already active (stuck sensor). | Clean debris from the sensor stylus, verify hardware operation, and reset probe state. |
| Siemens | Alarm 14800 | Path velocity is less than or equal to zero during a probing move. | Program a valid feedrate F prior to or within the probing block. |
| Siemens | Alarm 61800 | Probing command executed under ISO mode while external language machine data MD 18800 is disabled. | Enable external language support (set MD 18800 = 1). |
| Siemens | Alarm 14011 | CYCLE3106.spf is missing from NC program memory when G10.6 rapid lift is called. | Ensure CYCLE3106.spf exists in part program memory. |
| Mitsubishi | Program error P600 | G37 or G37.1 is commanded when the option has not been enabled. | Verify machine options and builder PLC integration. |
| Mitsubishi | Program error P604 | No axis coordinate is commanded, or multiple axes are commanded in the G37 block. | Command exactly one axis coordinate (e.g. Z) in the G37 block. |
| Mitsubishi | Program error P605 | Tool offset code H is commanded in the same block as G37. | Define the tool offset value in a prior block. |
| Mitsubishi | Program error P606 | No active tool length offset (G43 H) is programmed prior to G37. | Call G43 H in a prior block. |
| Mitsubishi | Program error P607 | Probe signal is triggered outside the search range (Area D) or never detected at the endpoint. | Verify physical envelope coordinates and check sensor alignment. |
| Mitsubishi | Program error P608 | Tool radius compensation (G41 or G42) is active when G37 is called. | Cancel radius compensation with G40 before executing G37. |
| Mitsubishi | Program error P957 | Tool length compensation value for the active offset number H is set to 0 when G43 or G53.6 is called. | Set a non-zero value for the offset in the registry. |
Application Notes
Spindle chuck and turret collisions during automatic calibration result directly from active cutter compensation offsets. When a programmer commands a G37 cycle on a Fanuc turning turret, a Siemens machining center spindle, or a Mitsubishi lathe control without canceling tool nose radius compensation using a G40 command, the parser computes a path shift. This path shift drives the tool holder beyond the safe deceleration limit. Instead of a controlled measurement touch, the axis feeds at rapid or high measurement speeds into a violent hard collision, shattering the electrical probe, overloading axis servo drives, and converting the raw stock into a ruined scrap part.
Related Command Network
- G43 / G44 / G49: Activates or cancels tool length compensation offsets which must be modalized prior to running the automatic tool calibration cycle.
- G31: Initiates a hardware-level skip function probing path that G37 internally utilizes to capture coordinates on sensor trigger events.
- G40 / G41 / G42: Cancels or enables tool radius and cutter compensation, where compensation must be canceled with G40 before G37 to prevent crash-inducing path deviations.
- G290 / G291: Toggles between native Siemens language and external ISO Dialect mode to enable G31 probing parser operations.
- G10: Enables programmable input of tool offsets and parameters to register base calibration coordinates directly from the part program.
Practical Takeaways for Safe Calibration
Successful automatic tool offset calibration depends on isolating G37 cycles from active radius compensations and maintaining strict safety envelopes. Setting the deceleration zone wider than the sensor search tolerance ensures the axis drops to measurement feedrate before probe contact. Restricting measurement feedrates to compensate for electrical signal propagation delays prevents mechanical overload and preserves sensor integrity.
Frequently Asked Questions
Why does G37 trigger an alarm when programmed in the same block as an H-code?
Programming the tool length offset code and G37 in the same block forces the controller to activate the offset and probe simultaneously, violating G-code modality rules. To prevent this alarm, program the G43 H command in a separate block before calling G37.
How does tool radius compensation affect the automatic measurement path?
Active tool radius compensation (G41 or G42) shifts the computed trajectory based on cutter geometry vectors, causing G37 to execute along an off-center path. Always cancel cutter compensation by programming a G40 command before executing the tool calibration cycle.
What parameter rules prevent touch probe collisions?
The deceleration distance parameter ($y$ or $r$) must always exceed the allowable search range ($\epsilon$ or $d$). If this condition is violated, the tool will trigger a collision alarm or crash. Adjust the parameters on the control screen to ensure the safety envelope satisfies the formula.
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.