G27 Reference Position Return Check: CNC Guide for Multi-Brand Systems
Master the CNC G27 reference position return check on Fanuc, Siemens, and Mitsubishi controls. Learn parameters like MD 34100 and fix Alarm 61816.
Introduction
A silent axis stall or feedback encoder slip during a heavy roughing pass will shift the CNC machine's coordinate system without triggering an immediate control alarm. If the parts program immediately proceeds to a tool change under this false coordinate assumption, the subsequent tool mounted on the turret will misindex or initiate an unexpected rapid traverse. This leads directly to a catastrophic hard collision where the tool holder or turret slams at full rapid traverse into the chuck jaws, tailstock, vise jaws, or workpiece clamp. Such high-speed impacts instantly shatter the cutting tool, produce a ruined scrap part, and cause severe structural damage to the spindle assembly or turret indexing mechanism. Programming the G27 Reference Position Return Check creates a non-interactive safety gate, forcing the control system to physically verify axis coordinate integrity before executing critical tooling changes or machining sequences.
Technical Summary
| Technical Attribute | Specification |
|---|---|
| Command Code | G27 |
| Modal Group | Group 00 / Non-modal (One-shot) |
| Applicable Brands | Fanuc, Siemens, Mitsubishi |
| Critical Parameters | Fanuc: No. 1401 Bit 1 (LRP); Siemens: MD 34100 $_MA_REFP_SET_POS; Mitsubishi: #2037 G53ofs |
| Main Constraint | At least one axis coordinate must be programmed in the G27 block. All tool offsets and nose/cutter radius compensation (G40, G49, Txx00) must be canceled prior to execution. |
Quick Read
- Halt on Drift: Automatically interrupt cycle execution and trigger a misposition halt if physical axis end coordinates deviate from the machine zero.
- Cancel Offset Compensation: Always program G40 and tool length/offset cancels (Txx00 or G49) prior to executing G27 to prevent false non-arrival alarms.
- Syntax Address Minimum: Program at least one axis coordinate (such as X, Y, Z, U, W) in the G27 block; empty command blocks will cause syntax errors.
- Deactivate Coordinates: Disable all active scaling, coordinate system rotation, and mirroring functions to avoid coordinate shifting and failed checks.
- Multi-Point Checking: Use Mitsubishi's P address parameter (P1 to P4) to check up to four distinct reference positions, defaulting to the first position.
- Cycle Time Loss: Account for a cycle delay of approximately one to three seconds due to the control's built-in motion deceleration and feedback checks.
Basic Concepts
Integrating the G27 reference position return check into a part program establishes a programmatic safety gate that verifies the physical integrity of the coordinate system. When a cutting tool finishes its machining operations, the programmer inserts a G27 command to traverse the axis slides toward the reference point. Upon arrival, the control system checks the axis feedback loop to verify if the physical slides align exactly with the machine zero home position. If the check succeeds, the corresponding reference position indicators (LEDs or display signals) activate, and the control continues executing the program. By confirming axis alignment, programmers prevent situations where mechanical slippage, servo errors, or tool drift shift the coordinates, which would otherwise lead to collisions during subsequent tool indexes or cycles.
Integrating G27 into a parts program is often paired with other boundary verification and safety commands, such as G22 stored stroke limit check on and G23 stored stroke limit check off, to define a complete safety zone for CNC axis travels.
Programmers and operators must maintain strict discipline regarding cutter compensation and tool offset states when programming G27. The control system executes the G27 verification at the programmed coordinates after applying any active tool offsets or tool length compensations. If cutter radius compensation (G41/G42) or tool length offsets (G43/G44 or active T-codes) are left active, the toolholder reference point remains physically displaced by the compensation vector. The machine will attempt to execute G27 at this offset position, fail to match the true reference point coordinates, and immediately halt automatic execution with a misposition alarm. Prior to calling G27, programmers must program a G40 cutter compensation cancel and clear all tool length and wear offsets. In contrast to Fanuc's G25 spindle speed fluctuation detection command which monitors spindle dynamics, G27 verifies mechanical axis positioning.
Command Structure
The G27 command is a Group 00 non-modal (one-shot) instruction that executes rapid axis positioning to the programmed coordinates before performing the referencing check. Programmed axes traverse at rapid traverse speed to the coordinates specified in the block. Once the axes reach the target position, the control's position loop comparator evaluates the machine's physical feedback against the reference coordinates stored in system variables. The check verifies only the axes programmed in the block; any omitted axes remain unchecked.
To accommodate different machine configurations, G27 utilizes different syntax structures. Lathe systems running under G-code System A use absolute (X, Z) or incremental (U, W) coordinates directly in the check block. Milling systems and machining centers specify absolute coordinate addresses (X, Y, Z). On Mitsubishi systems, the P parameter can be appended to designate which of the four reference positions to check. On Siemens controls, the system must switch to ISO Dialect mode using G291 before G27 can be parsed.
Syntax for Lathe/Turning Systems:
G27 X... Z... ; (Absolute Coordinates)
G27 U... W... ; (Incremental Coordinates)Syntax for Milling/Machining Systems:
G27 X... Y... Z... ;Syntax with Reference Position Selection (Mitsubishi):
G27 X... Z... P... ; (P1 for 1st, P2 for 2nd, P3 for 3rd, P4 for 4th reference position)Parameter Specifications:
| Address / Parameter | Description | Applicable Brands |
|---|---|---|
| X, Y, Z | Absolute coordinate values for target axes checks. | Fanuc, Siemens, Mitsubishi |
| U, W | Incremental coordinate values for target axes checks (System A). | Fanuc, Mitsubishi |
| P | Check number selecting the reference position (P1 to P4). Default is P1. | Mitsubishi |
Brand Applications
Fanuc
Fanuc controls execute G27 as a native Group 00 preparatory command that compares coordinates directly at the kernel level. Setup parameters like Parameter 3401 Bits 7 and 6 dictate whether the coordinates are processed using G-code System A, B, or C. If coordinates match, the control panel status LEDs light up.
Programmers must cancel compensations using G40 and Txx00 in the same block. For example, G27 G40 X7.85 Z2.0 T0400 M09 ; checks the absolute reference point of X and Z axes while canceling tool nose radius compensation and tool offsets.
| System Category | Identifier / Command | Application Detail |
|---|---|---|
| Parameters | Parameter No. 3401 Bit 7 (GSC) & Bit 6 (GSB) | Selects the active G-code system (A, B, or C) for coordinate interpretation. |
| Parameters | Parameter No. 3402 Bit 6 (CLR) | Determines if Group 00 modal G-codes return to clear states on reset. |
| Parameters | Parameter No. 1401 Bit 1 (LRP) | Determines if rapid traverse motion during G27 uses linear or non-linear interpolation. |
| Alarms | Alarm PS0187 | Illegal command triggered if G27 is executed during scaling (G51), mirror image (G51.1), or rotation (G68). |
| Alarms | Alarm PS0010 | Improper G-code alarm indicating the G27 function option is not configured on the control. |
| Versions | Modern (30i/31i/32i-B Plus) vs. Older | Modern series allow mixed absolute/incremental input. Older controls (Series 10/11/15) require strict integer coordinate formatting without decimal points. |
Warning: Using incremental addresses U and W in G27 blocks will accumulate rounding errors over repeated cycles, causing coordinate drift that can trigger false misposition halts.
Siemens
Siemens controls process G27 using an ISO Dialect wrapper. Under the hood, SINUMERIK does not run a kernel-level command; instead, it executes a background macro program named cycle328.spf. This macro uses MD 34100 to define the physical coordinate positions of the reference points.
To execute the check, the control must be placed in ISO Dialect mode using G291. For example, programming G27 X150.0 Z50.0 ; will check the reference coordinates of the X and Z axes using the cycle328.spf macro.
| System Category | Identifier / Command | Application Detail |
|---|---|---|
| Parameters | MD 34100 $_MA_REFP_SET_POS | Defines reference coordinate values for points 1 to 4 (index 0 to 3). |
| Parameters | MD 20150 $MC_GCODE_RESET_VALUES | Channel-specific machine data defining default G-code group states at reset. |
| Parameters | MD 10240 $MN_SCALING_SYSTEM_IS_METRIC | Determines if scaling system is metric (G21) or inch (G20). |
| Alarms | Alarm 61816 | Axes not on reference point alarm that halts automatic cycle mode. |
| Alarms | Alarm 61811 | ISO axis identifier not permitted during G27 check block execution. |
| Alarms | Alarm 61804 | Programmed intermediate position exceeds the physical reference point boundaries. |
| Alarms | Alarm 61803 | Programmed axis is not configured or available at the control system. |
| Versions | SINUMERIK 802D sl vs. 840D sl | 802D sl has write-protected channel G-code reset variables, while 840D sl allows full modification. |
Warning: Ensure that active coordinate transformations are fully deactivated using TRAFOOF before G27 execution, as unresolved transformations will cause cycle328.spf to fail and trigger Alarm 61803.
Mitsubishi
Mitsubishi CNC systems process G27 as a Group 00 unmodal instruction linked directly to the PLC. The controller uses axis-specific parameter #2037 to store the reference coordinate offsets from the machine zero. Once coordinates are matched, the system outputs a zero point arrival signal.
Programmers can specify which of the four reference positions to check using the P address. For example, G27 X100. Z50. P1 ; checks the primary reference position, while G27 Z250. P2 ; checks the second position.
| System Category | Identifier / Command | Application Detail |
|---|---|---|
| Parameters | Parameter #2037 G53ofs | Axis-specific reference coordinate offsets for reference points 1 to 4. |
| Parameters | Parameter #1091 Ignore middle point | Determines if the intermediate point is ignored during motion. |
| Parameters | Parameter #1279 ext15/bit6 | Enables or disables single block stop at intermediate positions. |
| Alarms | Verification Failure | Halts execution and suppresses the zero point arrival signal if the axis fails the check. |
| Alarms | Program Error P951 | Triggered if G27 is executed while simple inclined surface control (G176) is active. |
| Alarms | Program Error P942 | Triggered if G27 is executed while simple tool center point control (G174) is active. |
| Alarms | Program Error P45 | Triggered if G27 and a 3D coordinate conversion command (G68.1/G69.1) are in the same block. |
| Versions | M800/M80 Series vs. C80 | M800/M80 checks up to four reference points via P. C80 has command clashing where G26 represents the Machining Interruption retract sequence, but G27 remains identical. |
Warning: The Mitsubishi controller builds a motion deceleration check directly into the G27 command, resulting in a cycle time loss of approximately one to three seconds for each check block.
Brand Comparison
| Feature / Attribute | Fanuc | Siemens | Mitsubishi |
|---|---|---|---|
| Implementation Type | Native kernel-level unmodal command. | Scripted cycle macro (cycle328.spf) mapped to Group 00 in ISO Dialect mode. | Native kernel-level unmodal command. |
| Verification Scope | Checks 1st reference position (primary machine zero) only. | Checks reference coordinates defined in axis setting data. | Checks 1st, 2nd, 3rd, or 4th reference position via P1-P4 address. Defaults to 1st reference position. |
| Diagnostic Display | Status LEDs on operator panel light up simultaneously for successful axes. | Control screen pops up Alarm 61816 "Axes not on reference point" and stops execution. | Displays coordinate verification one axis at a time on screen starting from final axis. |
| Command Clash (G26) | Spindle Speed Fluctuation Detection ON. | Upper Working Area/Spindle Speed Limit (native Siemens Group 03 modal). | Machining Interruption tool retract cycle (specifically C80 series). |
Technical Analysis
The underlying architecture of CNC controls dictates how G27 reference return checking is executed and integrated into system diagnostics. On Fanuc and Mitsubishi controls, G27 is evaluated directly in the motion kernel as a low-level, non-modal preparatory command. When executed, these systems communicate directly with the axis servo loops and drive physical outputs. Fanuc illuminates dedicated hardware status LEDs on the operator panel, while Mitsubishi outputs a zero point arrival signal to the PLC. In contrast, Siemens SINUMERIK controls rely on a cycle-based wrapper. The G27 command is translated into a background macro program named cycle328.spf, which temporarily disables HMI updates using DISPLOF to hide Siemens-native blocks from the operator, executes the approach, and evaluates coordinate offsets in software before generating an Alarm 61816 if axes do not lie on the reference point.
Furthermore, command versatility differs between systems. Mitsubishi controls natively expand the G27 syntax by supporting the P parameter (values P1 to P4) to check up to four independent reference points configured under parameter #2037. Fanuc and Siemens controls typically restrict G27 to checking the primary machine zero reference coordinates.
Another critical operational difference lies in brand-specific command clashes involving the G26 code. In Fanuc environments, G26 controls Spindle Speed Fluctuation Detection. In Mitsubishi C80 systems, G26 represents a Machining Interruption retract cycle. In Siemens controls, G26 functions as a modal working area and spindle speed ceiling. Programmers must exercise caution when transferring G-code programs between machines, as executing a Fanuc program containing G26 on a Mitsubishi control will command a physical axis retraction instead of spindle monitoring, resulting in a turret crash.
Program Examples
The following example defines the reference position return check coordinates for X and Z axes on a Fanuc control:
G90 G40 G49 T0100 ; Cancel cutter compensation, tool length offsets, and clear active tool offsets
G27 X100.0 Z50.0 ; Execute rapid traverse to X100.0 Z50.0 and check primary reference position
M30 ; Program end and resetdry run verification:
Perform a dry run with the spindle stopped and no workpiece in the chuck. Manually reference all machine axes to establish machine zero before running the check. Execute the block. The axes must traverse at rapid speed to coordinate position X100.0 Z50.0. Upon arrival, verify that the physical reference position indicator LEDs on the operator panel illuminate. If the axes stop and the check fails, the control will halt automatic cycle execution, turn off the Cycle Start LED, and generate a misposition alarm.
The following example defines the reference position check coordinates for X and Z axes on a Siemens control:
G291 ; Switch control to ISO Dialect programming mode
G40 G49 ; Cancel cutter compensation and active tool length compensation
G27 X150.0 Z50.0 ; Traverse axes to coordinates and execute referencing check via cycle328.spf
G290 ; Switch back to native Siemens programming mode
M30 ; Program enddry run verification:
Confirm that the control's ISO language option (MD 18800) is enabled. Ensure active frames and mirror coordinates are cleared. Execute the block with the dry run switch active and feedrate override set to low. The machine will branch into cycle328.spf under the hood, temporarily freezing the active block display. The axes must traverse to X150.0 Z50.0. If the physical axes fail to match the reference coordinates configured in MD 34100 $_MA_REFP_SET_POS, the control must immediately trigger Alarm 61816 'Axes not on reference point' and halt automatic mode.
The following example defines the reference position check coordinates for X and Z axes on a Mitsubishi control, selecting the 2nd reference point:
G40 T0300 ; Cancel tool nose radius compensation and clear tool offsets
G27 X120. Z80. P2 ; Rapid-traverse to coordinates and check alignment with the 2nd reference position
M30 ; Program enddry run verification:
Configure the reference offset parameter #2037 G53ofs for the 2nd reference position. Execute the block. The axes must move at rapid traverse to the programmed coordinate positions. Verify that the screen display sequentially shows coordinate verification one axis at a time, starting from the final axis. Upon successful verification of the 2nd reference position, confirm that the control outputs the zero point arrival signal to the PLC and displays `#2` next to the axis labels.
Error Analysis
| Brand | Alarm Code | Trigger Condition | Operator Symptom | Root Cause / Fix |
|---|---|---|---|---|
| Fanuc | Alarm PS0187 | G27 command executed while coordinate scaling (G51), mirroring (G51.1), or coordinate system rotation (G68) modal states are active. | Cycle stops immediately, status screen displays Alarm PS0187, and axis motion is prevented. | Deactivate scaling (G50), mirroring (G50.1), or rotation (G69) in a preceding block prior to calling G27. |
| Fanuc | Alarm PS0010 | G27 is programmed but the physical reference return check option is not enabled in the parameters. | Halt of execution and display of "IMPROPER G-CODE" alarm message. | Verify machine option parameters and ensure the G27 function option is configured and licensed. |
| Siemens | Alarm 61816 | Programmed axis does not lie exactly on the configured reference point during G27 execution. | Automatic mode is interrupted, cycle execution halts, and the screen displays "Axes not on reference point". | Perform machine axis homing to recalibrate encoders, adjust coordinates, or reset reference status. |
| Siemens | Alarm 61803 | The axis specified in the G27 command block is not configured or available in the machine data. | Cycle execution halts with "Programmed axis not available" alarm during macro cycle cycle328.spf execution. | Correct the axis identifier address syntax in the G27 block to match active geometry axes. |
| Mitsubishi | Verification Failure | Programmed target coordinates are reached but the axis fails to align with the selected reference point (P1 to P4). | Automatic execution is halted, zero point arrival signal is suppressed, and Cycle Start LED turns off. | Verify parameter #2037 coordinate settings, cancel active compensations, and re-run check. |
| Mitsubishi | Program Error P951 | G27 is commanded while the control is in the simple inclined surface control (G176) modal state. | Automatic program execution terminates immediately with program error on the screen. | Cancel simple inclined surface control (G176) before executing the reference check block. |
Application Note
A catastrophic turret crash into the chuck jaws, ruined spindle bearings, and a scrapped workpiece will occur if operators run repetitive machining loops using incremental G27 commands (such as U and W) without periodic absolute coordinates reset. When incremental addresses are processed under G-code System A, minor rounding errors accumulate within the control's motion registers over consecutive tool cycles. Over a long production run, this cumulative drift shifts the toolpath path envelope until it exceeds the physical reference check tolerance. To maintain coordinate integrity and prevent false halts, programmers should pair G27 checks with absolute coordinate system calls, and ensure that tool offsets are canceled using G40 and Txx00 in the check block. If cutter compensations remain active, the toolholder reference point is displaced by the offset vector, causing the check to fail and halt execution with a verification alarm.
Related Command Network
- G22: Activates the stored stroke limit check function to establish a software safety boundary.
- G23: Deactivates the stored stroke limit check function, allowing axes to travel outside the restricted zone.
- G25: Deselects the spindle speed fluctuation detection function in Fanuc controls, or sets the lower working area limits in Siemens controls.
G49/Txx00: Cancels tool length compensation and clears tool offsets to allow correct machine zero alignment.G291/G290: Switches the SINUMERIK control between ISO Dialect mode (enabling G27 parsing) and native Siemens programming mode.
Conclusion
Implementing G27 reference position return checks provides an automated safeguard against coordinate drift and axis positioning failures. Programmers protect machine spindles, turrets, and workpiece fixtures by placing checks prior to critical tool changes. Standardizing G27 check blocks with canceled tool compensation codes (G40, G49, Txx00) guarantees collision-free execution and maintains production throughput on the shop floor.
FAQ
Why does G27 trigger a misposition alarm even if the axes are physically at machine zero?
This failure occurs when tool length compensation (G43/G44) or cutter radius compensation (G41/G42) remains active in the control buffer during the check. The control applies the active offset vectors to the coordinate comparison, resulting in a mismatch between the offset target and the actual machine zero coordinates. To resolve this, always program G40 and Txx00 (or G49) in the same block as G27 to fully cancel all active offsets before executing the reference check.
How can programmers check secondary or tertiary reference positions using G27?
Mitsubishi controls natively support checking multiple reference positions using the P address command (P1 to P4) in the G27 block, corresponding to settings in parameter #2037. Fanuc and Siemens controls typically restrict G27 to checking the primary machine zero, requiring the use of G30 commands if secondary reference positions must be approached. For multi-point verification on Mitsubishi controls, program the target coordinate followed by the P-address index (e.g., P2) to check the corresponding reference point.
What causes Siemens controls to trigger Alarm 61803 during a G27 check block?
Siemens SINUMERIK controls run the G27 command using the cycle328.spf macro file, which automatically evaluates active coordinates. If there are active coordinate transformations or axis rotations that cannot be cleared by the TRAFOOF command inside the macro, cycle328.spf fails and outputs Alarm 61803. To prevent this macro failure, program a TRAFOOF command and deselect active coordinate transformations before switching to ISO Dialect mode via G291 to run the G27 block.
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.