Skip to main content
CNC.wiki

Fanuc Stored Stroke Limit Settings and G22/G23 G-Code Guide

Master Fanuc G22 and G23 stored stroke limit settings. Learn parameters 1320 and 1321 to define boundaries, prevent axis crashes, and clear Alarm 520.

Hakan Gündoğdu
Hakan Gündoğdu

CNC CARE Co-founder

Introduction

When a CNC machine tool is operating in automatic mode, a single programming error or axis drift can result in the turret plunging into a spinning chuck, leading to a catastrophic OVERTRAVEL (HARD) collision, major structural damage, and a ruined scrap part. In modern production environments, mechanical crash guards are not enough to prevent these expensive accidents. Properly setting and managing software-based boundaries is the first line of defense. By configuring virtual envelopes that define forbidden zones, machine operators and programmers can prevent the tool holder or spindle housing from colliding with physical obstacles like vise jaws, chucks, or clamps, thereby eliminating unplanned downtime and saving valuable workpieces.

Technical Summary

Technical SpecificationConfiguration Details
Command CodeG22, G23
Modal GroupModal (Group 14 or standard boundary checking)
BrandFanuc
Critical ParametersParameter 1320 (positive limit) and Parameter 1321 (negative limit)
Main ConstraintThe standard stored stroke limits 2 and 3 are completely disabled when the T-series Chuck and Tail Stock Barrier is active.

Quick Read

  • Coordinate Envelope: Define absolute positive boundaries in Parameter 1320 and negative boundaries in Parameter 1321.
  • Active Checking: Command G22 in the program to enable the stored stroke check, and G23 to deactivate boundary checks when necessary.
  • Initial Power-On: Configure Parameter 3402#7 (G23) to set the default state of stored stroke checks (ON or OFF) upon rebooting the machine.
  • Prevent Startup Crash: Set Parameter 1301#3 (OTA) to 0 to raise an immediate alarm at power-up if the axis starts inside a prohibited area, preventing wrong-direction jog crashes.
  • Auto-Clear Alarms: Set Parameter 1301#4 (OF1) to 1 to automatically clear soft overtravel alarms when the axis is jogged back into the safe area.
  • Chuck Barrier Override: Enable parameter 8134#1 (BAR) on T-series lathes to model the chuck and tailstock dimensions, which automatically disables standard stored stroke limits 2 and 3.

Basic Concepts

The practical programming effect of Fanuc's Stored Stroke Limit settings is the creation of absolute, highly customizable software boundaries that physically prevent the machine from crashing into its own castings, fixtures, or workholding devices. By configuring limits 1, 2, and 3, programmers can establish a layered defense. For example, Limit 1 is permanently mapped to the absolute machine coordinate extremes to prevent over-stroking the ball screws, while Limits 2 and 3 can be dynamically configured (using parameter 1300#0 OUT) to forbid the inside of a specific zone, perfectly wrapping a "no-fly zone" around a rotary table or a tall workpiece.

For T-series lathes, operators must watch for the unique interaction between these limits and the machine's workholding. If the Chuck and Tail Stock Barrier is enabled in the parameters, it explicitly overrides and disables stored stroke limits 2 and 3. The control instead uses parameters 1330 through 1348 to mathematically model the physical dimensions of the chuck, chuck claws, and tailstock. This prevents the turret from plunging into the spinning chuck, thereby avoiding a catastrophic OVERTRAVEL (HARD) collision and preventing a ruined scrap part.

Command Structure

The syntax structure for stored stroke limits relies on G22 and G23 commands. Commands can be written dynamically to establish a workspace boundary, or they can be written as simple modal switches to activate parameters already defined in the system. The boundary settings can be verified on the diagnostic screen of the controller.

When using G22 with coordinates, the programmer defines the boundary box. When G22 is used as a standalone block, it turns on standard checking. To execute G-code programs safely, programmers must verify whether limits are active at boot, which depends on the configuration of parameter 3402. For detailed information on configuring CNC system parameters, see fanuc-parameters-and-pwe.

G22 X500.0 Y500.0 Z0.0 I-500.0 J-500.0 K-500.0 ; (Turns the stored stroke check on and sets the boundary limits)
G22 ; (Turns the stored stroke check on using the boundaries already defined in machine parameters)
G23 ; (Turns the stored stroke check off)
Parameter / BitDescriptionSettings / Value Range
Parameter 1320Stored stroke limit 1 (positive direction coordinate for each axis)-99999999 to 99999999 (0.001 mm)
Parameter 1321Stored stroke limit 1 (negative direction coordinate for each axis)-99999999 to 99999999 (0.001 mm)
Parameter 1300#0 (OUT)Inhibition area for stored stroke checks 2 and 30 = inside area forbidden, 1 = outside area forbidden
Parameter 1300#7 (BFA)Alarm trigger timing0 = alarm after boundary exceeded, 1 = alarm before limit exceeded
Parameter 1301#3 (OTA)Alarm trigger behavior when inside prohibited area at power-up0 = immediate alarm, 1 = no alarm before movement
Parameter 1301#4 (OF1)Alarm clearing behavior when jogging axis back to allowed range0 = alarm not canceled before RESET, 1 = alarm canceled automatically
Parameter 3402#7 (G23)Default stored stroke check state at power-on0 = G22 mode (ON), 1 = G23 mode (OFF)
Parameter 1301#2 (NPC)Ignored during automatic tool measurement (M) or tool compensation (T)0 = standard check, 1 = ignore check during G37 cycle
Parameter 8134#1 (BAR)Chuck and Tail Stock Barrier enable switch (T-series only)0 = disabled, 1 = enabled
Parameters 1330 to 1348T-series lathe chuck, chuck claws, and tailstock physical dimensionsMachine-specific boundaries

