CNC

Work offset calculator

G54 to G59 from edge finder, bore or Z touch-off readings, with the G10 line.

G54 X

X-10.1345 in

Edge = -10.2345 + 0.2 ÷ 2 = -10.1345 in (machine).

The spindle centre sits half the contact Ø from the edge (Starrett). Source

Control
Units
Work offset
What you touched
Axis

Machine (not work) coordinates

Starrett’s are .200"; mic yours

The spindle moved

Its X in the work coordinates: 0 if the edge is the zero

Set it from the program

(SET G54 - HAAS)
G90 G10 L2 P1 X-10.1345

Haas: in G90 the value replaces the offset, in G91 it is added to it. L20 here writes G154 P1–P99 (and G110–G129), not “make this position read”. Or type the value into the offsets page by hand.

Source: Haas Automation, mill G10; G10 on every control.

What next

Will this program run clean?A searchable G and M code list, and a checker that flags common program mistakes.
Where do the holes on this bolt circle go?X and Y for every hole on a bolt circle, plus a G81 drilling program.
What I and J for this arc?Arc centers I, J, K for G02 and G03 from a radius, and back again.
How the work offset calculator works

With a .200" edge finder the spindle centre stops .100" short of the edge: moving +X, a touch at X-10.2345 puts the edge at X-10.1345 in machine coordinates. Two touches across a bore average to its centre, and the finder cancels. G10 L2 P1 X-10.1345 writes it into G54; on LinuxCNC, G10 L20 P1 X-0.1 does it from the touch.

How to set a work offset with an edge finder

Maintained by John, former CNC lathe programmer

What it calculates

A work offset (G54 to G59 and the extended sets) is the machine position of your part’s zero. Touch off an edge, a bore or the top of the part, and the offset is that machine position, corrected for the size of whatever touched.

This helper does the correction and writes the G10 line that stores the result, in the words your control uses. It handles a single edge (with the edge finder’s radius), two opposite sides (the centre of a bore or boss, where the radius cancels) and a Z touch-off on a gauge block or shim.

The formulas

One edge

edge = reading ± Ø ÷ 2

reading
machine position when the finder kicks
Ø
the finder’s contact diameter: Starrett’s are .200" (6 mm metric)
±
+ when the spindle moved + into the edge, − when it moved −

Centre of a bore or boss

centre = (a + b) ÷ 2

a, b
machine positions at the two opposite touches, same finder, same way in

Top of the part

Z0 = reading − gauge

gauge
thickness of the block or shim between the tool and the part

Worked example

A .200" edge finder kicks at machine X-10.2345, moving +X into the left edge of the part. That edge is to be X0 in G54, on a Haas.

  1. Edge = −10.2345 + .200 ÷ 2 = −10.1345.
  2. It should read X0, so the offset is −10.1345 − 0 = −10.1345.
  3. G90 G10 L2 P1 X-10.1345 writes it into G54 (P1).
  4. On LinuxCNC, with the spindle still at the touch, G10 L20 P1 X-0.1 does the same thing: the spindle centre is .100 short of the edge.

G54 X = −10.1345.

How to use it

What you enter

Control and offset
Haas, LinuxCNC, Mach4 or Mach3, and which work offset to write.
What you touched
One edge, two opposite sides, or the top of the part.
Readings
Machine coordinates at each touch, not work coordinates.
Finder Ø and direction
The contact diameter (mic it) and which way the spindle moved into the edge.
Where the edge is
Its coordinate in your program: 0 if the edge is the zero, or e.g. −0.5 if the zero is half an inch in.

What you get

Offset
The machine position of the work zero on that axis, with the arithmetic.
G10 line
The line that writes it, in your control’s words, and LinuxCNC’s L20 form.

Common mistakes

  • Adding the radius the wrong way. Moving + into the edge, the edge is further +. Get the sign wrong and the part is off by the full finder Ø.
  • Work coordinates instead of machine. Read the machine position: a work reading already has an old offset in it.
  • Trusting L20 on every control. L20 is “current position reads this” only on LinuxCNC; on Haas it writes G154/G110 offsets and on Mach4 the G54.1 offsets.
  • G10 in G91. Haas and Mach4 add the value in G91 instead of replacing the offset; LinuxCNC ignores G91 here.
  • A spinning finder too fast. Run a mechanical finder slowly, and come in again from the other side to check the reading.

Sources

The half-diameter rule is Starrett’s, for its own finders, and Travers describes the same method; the rest is arithmetic. The G10 words and what L2, L20 and G91 do are from each control’s maker.

How we pick and check sources