G22 Stored Stroke Limit Check ON G-Code Command: CNC Programming
Program G22 Stored Stroke Limit Check ON for Fanuc, Siemens, and Mitsubishi. Prevent collisions and spindle damage with safety boundary parameters.
Introduction
An uncoordinated manual intervention or an unexpected coordinate offset shift during active compensation modes poses a critical production risk. When a tool carrier travels beyond its intended spatial boundaries at rapid traverse, the rotating tool turret can crash directly into the workpiece chuck jaws, tailstock body, or spindle. This severe impact results in a fractured machine spindle, damaged workholding components, and a ruined scrap part that halts the entire shop floor.
To mitigate these physical collision risks, CNC programmers utilize stored stroke limit checks and working area limitations. These functions establish virtual entry-inhibition zones around critical workholding equipment and raw stock. When activated, the control system monitors tool positions in real-time, enforcing automatic deceleration and halting axis travel before the tool tip or toolholder can violate the protected physical boundaries.
Technical Summary
| Feature | Technical Specification |
|---|---|
| Command Codes | G22, G23, G22.1, G23.1, G25, G26, WALIMON, WALIMOF, WALCS1 to WALCS10 |
| Modal Group | Group 04 (Fanuc/Mitsubishi Barrier Check / Stored Stroke Limit), Group 03 (Siemens Working Area Limitation) |
| Supported Brands | Fanuc, Siemens, Mitsubishi |
| Critical Parameters | Fanuc Parameter 3402 Bit 7, Siemens MD10604, Mitsubishi Parameters #8202, #8204, #8205, #8300, #12057 |
| Main Constraint | Boundary checks are subject to tool length offset status (checking tool tip versus toolholder reference point) and interpreter look-ahead pre-read limits. |
Quick Read
- Program barrier activation and deactivation commands (G22/G23, WALIMON/WALIMOF) in independent blocks to avoid syntax halts.
- Ensure tool length offsets are active before boundary approaches; inactive offsets shift checks to the toolholder, risking chuck impacts.
- Restrict non-motion blocks to fewer than N-2 steps under radius compensation to avoid look-ahead buffer overruns and contour gouging.
- Monitor PLC signals such as Fanuc *TSB to ensure tailstock safety barriers have not been programmatically bypassed during automatic cycles.
- Apply G23 to temporarily disable boundaries when recovering a tool that is trapped inside a prohibited stored stroke zone.
- Establish coordinate system boundaries relative to the active plane (e.g., using G19 YZ plane selection) to match physical fixtures.
Basic Concepts
Stored stroke limit checks restrict the physical traversing envelope of the cutting tool to establish virtual entry-inhibition zones around critical workholding devices and raw stock. By defining the physical boundaries of a workpiece clamped in the chuck or supported by a tailstock, the control system prevents the tool nose from entering these protected envelopes, automatically halting axis movement at the safety boundary. This software-based barrier acts as an electronic guardrail, protecting the CNC machine from human programming mistakes and coordinate offset errors.
Unlike hardware limit switches that trigger only when an axis physically contacts a microswitch, stored stroke limits are monitored continuously by the CNC interpreter. The system evaluates current coordinates against configured boundary parameters. If the system detects a trajectory breach, it decelerates all axes to a stop before a physical collision occurs. This safety envelope can be toggled on or off programmatically during execution to allow tools to enter or exit specific regions, such as during automated part unloading or turret swiveling.
Command Structure
The command structure for safety boundaries relies on specific preparatory codes that must be programmed in independent blocks. The G22 command initiates the stored stroke limit check, establishing the chuck and tailstock boundaries as active entry-inhibition zones. The G23 command deactivates the limit check, canceling the active boundaries to allow axis movement into the protected envelopes for tool changes or raw stock loading.
Depending on the manufacturer and the active coordinate system, boundaries can be defined dynamically via G-code parameters or pre-loaded system variables. When programming boundaries directly, absolute coordinate addresses define the positive and negative limits of the protected envelope. The control system evaluates these coordinate values against the active G-code state, adjusting the internal verification parameters whether the machine is operating under G20 inch input or G21 metric input standards.
G-Code Syntax
; Fanuc Syntax G22 ; G23 ; G22 Xp_ ;; Siemens Syntax G25 X_ Y_ Z_ ; G26 X_ Y_ Z_ ; WALIMON ; WALIMOF ; WALCS1 ; WALCS0 ;
; Mitsubishi Syntax G22 ; G23 ; G22 X_ Z_ C_ I_ J_ K_ ; G22.1 X_ Y_ Z_ I_ J_ K_ ;
Command Parameters
| Brand | Parameter | Description | Value Range |
|---|---|---|---|
| Fanuc | No. 3402 Bit 7 (G23) | Sets the default status of stored stroke limits at power-on. | 0 = G22 ON, 1 = G23 OFF |
| Fanuc | No. 3401 Bit 7 (GSC) | Configures active G-code system selections. | 0 or 1 |
| Fanuc | No. 19625 | Defines the pre-read look-ahead buffer size in offset mode. | Positive integers |
| Fanuc | No. 5040 Bit 3 (TCT) | Selects the tool length compensation shift type. | 0 or 1 |
| Fanuc | No. 0001 Bit 1 (FCV) | Selects standard or legacy Series 15 G-code program translation. | 0 or 1 |
| Siemens | MD10604 | Geometry axis change mode (limit behavior during axis switch). | 0 = deactivate limit, 1 = retain limit |
| Siemens | MD10710 | Determines if programmed G25/G26 values persist after reset. | Parameter table values |
| Siemens | $AC_WORKAREA_CS_LIMIT_PLUS | Positive boundary coordinate value for WCS limit groups. | Coordinate values |
| Siemens | $AC_WORKAREA_CS_LIMIT_MINUS | Negative boundary coordinate value for WCS limit groups. | Coordinate values |
| Mitsubishi | #8202 OT-CHECK OFF | Axis-independent overtravel check function active state. | 0 = active, 1 = inactive |
| Mitsubishi | #8204 OT-CHECK-N | Negative coordinate boundary limit for the axis. | ±199999998 in 0.5µm increments |
| Mitsubishi | #8205 OT-CHECK-P | Positive coordinate boundary limit for the axis. | ±199999998 in 0.5µm increments |
| Mitsubishi | #8300 (P0) X | Basic workpiece center machine coordinate (radius value) for barriers. | ±199999998 in 0.5µm increments |
| Mitsubishi | #12057 OT_prechkON | Enables stroke check before travel in stored stroke limit area. | 0 = OFF, 1 = ON |
Brand Applications
Fanuc
Fanuc controls utilize stored stroke limit checks to establish a virtual safety zone around workpiece chucks and tailstocks. The system initialization defaults are governed by Parameter No. 3402 Bit 7, which dictates whether G22 is active at power-on. The controller also references Parameter No. 3401 Bit 7 to interpret axis designations under the active G-code system.
Programmers activate the stored stroke check by commanding G22 in an independent block. To disable boundaries for tool changes or parts catcher operations, a standalone G23 command is programmed. During active tool nose compensation, the area coordinates can be specified using G22 Xp_ where Xp represents the coordinate axis.
| Category | Element | Details |
|---|---|---|
| Parameters | No. 3402 Bit 7, No. 3401 Bit 7, No. 19625, No. 5040 Bit 3, No. 0001 Bit 1 | Configures power-on default limits, G-code systems, look-ahead buffer sizes, tool compensation shift types, and legacy program translation. |
| Alarms | PS0368, PS0011, PS0067, PS0325 | Triggers for active offset parameter modification, zero commanded feedrate, missing repetitive cycle sequence numbers, and unauthorized shape definition commands. |
| Versions | Series 15 vs. Series 16i/18i/21i | Series 15 supports legacy program translation (FCV = 1) with differing parameters. Series 16i/18i/21i use distinct pocket roughing and single-axis turning retract logic. |
Warning: Programmers must closely monitor the PMC tailstock barrier selection signal *TSB. If the PMC outputs a *TSB value of 1, the tailstock barrier is deactivated even if G22 is active, which can result in a physical crash if the tailstock is moved under auxiliary commands.
Siemens
Siemens SINUMERIK controls manage axis boundaries in the Basic Coordinate System (BCS) and Workpiece Coordinate System (WCS) using machine data values. Geometry axis switches and zero-offset resets are configured via machine data MD10604 and MD10710.
Lower and upper boundary limits are defined in separate NC blocks using G25 and G26 commands respectively. These boundaries are activated globally via WALIMON and deactivated via WALIMOF. For coordinate-specific limits, WALCS1 through WALCS10 can be programmed to select up to ten WCS-based limitation groups, while WALCS0 cancels them.
| Category | Element | Details |
|---|---|---|
| Parameters | MD10604, MD10710, $AC_WORKAREA_CS_LIMIT_PLUS, $AC_WORKAREA_CS_LIMIT_MINUS | Controls limit behavior during geometry axis switches, boundary retention after reset, and WCS-specific boundary coordinate values. |
| Alarms | Alarm 22280, Alarm 14800, Alarm 12080 | Triggers for short thread run-in acceleration overload, zero or omitted path feedrate, and unknown G-code (like G22/G23) under ISO Dialect Mode. |
| Versions | SINUMERIK 802D sl vs. 840D sl | On 802D sl, MD10604 and MD22515 are read-only and locked by the manufacturer; multi-edge turning commands G51.2 and G50.2 are unavailable, unlike on 840D sl. |
Warning: Toggling working area limitations when tool length compensation is inactive causes the check reference to shift from the tool tip to the toolholder reference point. This offset displacement can cause the tool turret to cross physical boundaries and crash during rapid movements.
Mitsubishi
Mitsubishi CNC systems use stored stroke limits to establish entry-prohibited ranges for the machine axes. The axes boundaries are configured using Parameter #8204 for the negative-side limits and Parameter #8205 for the positive-side limits.
The chuck and tailstock barriers are enabled by G22 and disabled by G23, programmed alone in independent blocks. Stored stroke limit II is activated by commanding G22 X_ Z_ C_ I_ J_ K_ to specify absolute boundary coordinates. On machining centers, G22.1 activates travel checks while G23.1 cancels them.
| Category | Element | Details |
|---|---|---|
| Parameters | #8202, #8300 (P0) X, #12057, #8179, #12058 | Manages independent overtravel check states, workpiece center coordinate center reference, path pre-checking, and path evaluation logic. |
| Alarms | Program Error P452, Program Error P451, Operation Error M01 0007 | Triggers for boundary crossing along the path trajectory, missing pre-check options (G10 L70 writes), and non-targeted axis movements through prohibited zones. |
| Versions | Lathe L-system vs. Machining M-system | Under the M-system (M2/M0 format), G22 and G23 act as subprogram calls and returns. Safe travel stroke checks must be performed using G22.1 and G23.1 instead. |
Warning: If positive and negative boundary parameters are set to the same value (such as 0), the controller locks out all travel on that axis. Operators must complete all axis reference position returns before verifying boundaries to validate barriers.
Brand Comparison
| Comparison Topic | Fanuc | Siemens | Mitsubishi |
|---|---|---|---|
| Activation Command | G22 ; | WALIMON (for BCS limits), WALCS1-10 | G22 ; (barriers), G22 X_ Z_ C_ I_ J_ K_ ; (limit II), G22.1 (M-system) |
| Deactivation Command | G23 ; | WALIMOF (for BCS limits), WALCS0 | G23 ; (barriers/limit II), G23.1 (M-system) |
| Reference Origin | Machine-coordinate-based boundaries | WCS/SZS-based groups (WALCS1-10) or BCS-based limits (G25/G26) | Machine-coordinate-based barriers or custom stored stroke limit II coordinates |
| Path Trajectory Evaluation | Checks endpoint (standard overtravel check) | Checks tool tip (standard working area check) | Full path trajectory calculation (checking intersections, not just endpoints, via #12057 and #8179) |
| Look-Ahead Buffering | Limited to N-2 blocks under active radius comp (otherwise overcuts/gouges) | Completely decoupled; does not affect pre-read buffers | Decoupled in L-system, but subject to block-splitting syntax issues in M-system |
| PMC/PLC Integration | Tailstock barrier linked dynamically to *TSB PMC signal | Manual G-codes and parameter settings | Parameter-driven, integrated with axis name switching (G111 / G140) |
Technical Analysis
A comparative analysis of safety boundaries reveals fundamental differences in how Fanuc, Siemens, and Mitsubishi interpret and execute coordinate constraints. Fanuc controls integrate G22 safety barriers directly with the programmable machine controller (PMC) interface signals. By linking the tailstock barrier to the PMC signal *TSB, the PLC program can programmatically enable or disable the safety zone on-the-fly. This allows the tailstock to advance or retract during parts catcher cycles without triggering coordinate alarms. In contrast, Siemens and Mitsubishi do not utilize this direct PMC interface signal linkage for routine G22 operations, relying instead on explicit G-code states or manual parameter configuration.
The boundary checking method represents another major architectural variance. Fanuc and Siemens evaluate limits primarily by assessing the final programmed endpoint of a move. Mitsubishi, however, implements a path-passing stroke check when machine parameters #12057 and #8179 are enabled. Rather than checking only the endpoint coordinate, the Mitsubishi interpreter calculates the entire toolpath trajectory during rapid traverse (G00) and cutting interpolation (G01/G02/G03). If the path vector intersects a prohibited boundary at any point, the controller halts travel and triggers Program Error P452 before the axis starts moving.
Interpreter look-ahead handling also differentiates these systems. Fanuc imposes look-ahead pre-read limits under active cutter radius compensation, where programming more than N-2 consecutive non-motion blocks (such as consecutive G22 area settings) exhausts the buffer. This preprocessor limitation forces the Fanuc system to generate perpendicular error vectors that gouge the profile. Siemens avoids this preprocessor buffer constraint entirely by managing limits as system variables ($AC_WORKAREA_CS_LIMIT_PLUS and $AC_WORKAREA_CS_LIMIT_MINUS) and G-group 3 preparatory commands (WALIMON/WALIMOF) which do not occupy motion pre-read buffers.
Program Examples
Fanuc Example
O1001 ;
G28 U0 W0 ;
G54 ;
G22 ; ; Activate stored stroke limit check
G00 X100.0 Z50.0 ; ; Move to start position
T0101 ;
G01 Z-20.0 F0.2 ; ; Feed path near Chuck
G23 ; ; Deactivate limit check to permit chuck clearance
G00 X150.0 Z100.0 ; ; Retract to safe area
M30 ;Dry Run: The program starts by homing axes via G28 and selecting workpiece coordinates. Command G22 activates the safety boundaries around the chuck. The tool approaches to X100.0 Z50.0, then performs a linear cut to Z-20.0. When G23 is read, the controller disables stored stroke checks, permitting the turret to retract to X150.0 Z100.0 without triggering overtravel alarms when traversing close to the workholding equipment.
Siemens Example
N10 G291 ; ; Enter ISO Dialect Mode
N20 G54 ;
N30 G25 X-80.0 Z30.0 ; ; Define lower working area limits
N40 G26 X80.0 Z330.0 ; ; Define upper working area limits
N50 WALIMON ; ; Switch ON working area limitations
N60 T1 D1 ; ; Tool change and offset activation
N70 G00 X60.0 Z100.0 ; ; Rapid approach tool tip
N80 G01 Z-50.0 F0.15 ; ; Linear machining
N90 WALIMOF ; ; Switch OFF working area limitations
N100 G00 X100.0 Z350.0 ; ; Retract past upper limits
N110 M30 ;Dry Run: The control enters ISO Dialect Mode with G291 and establishes G54 coordinates. G25 and G26 specify the lower and upper limits in the Basic Coordinate System (BCS). WALIMON activates the safety limits. The tool executes rapid positioning and cuts to Z-50.0. The controller monitors the tool tip against limits. WALIMOF deactivates the working area limitation, allowing the tool to retract beyond the G26 limits (Z350.0) for a safe tool change without triggering Alarm 12080.
Mitsubishi Example
O2001 ;
G28 X0 Z0 ;
G54 ;
G22 X120.0 Z200.0 I-120.0 K-200.0 ; ; Activate stored stroke limit II
G00 X80.0 Z50.0 ; ; Approach workpiece
T101 ;
G01 Z-30.0 F0.2 ; ; Linear interpolation
G23 ; ; Cancel stored stroke limit II
G00 X150.0 Z100.0 ; ; Safe retraction
M30 ;Dry Run: The program initiates axis homing and coordinate system selection. The command G22 X120.0 Z200.0 I-120.0 K-200.0 specifies Stored Stroke Limit II boundaries (positive limits at X120/Z200, negative limits at I-120/K-200) and activates the check. The tool approaches and cuts. The controller evaluates the tool path trajectory against parameters #8204 and #8205. Finally, G23 cancels the limits, letting the tool retract to X150.0 Z100.0 without triggering program error P452.
Error Analysis
| Brand & Alarm Code | Trigger Condition | Operator Symptom | Root Cause / Fix |
|---|---|---|---|
| Fanuc PS0368 | Modifying Parameter No. 5040 Bit 3 (TCT) while coordinate offsets or tool nose radius compensations are active. | Execution halts instantly; screen displays Alarm PS0368. | Offsets are active during parameter write. Cancel all coordinate and radius offsets in G-code before modification. |
| Fanuc PS0011 | Programmed feedrate F exceeds maximum allowable cutting feedrate limit configured in machine parameters. | CNC halts feed execution with FEED ZERO (COMMAND) alarm. | F value in block exceeds parameters. Correct the feedrate command to within machine limits. |
| Siemens 12080 | Programmed unrecognized G-code (such as G22/G23) in ISO Dialect Mode (G291). | NC parser halts parsing; screen displays unknown G-code alarm. | ISO dialect scanner encountered unsupported G-code. Configure machine data $MC_EXTERN_FUNCTION_MASK Bit 3 to 0, or remove invalid codes. |
| Siemens 22280 | Axis acceleration required for programmed lead-in/lead-out path exceeds configured machine tolerances. | Execution halts with acceleration overload alarm. | Lead-in path is too short for the required acceleration. Program a longer run-in path or adjust acceleration settings. |
| Mitsubishi P452 | Commanded tool path passes through or terminates inside a prohibited stored stroke zone. | Overtravel alarm halts rapid or cutting axis travel. | The tool path vector intersects the software limit boundary. Reset the control, program G23 to invalidate the barrier, and safely retract the axes. |
| Mitsubishi P451 | Stroke check before travel parameters are enabled but the option is not provided on the control, or trying to write #12057 to 1 via G10 L70. | CNC displays P451 error at startup or during parameter write block execution. | Software lacks stroke pre-check options. Verify control software configuration or remove the G10 parameter write commands. |
Application Note
A hard collision resulting in a fractured spindle occurs when tool length compensation offsets are cleared during a geometry axis switchover. On Siemens controls, if machine data MD10604 is configured to 0, the active working area limitations are deactivated automatically during a geometry axis switch. When this occurs, and tool offsets are cleared (such as executing a tool change without applying the proper D-edge offset), the control shifts its envelope check from the tool tip to the toolholder reference point. During a rapid traverse approach (G00), the tool carrier can travel beyond intended spatial boundaries, crashing the turret directly into the workpiece chuck or raw stock.
To prevent this, programmers must coordinate boundary parameters with active offsets. On Mitsubishi controls, toggling G188 mid-run shifts the G-code mode from lathe format to machining center format. This shifting changes the interpretation of G22/G23 from Group 04 (Barrier check) to Group 00 (Subprogram call). If the programmer attempts to define safety zones using Lathe syntax under G188 Machining Center mode, the parser will split blocks like G23.1 X100.0 ; into two separate lines, executing the cancellation first and moving the tool unprotected. Operators must verify that all axis reference position returns are completed and checkpoints are configured in range "c" on the HMI to ensure Chuck barriers are validated before cutting.
Related Command Network
- G23: Deactivates stored stroke check boundaries to allow the tool to traverse into safety or tool change zones.
- G25 / G26: Defines the lower and upper working area limits in the basic coordinate system on Siemens controls.
- G22.1 / G23.1: Activates and deactivates the travel stroke check function before axis movement on Mitsubishi machining centers (M-system).
- G40 / G41 / G42: Controls cutter radius compensation, which interacts with look-ahead buffers during G22 execution.
Conclusion
Implementing stored stroke limits requires careful synchronization of coordinates, parameters, and tool offsets. Protecting the physical machine from catastrophic collisions demands that programmers verify look-ahead buffer sizes and always validate boundary statuses after tool changes. Ensuring safety barriers are active before rapid approaches remains the single most effective practice to eliminate scrap parts and machine downtime.
FAQ
Why does the CNC machine lock out all axis travel when G22 is activated
This travel lockout occurs when the positive and negative boundary parameters are set to the same value, such as 0, or if the prohibited zone is configured on the outside. To resolve this, operators must update Mitsubishi parameters #8204 and #8205 (or equivalent) to valid coordinate limits and perform axis homing to re-establish the reference origin.
Can I program G22/G23 in the same block as tool movement commands
No, programming G22 or G23 alongside motion coordinates or auxiliary M-codes violates format rules, causing the parser to halt with errors. Programmers must write G22 and G23 as standalone statements in independent blocks to ensure the interpreter activates or deactivates safety boundaries before the machine initiates travel.
Why did my tool turret crash into the chuck jaws even though G22 was active
This crash typically happens when tool length compensation is disabled, which forces the controller to evaluate the boundary check from the toolholder reference point instead of the tool tip. Operators must ensure that correct tool offsets are active in the program registers and verify boundaries using graphic check dry runs before running automated turning cycles.
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
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.
Siemens SINUMERIK G26 Upper Working Area & Spindle Speed Limit
Master the Siemens SINUMERIK G26 command for upper working area and spindle speed limits. Learn syntax, parameters like SD 43420, and alarms to avoid crashes.
G26 Spindle Speed Fluctuation Detection ON: CNC Programming Guide
Learn how to configure G26 on Fanuc, Siemens, and Mitsubishi CNC controls to prevent spindle speed fluctuations, set travel limits, and avoid tool crashes.
G25 Lower Working Area and Spindle Speed Limit: Siemens CNC
Master G25 lower working area and spindle speed limits on Siemens SINUMERIK controls. Avoid chuck collisions and configure safety parameter SD 43430.