G22 is a powerful CNC safety command used to activate soft travel limits, preventing the machine from moving outside a defined axis range. When G22 is active, the CNC control monitors travel in X, Y, and Z axes and stops motion if any programmed move attempts to exceed the allowed stroke. This protects the machine from crashing into hard limits, damaging ball screws, or hitting fixtures and vises. G22 is especially useful when machining inside tight cavities, near expensive fixtures, or during robotic feeding operations where precision travel restrictions are critical.
1. What G22 Actually Does
When activated, G22:
- Enforces user-defined axis travel boundaries
- Monitors every commanded move
- Automatically stops dangerous moves
- Prevents overtravel crashes
- Protects machine mechanics and tooling
- Increases operator safety
It is essentially a “software fence” around the axis limits.
2. Basic Syntax
G22 X# Y# Z#
Each axis value defines the maximum allowed positive travel from the negative limit reference.
Example:
G22 X500. Y300. Z250.
Meaning:
- X axis cannot exceed 500 mm
- Y axis cannot exceed 300 mm
- Z axis cannot exceed 250 mm
If a move tries to go past those limits → machine alarms and stops.
3. Releasing Limits: G23
G23 disables stroke limit protection.
Example:
G23
(All axis limits removed)
Warning:
Only disable limits when absolutely necessary.
4. Real-World Example – Protecting a Deep Pocket Program
Inside a tight 5-axis cavity:
G22 X120. Y80. Z-60.
(Activate safe machining box)
G01 X90. Y70. Z-45.
G01 X118. Y78. Z-58.
…
G23
This prevents tool from exiting the pocket and smashing into walls.
5. Protecting Fixtures and Vises
G22 prevents the tool from hitting:
- A rotary table
- A vise jaw
- A tombstone
- A large part sticking out
- Probing fixtures
- Indexing heads
Example:
G22 X350. Y-40. Z200.
Operator is completely protected from accidental axis overshoot.
6. Using G22 for Robot-Loaded CNC Cells
For automation:
- Keep machine axis inside a safe cube
- Prevent accidental axis extension during part load/unload
- Protect robot from CNC movement
Example:
(Protect robot working zone)
G22 X290. Y240. Z180.
G23
This is used in many modern robotic machining cells.
7. Machine Builder Defaults vs Custom G22
Most Fanuc machines already have factory travel limits.
However, G22 allows CUSTOM safe zones, such as:
- “Don’t go past the vise jaws”
- “Don’t exceed the tombstone face”
- “Stay inside the mold cavity”
- “Prevent touching the chuck jaws”
You define the envelope, not the factory.
8. Common G22 Mistakes & Fixes
Alarm: Stroke Limit Exceeded
Reason: Move exceeded programmed G22 boundary.
Fix:
– Increase limit value
– Or lift with G23
Toolpath stops inside a cycle
Fix:
– Check CAM-generated limits
– Adjust Z limit for retract moves
Machine won’t move at all after G22
Fix:
– G23 must be issued
– Or power cycle if control locked state
Collision caused by wrong sign (+ / -)
Fix:
– Always verify machine coordinate system (G53)
9. Best Practices for Using G22 in 2025
- Always define limits in machine coordinates (G53)
- Set limits slightly outside work offset envelope
- Use G22 in programs made for:
- Unattended machining
- Automation cells
- Expensive parts
- Complex 5-axis operations
- High-precision pocketing
- Always remove limits with G23 before tool changes or probing cycles
10. Example: Safe Turning Zone Protection (CNC Lathe)
Protecting turret from hitting chuck jaws:
G53 X200.
G22 X180. Z150.
All cutting allowed, but turret cannot physically overtravel into chuck.
11. Example: Safe 3-Axis Milling Envelope
Protecting table-mounted fixtures:
G22 X450. Y180. Z-40.
(Operate safely inside defined box)
This is extremely common in aerospace machining.
12. Summary
G22 Stroke Limit Protection is one of the most effective ways to prevent CNC crashes, protect expensive fixtures, and ensure safe machine motion. It allows you to define custom travel zones that the machine cannot exceed, making it a powerful safety tool for both beginner and advanced machinists. In 2025’s high-speed, automated machining world, G22 is a must-use command for any shop aiming to reduce scrap, increase uptime, and eliminate preventable collisions.
Leave a comment