Skip to content

G40, G41 and G42: the cutter radius compensation family

G41 and G42 tell the control to shift the toolpath half a tool diameter to the left or right of the contour, looking in the direction of travel, and G40 cancels that shift. Thanks to them you program the print dimensions instead of the cutter centerline: the real radius lives in the offset table and gets changed at the machine when the tool wears or when you load a different one. All three are modal and belong to the same group, so activating one automatically cancels the other two.

For reference only: syntax changes with the control, the post-processor and the machine parameters. Check the official manual and run a simulation before cutting. Legal notice.

The brands and control names mentioned belong to their owners and are used only to identify the equipment. GetGCode is not affiliated with or endorsed by any manufacturer, ISO or ASME: this is our own content, not official documentation. Legal notice.

Family
Compensation
Machine
Milling, Turning, Mill-turn
Risk
High
Example
G01 G41 D01 X50 Y0 F200

Syntax by control

Fanuc (milling)
G01 G41 D01 X0. Y-15. F250 ... G01 G40 X-30. Y-30.
Turning compensation on and off requires a linear move with sideways travel greater than the offset radius. D calls the line in the radius table; D00 is equivalent to zero compensation.
Haas (milling)
G01 G41 D01 X0. Y-15. F250
Same syntax as Fanuc. Check the relevant setting on your machine to see whether the table is in radius or in diameter: if you enter the radius where the control expects the diameter, the whole contour comes out with half the compensation.
Fanuc / Haas (turning)
G42 X40. Z0. F0.2 ... G40 X60. Z5.
On a lathe you compensate the insert nose radius, and you also need the orientation number (tip, 0 to 9) in the offset. With a rear turret and an OD tool, G42 is the usual choice; with a front turret it reverses.
Siemens 840D / 828D
G1 G41 X0 Y-15 F250 ... G40 X-30 Y-30
Siemens takes the radius from the tool list through its D offset, not from a separate D letter. CUT2D and the corner strategies NORM, KONT, G450 and G451 decide how the outside corner is traversed.
Heidenhain TNC (Klartext)
L X+0 Y-15 RL F250 ... L X-30 Y-30 R0 FMAX
In Klartext the compensation sits right in the positioning block: RL is left (equivalent to G41), RR is right (G42) and R0 is uncompensated (G40). APPR and DEP are the tangential approach and departure blocks.

Address letters used with it

LetterWhat it setsUnit
DRadius offset number in the tool table on Fanuc, Haas and compatible controls. D01 does not have to match T01: they are separate tables, although nearly every shop keeps them matched so nobody gets lost.integer, no units
HOn some controls and older machines the radius offset is called with H instead of D. That is a machine setting, not a program choice: look it up in the manual before you assume it.integer, no units
X YCoordinates of the block that turns compensation on or off. The sideways travel in that block has to be greater than the compensated radius, or the control either alarms or gouges the entry.mm / in
G17 / G18 / G19Plane the compensation works in. Left and right are judged inside that plane, and compensating in the wrong plane is a sure way to get an interference alarm.modal, no units
T (lathe)On a lathe, the last two digits of the T call the offset, which stores the nose radius and the orientation number. T0303 uses offset 3 with its radius and tip.integer, no units

Worked example

Finishing the outside contour of a 100 x 60 mm aluminum plate with a Ø12 cutter and offset D01 = 6.0 mm. What matters here is where compensation turns on and where it cancels: always in straight moves, clear of the material, and with sideways travel greater than the 6 mm radius. The path runs clockwise seen from above, which with G41, a right-hand cutter and M03 gives climb milling.

O0400 (CONTORNO CON G41 Y G40)
( Program header. )
G21 G17 G40 G49 G80
( Millimeters, XY plane and a clean state. The G40 in the header guarantees you do not drag in compensation from the previous part. )
G91 G28 Z0.
( Z to the reference point before the tool change. )
T1 M06
( Ø12 finishing cutter. )
G90 G54 G00 X-25. Y-25.
( Positions clear of the part, on a diagonal from the start corner. )
G43 H01 Z50. M03 S4500
( T1 length offset and spindle on. )
G00 Z-5. M08
( Goes down to the depth of cut while still clear of the material. )
G01 G41 D01 X0. Y-15. F400
( Turns compensation on. The first move runs in Y, so the sideways travel relative to it is the X move: 25 mm, greater than the 6 mm radius, so the control can build the entry vector without an alarm. )
G01 Y0.
( Arrives tangent to the start corner of the contour, already compensated. )
G01 Y60.
( Left wall. )
G01 X100.
( Top wall. You write the print dimension; the control is already keeping the cutter 6 mm to the outside. )
G01 Y0.
( Right wall. )
G01 X0.
( Bottom wall: closes the contour. )
G01 X-15.
( Leads out along the extension of the wall, already clear of the material. )
G01 G40 X-25. Y-25.
( Cancels in a linear move, clear of the part. Cancelling right up against the contour drives the cutter half a diameter into the wall. )
G00 Z50. M09
( Retract in Z and coolant off. )
G91 G28 Z0. M05
( Z to the reference point and spindle stop. )
G90 M30
( Back to absolute and end of program. )
Open the simulator to check the example

