Tool Diameter Compensation in CNC: G41, G42, G40 Explained with Examples
When programming a toolpath, the tool has physical diameter — it can’t follow the exact contour of the part.
Cutter compensation allows the CNC to shift the toolpath left or right depending on tool size, ensuring the part geometry is accurate.
🔧 Why Cutter Compensation is Needed
Without compensation:
- The tool cuts inside or outside the desired path
- Tool changes require full reprogramming
- Tight tolerances are harder to hold
With compensation:
- The machine shifts the path by the radius of the tool
- Tool size adjustments can be done in the controller
- Programs become more flexible and reusable
🧠 G-Code Summary
| G-Code | Function |
|---|---|
| G41 | Cutter compensation left |
| G42 | Cutter compensation right |
| G40 | Cancel cutter compensation |
“Left” or “Right” is based on the direction of tool movement and the side of the material the tool is on.
🧭 Determining G41 vs G42
- G41: Tool moves to the left of programmed path (for conventional milling outside a contour)
- G42: Tool moves to the right of programmed path (for inside contours)
🔁 Use the right-hand rule:
- Point your thumb in the direction of motion
- G41 = tool left of line (fingertips)
- G42 = tool right of line
🧪 Example: Outside Profile
T1 M06
G90 G54
G00 X0 Y0
G43 H01 Z100.0
G01 Z5.0 F100
G41 D01 ; Apply left compensation
G01 X50 Y0 F200 ; Start cutting
...
G40 ; Cancel compensation
G00 Z100.0
D01refers to Tool Diameter Offset from tool table- G41 shifts the tool left of path by the stored radius
📐 Tool Table (Diameter Offset Example)
| Tool | D Offset | Diameter (mm) | Radius |
|---|---|---|---|
| T1 | D01 | 10.00 | 5.00 |
| T2 | D02 | 6.00 | 3.00 |
The control shifts the path by the radius, not the full diameter.
🧰 Example: Inside Pocket
G42 D02 ; Apply right compensation (tool inside path)
G01 X20 Y20
...
G40 ; Cancel after complete
Use G42 when you’re cutting inside features like pockets or holes.
🛑 G40 – Cancel Cutter Compensation
Always cancel cutter comp after the compensated move is done:
G40
Place this after the tool retracts or when no more compensation is needed.
🧱 Required Conditions for G41/G42
- Must follow a lead-in move before compensation is applied
- Must specify D-word (tool radius index)
- Works only in G01 linear interpolation
- Program must allow room for compensation move
🚫 Common Mistakes
- ❌ Not giving a lead-in → controller alarms or moves unpredictably
- ❌ Forgetting
Dvalue → no offset applied - ❌ Canceling G41/G42 mid-path
- ❌ Using G41/G42 on rapid moves (
G00) — must be withG01
📊 Visual Diagram
Part Edge (Programmed Path)
|
| ← G41: Tool offset left by radius
|
| → G42: Tool offset right by radius
- Tool is physically shifted, part profile remains accurate
📚 Practical Workflow
T2 M06
G90 G54
G00 X-5 Y0
G43 H02 Z100.0
G01 Z5.0 F100
G41 D02
G01 X50 Y0
G01 X50 Y50
G40
G00 Z100.0
✅ Starts with tool approach, applies offset, then cancels after the contour is complete.
🧠 Best Practices
- ✅ Use lead-in moves before activating G41/G42
- ✅ Store correct tool radius in offset table
- ✅ Cancel compensation with G40 before retract
- ✅ Simulate programs to verify compensation direction
🔧 Lead-In Move Example
G01 X-5 Y0 ; Start outside part
G41 D01 ; Apply compensation before first cut
G01 X0 Y0 ; Start of contour
Lead-in should be at least 1–2× tool radius.
🧠 Summary Table
| Code | Function |
|---|---|
| G41 | Cutter compensation left |
| G42 | Cutter compensation right |
| G40 | Cancel cutter compensation |
🔍 Final Thoughts
Tool diameter compensation allows you to:
- Use the same program for tools of different sizes
- Adjust offsets without touching G-code
- Maintain part accuracy and tolerance
Learn to visualize the cutter direction and part edge. Compensation makes programs powerful, flexible, and safe.
Leave a comment