G40, G41, G42: Tool Radius Compensation in CNC – Complete Guide
Tool radius compensation (G41/G42) allows the CNC controller to adjust the toolpath based on the cutter diameter. This is essential for accurate profile machining, avoiding manual adjustments to G-code when the tool size changes.
Without this, any change in cutter size would require reprogramming all your toolpaths!
🧩 What Do G40, G41, G42 Do?
| Code | Name | Function |
|---|---|---|
| G40 | Cancel Compensation | Disables tool radius compensation |
| G41 | Left Compensation | Tool moves to the left of the path |
| G42 | Right Compensation | Tool moves to the right of the path |
- “Left” or “Right” is relative to the direction of tool motion.
- Compensation uses the D-word to define which offset to apply (e.g.,
D1).
📐 Example Scenario
Tool radius = 5 mm
Programmed contour path: a perfect rectangle (no tool offset)
- If no compensation: cut will be inside by 5 mm
- If G41 is used: tool moves left, cutting along the outside
- If G42 is used: tool moves right, cutting along the inside
🛠️ Syntax Overview
G1 G41 X__ Y__ D__ (left of path)
G1 G42 X__ Y__ D__ (right of path)
G1 G40 (cancel after path)
🧪 G-Code Example – Profile with Compensation
%
O8001 (G41/G42 Example)
G21 G90 G54
G0 Z5
T1 M6
G0 X0 Y0
G43 H1 Z5
S1500 M3
G1 Z0 F200
G41 D1 ; Apply tool compensation left
G1 X100 Y0
G1 Y50
G1 X0 Y50
G1 Y0
G40 ; Cancel compensation
G0 Z100
M30
%
This will cut a 100×50 mm rectangle using G41. Tool offset D1 must be defined in the tool offset table.
🧠 Tool Table (Typical Fanuc Controller)
| D Number | Tool Number | Radius (mm) |
|---|---|---|
| D1 | T1 | 5.0 |
| D2 | T2 | 3.175 |
| D3 | T3 | 10.0 |
The control uses the D1 value to shift the toolpath automatically.
🚫 Common Mistakes
| Mistake | Result | Fix |
|---|---|---|
| Forgetting G40 after G41/G42 | Compensation remains active | Always cancel with G40 |
| Wrong D number | Wrong offset applied → dimensional errors | Check the D-word matches tool radius |
| Incorrect start point | Cutter gouges or overshoots corners | Start away from part; lead-in required |
| Applying compensation too early | Control alarms or weird path | Apply G41/G42 on linear move (G1) |
📏 Lead-in and Lead-out Moves
Compensation must be applied during a linear move (G1). Abrupt or diagonal entries can cause alarms or gouging.
🟢 Good Lead-in Example:
G1 X-10 Y0 (approach)
G41 D1
G1 X0 Y0 (start profile)
🔴 Bad Example:
G41 D1
G0 X0 Y0 ; rapid move with compensation – error!
🧩 G41 vs G42 – How to Choose?
| Direction of Travel | Tool on Left (G41) | Tool on Right (G42) |
|---|---|---|
| Clockwise (CW) | G41 | ✅ G42 |
| Counter-Clockwise (CCW) | ✅ G41 | G42 |
You must visualize the direction your tool travels, then decide which side the tool should be on.
📊 Why Use Tool Compensation?
- You can change cutters without re-posting code
- Fine-tune profile accuracy at the machine
- Easier to manage tool wear or replacement
- Works seamlessly with CAM outputs when configured
🧱 Practical Application: Pocket Finishing
CAM software usually outputs a contour for the pocket wall. By using G41/G42:
- Your G-code stays the same
- The machinist can fine-tune with
D1,D2, etc. - Tool wear can be compensated with minor D-value updates
🔚 Final Thoughts
G41 and G42 allow precise control over tool positioning without modifying your G-code for every tool. They are indispensable for contour milling, profiling, and finishing operations.
Mastering cutter compensation is the difference between parts that fit… and parts that scrap.
Leave a comment