Brand Applications

Fanuc

On Fanuc CNC systems, stored stroke limits are controlled through system parameters to establish secure machine coordinates. These limits are primarily configured using Parameter 1320 and Parameter 1321, which establish the positive and negative absolute boundary values for each axis.

To control these software limits dynamically in a G-code program, operators can command G22 to turn on checking or G23 to turn off checking.

CategorySystem Setting / CodeDescription and Details
Key ParametersParameter 1320 & Parameter 1321Defines positive and negative software overtravel limit coordinates for each axis.
Startup StatusParameter 3402#7Determines if stored stroke limits default to ON (G22) or OFF (G23) at boot.
Alarm CodeAlarm 520 (OVERTRAVEL (SOFT))Triggered when the machine coordinates touch or exceed the active software boundary.
Hardware AlarmOT00506 (OVERTRAVEL (HARD))Triggered when hardware limit switches are physically hit by the machine axes.
M-Series vs T-SeriesParameter 1301#2 (NPC)M-series ignores stroke check during G37 tool length measurement, while T-series ignores it during G37 tool compensation.

Warning: Commanding G23 disables stored stroke checking entirely. If the G23 command is executed and not followed by a G22, the tool can collide with workholding or fixtures without generating a software overtravel alarm.

Brand Comparison

Feature / SettingFeature / Setting DescriptionFanuc Series 16i / 18i / 21iFanuc Series 0i (0i-C / 0i-D / 0i-F)Fanuc Series 15i (High-End)
Limit 1 Parameter AddressesParameter registers for positive/negative limitsParameters 1320 (positive) and 1321 (negative)Parameters 1320 (positive) and 1321 (negative)Parameters 5220 (positive) and 5221 (negative)
Number of Stored Stroke LimitsSupported sets of stored stroke limitsSupports up to 4 sets of stored stroke limits (Limits 1 to 4)Supports up to 3 sets of stored stroke limits (Limits 1 to 3 standard)Supports up to 8 sets of stored stroke limits (Limits 1 to 8 customizable)
Chuck and Tailstock Barrier IntegrationPhysical collision model supportSupported via parameters 1330 to 1348 with BAR bit 8134#1Supported via parameters 1330 to 1348 with BAR bit 8134#1Supported via high-end parameter grouping and custom builder interface

Technical Analysis

Fanuc distinguishes its software stroke limit architecture from other brands through highly advanced predictive stopping calculations and dynamic alarm handling. First, Fanuc does not merely wait for a boundary to be crossed to kill the servos; if parameter 1300#7 (BFA) is enabled, the CNC mathematically looks ahead at the current feedrate F and dynamically halts the tool exactly F / 7500 mm short of or ahead of the boundary, guaranteeing the tool never actually touches the forbidden zone regardless of how fast it is traveling. Second, Fanuc allows builders to map external PLC signals directly to the stroke limits (via the EXLM signal or +EXL1/-EXL1 inputs). This allows the machine to instantaneously swap between different stroke limit profiles based purely on the physical state of the machine—such as whether a specific pallet is loaded or a door is open—without requiring any G-code intervention. Finally, Fanuc integrates an automatic alarm cancellation feature (OF1); instead of forcing the operator to reach for the RESET button and wipe out the active modal G-codes after hitting a soft limit, jogging the axis back into the safe area automatically extinguishes the alarm and restores normal operation seamlessly.

Program Examples

G22 X500.0 Y500.0 Z0.0 I-500.0 J-500.0 K-500.0 ; (Activate stored stroke check and define boundary coordinates)
G22 ; (Activate stored stroke check using boundaries already defined in machine parameters)
G23 ; (Deactivate stored stroke check, allowing full axis travel beyond software boundaries)

dry run

Before running programs that utilize custom G22 stored stroke limits, perform a dry run. Clear the workspace of workpieces and retract the tool turret or spindle to the machine reference point. Execute the boundary-defining block in single-block mode. Once G22 is active, jog the axis slowly toward the configured boundary. The machine must generate Alarm 520 (OVERTRAVEL) and halt motion before the tool can strike any fixtures. Jog the axis in the opposite direction to verify if the alarm automatically clears under the active Parameter 1301#4 (OF1) setting.

Error Analysis

