G-codeCoordinate SystemModal group 12Mill · Lathe · 3D printer
G54 to G59: Work Offsets
G54 to G59 pick which stored work offset the control adds to every programmed coordinate, so X0 Y0 Z0 in the program lands on the part instead of on the machine's home position. Six are standard. G54.1 P1 onwards adds more: 48 as standard on a Fanuc 0i-MF, 300 with the option.
Syntax
G54 Work offset 1 (active at power up on most controls)
G55 to G59 Work offsets 2 to 6
G54.1 P__ Extended work offset, P1 to P48 (Fanuc, Mazak; on a Haas, G154 P__)Parameters
| Address | Meaning | Notes |
|---|---|---|
P | Extended offset number, with G54.1 only | 1 to 48 as standard on a Fanuc 0i-MF, 1 to 300 with the option; Haas G154 takes 1 to 99 |
The offset values themselves are not in the program. They live in the control's offset table and are set at the machine, by probing or by touching off.
Example
O0002 (TWO VICES, ONE PROGRAM)
G21 G17 G40 G49 G80 G90 (safe start block)
T03 M06 (10mm carbide end mill)
S6000 M03
G54 G00 X0. Y0. (first vice, zero on the top left corner)
G43 H03 Z50. M08
G01 Z-5. F300
X60. F900
G00 Z50. (up to safe height before leaving this offset)
G55 X0. Y0. (second vice, its own zero, same moves)
G01 Z-5. F300
X60. F900
G00 Z50.
G49 M09
G91 G28 Z0.
G90 G54 (hand the control back in G54 for the next job)
M30Controller differences
| Control | Behaviour |
|---|---|
| Fanuc | G54 to G59, plus G54.1 P1 to P48 as standard on an 0i-MF, and 300 pairs with the option. The EXT (common) row on the offset page is added to all six. G53 suppresses the offset for one block only. |
| Haas | G154 P1 to P99 extends the six, and G110 to G129 are G154 P1 to P20 under their older numbers. Setting 33, Coordinate System, decides what G52 and G92 do: in FANUC mode the G52 values are added to every work offset, a global shift, and in YASNAC mode G52 becomes one more work offset, like G55. Setting 56 decides whether M30 puts the control back in G54. |
| Siemens 840D | The native language has G54 to G57 only, then G505 to G599. G58 and G59 are axial programmable offsets, not stored work offsets. G500 cancels all of them. G54 to G59 behave as on Fanuc only in ISO dialect mode. |
| Mazak | In EIA/ISO programs G54 to G59 and G54.1 P1 to P48 work as on Fanuc. Mazatrol conversational programs do not use them at all; the work piece coordinate (WPC) is a field in the unit data. |
| Okuma | An OSP mill selects work coordinate systems with G15 and an H number, not G54 to G59. G15 is modal; G16 with an H number does the same for one block. G54 to G59 are tool length offset codes there, so a Fanuc program's G54 picks up a length offset instead of a work zero. |
| Grbl | G54 to G59 supported and stored in EEPROM, so they survive a reset and a power cycle. Set them with G10 L2 P1 or G10 L20 P1; $# prints all six. No G54.1. |
| Marlin | G54 to G59.3 exist only when the firmware is built with CNC_COORDINATE_SYSTEMS. Stock printer builds report an unknown command and carry on. |
What goes wrong
The offset that got probed is not the offset the program calls. You touch off the new part with G55 up on the screen, the program still says G54 from the last job, and the first Z move either cuts air 40mm above the part or goes straight into the vice. Read the offset page and the safe start block together before cycle start, every setup, and put the work offset in that block so the program never inherits one from MDI.
Next most common is the EXT or common row on a Fanuc offset page. Anything typed into it is added to all six work offsets and it survives the job. A leftover Z-2.5 from a previous setup shifts every part from then on, and nothing in the program shows it. If the whole job is out by a constant, check EXT before you touch anything else.
Switching offsets at depth costs parts too. G55 is modal and takes effect on the next move, so G55 X0. Y0. written straight after a Z-5 cut moves across to the second fixture at Z-5 in the new coordinate system. Retract to a safe Z in the offset you are leaving before you call the next one.
Then portability. G58 and G59 on a Sinumerik in its native language are axial programmable offsets, not stored work offsets, so a Fanuc program that uses them runs in the wrong place without an alarm. Haas G110 to G129 and G154 P__ mean nothing to a Fanuc, which stops on an alarm. Haas Setting 56 then decides whether M30 hands you back G54 or leaves G55 active for the next program.
Updated 11 Oct 2026