Practical keys to using G40/G41/G42 in the workshop

Left or right: how to never get it wrong

The rule is to picture yourself behind the tool, facing the way it is feeding: if the tool runs to the left of the contour it is G41, so the part is on your right; if it runs to the right it is G42, and the part is on your left. In shop terms, an outside contour run clockwise seen from above calls for G41, and run counterclockwise it calls for G42; inside a pocket it is exactly the opposite. That same call decides whether you are cutting climb or conventional with a right-hand cutter and M03, so picking the side is not just geometry: it also affects finish and edge life.

Where it turns on and where it cancels

The control needs a move to build the compensation vector, which is why Fanuc and Haas require G41, G42 and G40 to sit in a linear move, never an arc, with sideways travel greater than the offset radius. Skip that and you get an interference alarm or, worse, the control works out something strange and gouges the entry. The healthy habit is to always enter and exit clear of the material, with straight moves of at least the cutter diameter, and better still with a tangent arc entry.

The offset is your size adjustment tool

The real advantage of compensating is not easier programming, it is being able to correct the part without touching the program. If an outside contour comes out 0.01 mm big per side, you lower the offset 0.01 mm and the next part is on size; if you swap a worn cutter for a new one, you only update the number. Many shops also rough with the same program and an offset a few tenths of a millimeter larger, to leave finish stock. That trick is worth gold, but it demands discipline with the table: an offset at zero compensates zero and, on an outside contour, the part comes out half a diameter too small.

Mistakes that cost you a part (or a tool)

  • Turning compensation on or off inside an arc: Fanuc and Haas want it in a linear move and throw an interference alarm.
  • Entering with sideways travel smaller than the cutter radius: the control cannot build the vector and either alarms or gouges the start of the contour.
  • Cancelling with G40 while the tool is still right up against the contour: when compensation drops out, the cutter jumps half a diameter into the wall.
  • Leaving the D offset at zero or calling a D that does not belong to that tool: the profile comes out half a diameter too big or too small.
  • Mixing up radius and diameter in the offset table: it is a machine setting, and it makes the whole contour come out with half the compensation.
  • Ending the program without G40 and starting the next one with inherited compensation: the first approach on the new part is already shifted.
  • Programming inside radii smaller than the cutter radius: the control warns of interference, and if the warning is disabled it gouges the corner.

Frequently asked questions

What is the difference between G41 and G42?

Only the side. G41 shifts the path to the left of the contour, looking in the direction of travel, and G42 shifts it to the right. The trick to avoid second-guessing is to imagine walking behind the tool: the code is the side the tool is on, and the part is on the other side.

Can I put G40 and G41 in the same block?

It makes no sense: they belong to the same modal group, so the last one in the block wins and the other is ignored. Each one goes in its own linear move block, one to enter the contour and one to leave it.

Do I need compensation if I program with CAM?

It is not required, because CAM can write the cutter center path directly. But if you do that you lose the ability to adjust size at the machine: any correction forces you back to CAM to post the program again. That is why nearly every shop still outputs the contour compensated for finishing.

How do you compensate on a lathe?

With the same G41 and G42, but what gets compensated is the insert nose radius, and the orientation number in the offset also has to be set correctly. Without compensation, tapers and radii come out wrong even though straight diameters and faces are on size.

Why do I get an alarm when I turn compensation on?

Almost always one of three things: turning it on in an arc instead of a straight line, doing it with sideways travel smaller than the offset radius, or asking for an inside radius smaller than the tool. Check the entry block before you touch anything in the table.

Related codes

Detailed data sheet for each code

Syntax by control, address letters, a commented program and the typical mistakes for each one.

Other codes in Compensation

See the full list of G and M codes

Related apps