Alarm / Error CodeTrigger ConditionOperator SymptomRoot Cause & Resolution
Fanuc Alarm 520 (OVERTRAVEL (SOFT))The current machine coordinates reach or exceed the software stored stroke limit boundary.Automatic operation halts instantly, and all axes stop. An overtravel soft alarm message is displayed.The tool traveled beyond the virtual envelope. Jog the axis back into the allowed range and press RESET. If Parameter 1301#4 (OF1) is 1 and Parameter 1300#7 (BFA) is 0, the alarm clears automatically without RESET.
Fanuc Alarm OT00506 (OVERTRAVEL (HARD))The axis moves past the software limit and physically strikes the hardware limit switches.The emergency stop circuit is tripped, and servo power is instantly cut off.A hardware bypass occurred due to limit disable (G23) or misconfigured soft boundaries. Manually move the axis off the limit switch using the OT release override button.
Fanuc Alarm PS0327Canned cycles (like multiple repetitive roughing cycles) are commanded when scaling or mirror coordinates conflict with the stored stroke limits.The program halts immediately with a G-code parameter or formatting error screen.A mathematical conflict exists between active coordinates and stroke limits. Verify program dimensions, check coordinate scaling factors, and ensure limits match target coordinates.

Application Note

A turret plunging into a spinning chuck, resulting in a ruined scrap part and catastrophic overtravel damage, occurs when operators fail to recognize how the lathe's workholding barriers override standard software boundaries. Specifically, enabling the Chuck and Tail Stock Barrier via parameter 8134#1 (BAR) completely disables standard stored stroke limits 2 and 3. Instead, the CNC uses parameters 1330 through 1348 to model the physical dimensions of the chuck claws and tailstock. For safe parameter writing access, operators must manage these changes through fanuc-parameters-and-pwe. Similarly, if the machine is powered off while inside a forbidden zone, a misconfigured parameter 1301#3 (OTA) set to 1 prevents the alarm from triggering on reboot, creating a severe crash risk if the operator jogs the tool in the wrong direction.

Related Command Network

  • G31: Frequently used during probing cycles, where it temporarily bypasses or interacts with stored stroke check boundaries depending on system parameters.
  • G37: Automatically bypasses stored stroke limits during active tool setting cycles depending on Parameter 1301#2 (NPC).
  • G28: Temporarily overrides software stored stroke limits during axis retraction to the absolute machine zero position.
  • G10: Allows operators to programmatically write and modify stored stroke boundary parameters directly from the G-code stream.
  • G65: Used to call custom macro routines that dynamically calculate and write stroke limit parameters based on part dimensions using g65-custom-macro-b.

Conclusion

Implementing stored stroke limits on Fanuc controls is a highly effective, low-cost method to prevent mechanical crashes and reduce scrap rates. Periodically auditing Parameter 1320 and Parameter 1321 on all shop floor CNCs guarantees that virtual safeguards remain aligned with actual machine setups. Properly configuring these parameters, along with startup behaviors like fanuc-parameter-3402-g-code-clear, ensures that coordinate systems are initialized safely, protecting valuable equipment and components during both setup and automatic operation.

Frequently Asked Questions

How do you bypass a Fanuc software overtravel alarm to jog an axis back into the safe zone?

When an axis hits a soft limit and triggers Alarm 520, the control halts all movement. To recover, switch the machine to manual jog mode, move the affected axis in the opposite direction of the limit, and press RESET. **Practical Action:** If parameter 1301#4 (OF1) is set to 1 and parameter 1300#7 (BFA) is 0, the alarm will automatically clear the moment the axis moves back into the safe zone without requiring a RESET keystroke.

Why does the Fanuc control fail to raise an overtravel alarm at power-up even if the tool is inside a forbidden zone?

This occurs because parameter 1301#3 (OTA) is set to 1, which suppresses the alarm at reboot until the axis is moved. This creates a severe risk because jogging the axis in the wrong direction will allow the tool to crash without raising an alarm. **Practical Action:** Set parameter 1301#3 to 0 to force the CNC to raise an immediate alarm at power-up if the axis starts inside a prohibited zone, ensuring the operator must consciously override the system before jogging.

How can you dynamically adjust Fanuc stored stroke limit boundaries during a production run?

To dynamically adjust limits without manual parameter editing, use G10 L50 program blocks to write new values directly to parameters 1320 and 1321 within your program. **Practical Action:** Insert a G10 L50 block at the start of a fixture change to write new coordinate values to parameter 1320 and 1321, command G11 to exit parameter input mode, and then execute G22 to activate the updated boundaries for the new setup.

Still not resolved?

Ask our AI assistant about this topic in natural language. Grounded in verified sources, no hallucinations.

Ask AI Assistant
Hakan Gündoğdu
Hakan Gündoğdu
  • CNC CARE Co-Founder (May 2025 - Present)
  • Mitsubishi Electric NC Sales & Service Section Manager (2008 - 2025)
  • Reis CNC Service Engineer (2003 - 2005)
  • Ö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