G54.APP

G-code deep dive

G40, G41, G42: Cutter Radius Compensation Explained

G40G41G42G41.1G42.1

Cutter radius compensation shifts the toolpath sideways by the tool's radius, so the program can describe the part edge while the machine moves the tool center:

The offset amount comes from the tool table, selected by the D word:

T3 M6              ; 10 mm end mill, radius in offset register 3
G0 X-15 Y0         ; start clear of the part
G41 D3             ; comp on, left of path
G1 X0 Y0 F500      ; lead-in: tool drifts left by its radius
G1 Y50             ; from here on, coordinates ARE the part edge
G1 X60
...
G40                ; cancel on the way out, in open space

The payoff is on the shop floor: measure the finished part 0.05 mm oversize, dial the D register down 0.025, and re-run — no repost, no CAM.

The lead-in rule

Comp cannot switch on instantaneously — the control needs one move to ramp from center-on-path to center-offset. That move must:

  1. be a straight line (G1, not an arc) on most controls,
  2. be at least as long as the tool radius, and
  3. happen outside the material, in the active plane (G17 for mills).

Cancel with G40 the same way: on a linear exit move in open space. Turning comp on or off mid-profile is the direct cause of most gouges and "interference" alarms.

OperationLinuxCNCGRBLCentroidFANUCMach3Mach4Notes
Cutter compensation OFF G40 G40 G40 G40 G40 G40 Default state.
Cutter comp LEFT of path G41 G41 G41 G41 G41 D word selects the offset register.
Cutter comp RIGHT of path G42 G42 G42 G42 G42
Dynamic cutter comp (offset in source) G41.1 / G42.1 LinuxCNC puts the D value in the source line instead of a register.
Cutter-comp corner style G40.1 / G40.2 Mach4 only: G40.1 arc-rounded, G40.2 square.

— means the control has no equivalent code. Full cross-control tables: the complete G-code & M-code reference.

Comp in the control vs comp in CAM

Modern CAM systems compute the offset path themselves and post center-line coordinates with comp off ("computer" compensation in post settings). Control-side comp survives because of the tool-wear workflow above, and because hand-written profiles are far easier to program at the part edge. Know which mode your post is set to — running a CAM-compensated path with control comp active doubles the offset and cuts everything undersize/oversize by a full radius.

Common mistakes

Frequently asked questions

What's the difference between G41 and G42?

Direction of offset relative to travel. G41 shifts the tool to the left of the programmed path (climb milling an outside profile), G42 to the right (conventional milling). Stand behind the tool as it moves: G41 steps it to your left, G42 to your right.

What does the D word do in a G41/G42 block?

It selects which tool-table offset register holds the radius (or diameter, on some controls) to compensate by — e.g. G41 D1 uses register 1. This is how an operator adjusts for a resharpened or slightly undersized cutter without touching the program.

Why doesn't cutter comp work on GRBL?

GRBL intentionally omits it, along with canned cycles. CAM posts targeting GRBL must compensate in software: the post outputs the offset toolpath directly. That's also the modern CAM default for every control — most shops leave comp off and let CAM produce the final path.

Why do I get a gouging or 'comp interference' alarm?

The control can't fit the tool radius through the programmed geometry — an inside corner smaller than the tool radius, or a lead-in move shorter than the offset. Enable comp on a lead-in move at least as long as the tool radius, in open space, never inside the profile.

See it, don't guess it

Paste a program into the free G54.APP viewer and watch these codes execute — toolpaths, stock removal, and machine state, live in your browser. Nothing is uploaded.

Open the G-code viewer