What are Work Offsets [G54-G59 G Codes Explained]

a graphic of a cnc machine with text that says learn g code today G54-G59 work offsets

The G54 command tells the CNC machine where your part is located.

To put it differently, the G54 code sets the work offset zero location currently used in the CNC program.

Once the G54 work offset code is used, all sizes and locations in the program will be relative to the zero location of the part until the offset is changed with a new code such as G55 or G56.

This type of G code is called a modal command.

Modal commands remain in effect until they are canceled. This is true even if you restart your program.

Until you cancel the command or change it, the modal command G54 will stay in effect.

Obviously, this can cause trouble if you aren’t paying attention.

For this reason, most CNC programs will be created with start-up or safety commands. The safety commands make sure that the machine is always in the correct modes.

G54 vs G55-G59

All of the CNC codes from G54 to G59 act the same. They are all work offsets.

Everything in this article that applies to the G54 command also applies to all of the other work offsets including G55-G59.

Work offsets work like presets on your radio, except you store a location instead of a radio frequency. You can then call it up quickly and switch between them as needed.

This makes operations such as machining multiple parts at once easier.

Each of these commands is modal so they will stay on until turned off or changed.

The picture below shows how multiple work offsets can be set in a CNC and how they compare to the machine zero location.

visual to show cnc work offsets G54-G59 with the zero locations shown

When to use a G54 code

A G54 code can be found at any point within the program but the most likely location is at the start of the program or at the start of a new section of code.

Imagine you have a part that you want to drill holes in and then counterbore the same holes.

counterbore on metal part
A hole with a counterbore

In the program there will be a section of code for drilling the holes and a section of code for counterboring them.

Even though those operations both use the G54 offset, the G54 command would be given at the start of each of these sections of code.

This allows the programmer or operator to make sure the correct work offset mode is active.

Our imaginary example program is shown below.

an example of how modal cnc modal work offsets work

At times, CNC programs might be run out of sequence. 

If the program didn’t call out the necessary modes at the start of each section, then bad things can happen when the machine is not in the correct mode.

In our example above with the holes and counterbores, imagine finish the L&W roughing portion of the code and you check the holes only to find out they are undersize.

Time to make them bigger.

To do this you decide to only run the hole section of the code. This saves time compared to running the whole program right?

If you haven’t called out the G54 command in the hole section of the code, then the machine will continue using the G55 work offset that was used for the L&W roughing.

This can definitely end up with a crashed machine and/or damaged parts.

For this reason, safety lines are included in the CNC program at the start of each section.

The CNC machine needs to have the necessary modes set before any machining operation and the correct work offset is one of those modes.

Which work offset is the most commonly used?

The most common CNC work offset is the first one, G54.

Other work offsets are G55-G59.

Some machines may have more, but G54-G59 are the ones found on almost all CNC machines.

CNC codes that are similar to G54

G53 - Machine coordinate system

G53 is used to send the machine to a location based on the machine zero.

Typically, this is the home/return position for the machine.

Unlike G54, the G53 command is not modal. The G53 code only affects the line it is used on. It is a one-time use code.

This is a handy code to use, but not all machines have it. Keep in mind that older machines, and even some of the newer ones might think the code is something else.

Not all CNC codes are universal across the different manufacturers .

You can expect that G54 will be the same on every machine, but I can’t say the same for G53.

G28 - Machine coordinate system

The G28 code is used to send the machine to a location and then to the machines zero location in one or more of axes.

How does G10 affect G54 and other work offsets

A G10 code is used to change an offset value.

The format for using G10 looks like this:

G10 L2 P1 X1.5 Y2.3 Z 3.0

The L code is for the offset type.

The P is the offset number.

G10 codes are not something for beginners. Also, the code format isn’t the same across all CNC controls. It is important to know how your machine will react to a G10 codes. Consult your manual.

Want to learn more about G Code for your CNC?

Leave a Comment