Tool Compensation in CNC: G40, G41, G42 Explained with Cutter Radius Offsets
In CNC programming, tool compensation refers to the automatic adjustment of the tool path to account for the radius of the cutter.
Without compensation, the tool would follow the programmed path with its center, causing dimensional inaccuracies.
🧠 Why Use Tool Compensation?
Cutting tools have physical width, so their centerline path needs to be offset by the radius to cut parts to the correct size.
There are three key G-codes for tool compensation:
| G-Code | Function |
|---|---|
| G40 | Cancel cutter compensation |
| G41 | Cutter compensation left |
| G42 | Cutter compensation right |
🔄 G40 – Cancel Tool Compensation
G40
Use this before rapid moves or after a cutting operation to turn off compensation.
⬅️ G41 – Cutter Compensation Left
G41 D01
Offsets the tool to the left of the programmed path relative to tool motion. Typically used when cutting clockwise (CW) around a profile.
➡️ G42 – Cutter Compensation Right
G42 D01
Offsets the tool to the right of the path, commonly used for counter-clockwise (CCW) contouring.
🧭 Tool Compensation Example
G90 G21 ; Absolute mode, metric
G0 X0 Y0 ; Start position
G1 Z-5 F100 ; Lower tool
G41 D01 ; Enable cutter comp LEFT using offset #1
G1 X50 Y0 ; Begin contour
G1 X50 Y50
G1 X0 Y50
G1 X0 Y0
G40 ; Cancel compensation
G0 Z100
| Code | Meaning |
|---|---|
| G41 | Comp left (tool offset to the left) |
| D01 | Tool offset register number 1 |
🔄 G41 vs G42 – How to Choose?
It depends on:
- Direction of tool movement
- Which side you want the tool to be on
| Movement Direction | Desired Side | Use G-Code |
|---|---|---|
| CW around profile | Outside | G41 |
| CCW around profile | Outside | G42 |
| CW around profile | Inside | G42 |
| CCW around profile | Inside | G41 |
🔧 D Word – Tool Offset Number
The D value specifies which tool radius from the offset table to use.
G41 D05 ; Use radius from tool offset #5
Set your tool radius in the CNC machine’s tool table, typically in D-parameters.
🔁 Entry and Exit Rules for G41/G42
To apply compensation cleanly, follow these rules:
- Always move into the profile with a lead-in move.
- Always move out of the part with a lead-out move.
- Avoid turning on compensation directly on a corner.
- Never switch G41 ↔ G42 in the middle of a contour.
Lead-In Example
G1 X-5 Y0 ; Lead-in before entering profile
G41 D01
G1 X0 Y0
🚫 Common Mistakes
- ❌ Turning on G41/G42 at the start point of a contour
- ❌ Forgetting to cancel with G40 before a rapid move
- ❌ Not setting the correct tool radius in the offset table
- ❌ Mixing G41 and G42 in the same path
🧱 Visual Example
Part Outline
G41 → Offset Left (Tool to the left of motion)
G42 → Offset Right (Tool to the right of motion)
^
G42 --> | G41 <--
v
🧪 Advanced Tip: Combine with Wear Offsets
You can use compensation dynamically for wear correction:
- Set exact tool radius in CAM
- Use small wear value (±0.01 mm) in machine for on-the-fly adjustments
🔒 Safety Precautions
- Always verify lead-in/out in simulation.
- Use G40 to cancel comp before retract or rapid moves.
- Use
G0only when you’re sure comp is off.
📘 Summary Table
| G-Code | Action | Usage |
|---|---|---|
| G40 | Cancel comp | Before/after profiling |
| G41 | Tool left of path | CW motion, outside profile |
| G42 | Tool right of path | CCW motion, outside profile |
| Dnn | Tool offset number | Matches tool radius in offset table |
🔚 Final Thoughts
Tool compensation is essential for precise machining, especially in contouring and profiling operations.
Mastering G41/G42 allows you to:
- Adjust for tool wear
- Use generic programs for multiple tools
- Improve finish and dimensional accuracy
Learn it once. Get perfect parts every time.
Leave a comment