G-codeCompensationModal group 7Mill
G41, G42 & G40: Cutter Radius Compensation
G41 and G42 push the cutter off the programmed line by its own radius, G41 to the left of the direction of travel and G42 to the right, so the program can hold the finished edge of the part and the control keeps the tool clear of it. G40 switches that off. The radius comes from the offset register named by the D word, so one program cuts the same profile with a 10mm cutter or a 12mm one.
Syntax
G41 D__ Compensate left of the direction of travel
G42 D__ Compensate right of the direction of travel
G40 Cancel compensationParameters
| Address | Meaning | Notes |
|---|---|---|
D | Radius offset register | Holds the cutter radius, so 6.0 for a 12mm cutter. D00 is a zero offset |
H | Offset register on older controls | Fanuc and Haas accept H for compensation only when a parameter allows it. Use D |
The offset works in the plane picked by G17, G18 or G19, and the control swings the tool onto it over the block where G41 or G42 appears, not before. With a right-hand cutter running M03, G41 leaves the material on the right of the travel direction and climb mills it; G42 puts the material on the left and mills conventionally.
Example
O0003 (FINISH A 60 X 40 BOSS)
G21 G17 G40 G49 G80 G90 (safe start block)
T05 M06 (12mm three flute end mill, D05 holds 6.0)
G54
S4500 M03
G00 X-30. Y-40. (on the lead-in line, 20mm clear of the boss)
G43 H05 Z25. M08 (tool length comp on, well above the part)
G01 Z-6. F400 (down beside the part, full depth)
G41 D05 Y-20. F900 (comp on over a 20mm straight lead-in)
Y20. (up the left face)
X30. (across the top)
Y-20. (down the right face)
X-30. (back along the bottom)
G40 X-50. Y-40. (comp off on a straight move, clear of the part)
G00 Z25. M09
G49 (cancel tool length comp)
G91 G28 Z0. (home Z)
M30Controller differences
| Control | Behaviour |
|---|---|
| Fanuc | D selects the radius register. The control reads two blocks ahead to work the corners out, so start-up and cancel have to happen on a straight G00 or G01 block: doing either inside G02 or G03 raises alarm PS0034. Changing the plane while compensation is live raises PS0037, and an inside corner tighter than the tool radius stops the program with PS0041 instead of gouging it. |
| Haas | D names the register, as on Fanuc. Setting 40 decides whether the offset column is read as a radius or a diameter, so the same value cuts two different parts on two machines. Setting 58 changes how the tool goes round an outside corner: YASNAC joins every outside corner with an arc, FANUC makes a sharp corner and adds a linear move where the angle is over 270 degrees. 2D compensation works in X and Y with G17, and 3D compensation is a separate code, G141. |
| Siemens 840D | G41 and G42 in the native language as well, but the radius comes from the active tool's D offset, so there is no separate register on the block. NORM and KONT set how the tool approaches and leaves the contour, and G450 or G451 decides whether a corner is rounded with an arc or run to the intersection point. |
| Mazak | EIA/ISO programs behave as on Fanuc, D word included. Mazatrol conversational programs never call G41 or G42: the cutter radius sits in the tool file and each unit applies it, with the cutting side chosen as a field in the unit. |
| Grbl | No radius compensation. G40 is accepted because it is the state Grbl is always in; G41 and G42 stop the stream with error:20. Offsets have to be baked into the toolpath by the CAM system. |
| Marlin | No radius compensation and no D offsets. G41 and G42 return "Unknown command" and the machine carries on cutting the programmed line. |
What goes wrong
The boss comes off the machine 12mm oversize because the D register holds the cutter diameter and the control wants the radius. A 12mm cutter needs 6.0 in D05. Put 12.0 there and the tool runs 6mm further off the line on every face, so an outside profile finishes 12mm large and a pocket 12mm small. Read the register against the tool before the first cut, and on a Haas check Setting 40, which decides which of the two the column means.
Next is the lead-in. The whole offset gets worked in over the single block where G41 appears, so a 2mm approach with a 6mm radius cutter drags the tool sideways through the finished face while it is already at depth. Give the approach at least the tool radius, 20mm is comfortable, and keep it on air.
Switching compensation on or off inside an arc is the next one, and it stops a Fanuc with alarm PS0034 halfway through a setup. Both G41 and G40 need a straight block. Changing plane with compensation live throws PS0037 the same way.
Then the quiet one. Two blocks in a row with no movement in the compensation plane, a dwell, a Z peck, a line of M-codes, leave the two-block lookahead with nothing to aim at, and the tool sits on the programmed corner and takes a bite out of the part. Keep the XY motion in the compensated blocks, and cancel with G40 before the tool change so the next tool starts clean.
Updated 11 Oct 2026