---
title: "G52 Local Coordinate System Explained"
description: "G52 shifts program zero on top of G54 for one section of a program. How it stacks, how to cancel it, and why it beats G92 for repeated features."
url: https://gcodepractice.com/journal/g52-local-coordinate-system-explained/
canonical: https://gcodepractice.com/journal/g52-local-coordinate-system-explained/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-10-02
updated: 2026-10-02
category: "Code reference"
tags: ["g52", "local-coordinate-system", "work-offsets", "g54", "g92"]
lang: en
---

# G52 Local Coordinate System Explained

> **TL;DR** G52 X Y Z sets a local coordinate system: a temporary shift that adds to the active work offset (G54 to G59), so every position after it is measured from the shifted zero. Cancel it with G52 X0 Y0 Z0. It is ideal for repeating one feature at several positions on a part. Unlike G92, it does not depend on where the tool happens to be, and unlike G54 it lives in the program, not the offset table. Always cancel it before the next tool.

Every CNC program measures positions from a zero point. Usually that zero comes from a work offset like G54, set by the operator when the part is clamped. G52 adds a second, temporary layer on top: a local coordinate system that shifts zero by a stated amount for as long as you need it. Write a feature once at X0 Y0, shift zero with G52, run the feature, shift again, run it again, and cancel. It is one of the most useful and least taught codes on a mill, and once it clicks it changes how you write repeated features.

## How coordinate layers stack

A modern control builds the position of the tool from several layers. At the bottom is the machine coordinate system, fixed to the machine's home position, which [G53 commands directly](/journal/fusion-360-g28-vs-g53-safe-retract/). On top of that sits the active work offset, G54 to G59 and their extended versions, which moves zero to the part. G52 sits on top of the work offset. Tool length and cutter radius compensation then adjust where the tool tip actually goes.

The [LinuxCNC coordinate systems page](https://linuxcnc.org/docs/html/gcode/coordinates.html) describes the same stack in its own terms, and the logic carries over to Fanuc-style controls. The key point is that G52 does not replace the work offset. It adds to it. If G54 puts zero at the corner of a vise jaw, G52 X50 puts zero 50 mm to the right of that corner, and changing to G55 keeps the 50 mm shift but applies it to the G55 zero instead.

If work offsets themselves are still new, read [G54 work offsets explained](/journal/g54-work-offsets-explained/) first. G52 makes much more sense once G54 is second nature.

## The syntax

The line is simple:

`G52 X50. Y25.`

From this point, X0 Y0 in the program is 50 mm in X and 25 mm in Y from the work offset zero. Any axis you do not mention keeps its current local shift, so it is good practice to state every axis you care about. To cancel:

`G52 X0 Y0 Z0`

G52 is not a motion command. The tool does not move when the line runs. Only the meaning of later coordinates changes. The [LinuxCNC G52 reference](https://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g52) describes it as a local coordinate system offset applied in addition to the current work offset.

## A practical example: four identical pockets

Say a plate needs four identical pockets, with centres at X30 Y30, X90 Y30, X30 Y80 and X90 Y80 relative to G54. You write the pocket once as a subprogram centred on X0 Y0, then call it four times:

```
G54 G90
G52 X30. Y30.
M98 P1000
G52 X90. Y30.
M98 P1000
G52 X30. Y80.
M98 P1000
G52 X90. Y80.
M98 P1000
G52 X0 Y0
```

Each G52 replaces the previous local shift rather than adding to it, because G52 values are measured from the work offset zero, not from the last local zero. The subprogram itself never changes. If the pocket needs a change, you edit one block of code. The subprogram mechanics are covered in [M98 and M99 subprogram Fanuc example](/journal/m98-and-m99-subprogram-fanuc-example/).

## G52 compared with G54 and G92

Three codes can move program zero, and they behave differently.

| Code | Where the shift lives | What it is measured from | Typical use | Main risk |
| --- | --- | --- | --- | --- |
| G54 to G59 | Control offset table | Machine zero | Locating the part or fixture | Wrong offset active for a job |
| G52 | Program, temporary | The active work offset | Repeating features within one part | Left active into the next tool or program |
| G92 | Program, set from current tool position | Where the tool is when it runs | Older programs, quick zero setting | Depends on tool position, easy to misapply |
| G53 | Single block only | Machine zero directly | Safe retracts and tool change positions | Non-modal, must be on every line it applies to |

The big difference between G52 and G92 is predictability. G92 says "the tool is now at this position", so its effect depends on where the tool happens to be when the line runs. G52 says "shift zero by this amount", which gives the same result every time. That is why many programmers prefer G52 for repeated features and reserve G92 for special cases. The [G92 coordinate shift vs G54 work offsets](/journal/g92-coordinate-shift-vs-g54-work-offsets/) post covers G92 in detail.

## The LinuxCNC twist

On LinuxCNC, G52 and G92 use the same internal offset. Setting one effectively sets the other, as noted in the [LinuxCNC G92 reference](https://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g92). A program that mixes G52 and G92 on LinuxCNC can therefore behave in ways that would not happen on a Fanuc-style control. The safe rule is to pick one method per program and stick to it.

## When G52 is cleared

Different controls clear G52 at different moments. On many Fanuc-style controls, a reset or the end of the program clears it, depending on parameter settings. Some keep it until it is explicitly cancelled. Some clear it when a different work offset is selected, and others keep it.

Because the behaviour varies, the only reliable approach is to cancel G52 explicitly with G52 X0 Y0 Z0 at the end of every section that uses it. That habit prevents the worst failure mode: a local shift left active, so the next tool or the next program starts 50 mm away from where the operator thinks zero is.

## G52 with rotation and polar coordinates

G52 works well alongside other coordinate tools. Combine it with [G68 coordinate rotation](/journal/g68-coordinate-rotation-explained/) to run a feature at a shifted and rotated position, or with [G16 polar coordinates](/journal/g15-g16-polar-coordinates-cnc-mill/) to place a bolt circle around a shifted centre. Order matters on some controls: the shift is usually applied before the rotation, so the rotation turns about the shifted zero. Test the combination in a simulator or with the tool well above the part before trusting it.

## G52 in macro and family-of-parts programs

G52 becomes even more useful once variables enter the picture. A macro program can compute a shift from a table of positions and apply it with G52 using variables, so one feature routine runs at any number of locations without rewriting a line. A family of parts with the same feature at different positions can share a single feature routine, with only the G52 values changing from part to part.

It also suits fixtures that hold several identical parts in a row. If each station is a known distance apart, G52 shifts from station to station while keeping a single work offset for the fixture. Some shops prefer one work offset per station instead, which lets the operator adjust each station independently. Both work. The choice usually comes down to how accurately the fixture is made: a precision fixture suits G52 steps, while a fixture with small station-to-station errors suits separate offsets that can be touched off individually.

A practical tip for fixtures: write the station spacing once as a comment at the top of the program, with the G52 values beside it, so anyone adjusting a station later can see the whole layout at a glance. When the fixture is replaced or rebuilt, that comment is the first thing to check against the new spacing, and the G52 lines are the only thing that needs to change.

## What the operator sees

From the operator's side, G52 can be confusing because it is invisible on the offset page. The work offset screen shows G54 exactly as it was set. The local shift appears only in the position display, as a difference between the work coordinates and what the operator expected, or on a separate page some controls provide for the local coordinate system. A short comment next to each G52 line, such as `(SHIFT TO POCKET 2)`, helps the next person reading the program understand what is happening without hunting through screens.

## Common G52 mistakes

- **Forgetting to cancel it.** The next tool or program runs offset by the local shift.
- **Assuming G52 values accumulate.** A second G52 replaces the first; it does not add to it.
- **Mixing G52 and G92.** Especially on LinuxCNC, where they share an offset.
- **Leaving out an axis.** An axis not mentioned keeps its previous local shift.
- **Running G52 in incremental mode by habit.** The values are taken as a shift, but G91 positioning after it can still confuse a reader; keep feature programs in G90 with [clear absolute logic](/journal/g90-vs-g91-crash-prevention/).

## How to check a G52 program before cutting

Run the program in graphics or a simulator and confirm each feature lands where the print says. Then, at the machine, use single block with the rapid override turned down and watch the position display at the first move after each G52 line. Most controls show both the work coordinate position and the machine position, and the difference between them should change by exactly the G52 amount. That check takes a minute and catches nearly every G52 mistake. The broader routine is in [how to safely test a G-code program without crashing](/journal/how-to-safely-test-a-g-code-program-without-crashing/).

## Why G52 is worth learning early

Many beginners never meet G52 because CAM software writes every position out longhand. But hand-edited programs, macro programs and shop floor changes all benefit from it, and it often appears in older programs that a new machinist has to read and edit. Recognising it instantly, and knowing it sits on top of G54, prevents a whole class of setup mistakes. The [G-code practice](/g-code-practice/) drills include offset codes for exactly this reason.

## Bottom line: shift zero, run, cancel

G52 shifts program zero on top of the active work offset for one section of a program, so a single feature can run at many positions. It is predictable where G92 is not, temporary where G54 is not, and it must always be cancelled with G52 X0 Y0 Z0 when the section ends. Use one offset method per program, check the position display after each shift, and G52 becomes one of the cleanest tools in the programmer's kit.

## Frequently asked questions

### What does G52 do in G-code?

G52 sets a local coordinate system: a temporary shift of program zero, added on top of the active work offset such as G54. Positions after it are measured from the shifted zero until you cancel it with G52 X0 Y0 Z0. It is used to run the same feature program at several places on one part.

### What is the difference between G52 and G54?

G54 is a work offset stored in the control's offset table, set by the operator and normally kept between programs. G52 is a temporary shift written in the program that sits on top of whichever work offset is active. Change G54 to move the whole job; use G52 to move within the job.

### How do I cancel G52?

Command G52 with zero values for every axis you shifted, usually G52 X0 Y0 Z0. On many controls a reset or M30 also clears it, but that behaviour is parameter dependent. Always cancel it explicitly at the end of the section that uses it, so the next tool or program starts from the real work zero.

### What is the best way to practise local coordinate systems?

Write a short feature program at X0 Y0, then call it at three positions with G52 and cancel it after. Trace the absolute machine positions on paper. Drill the code meanings until G52, G54 and G92 are instant; a free app like G-Code Sprint quizzes those offset codes in timed rounds.

### When should I not use G52?

When a separate work offset per fixture is cleaner, such as multiple vises each with their own G54 to G59, or when your machine's control or CAM post handles G52 inconsistently. On LinuxCNC, G52 and G92 share the same offset, so mixing them in one program causes confusing results. Use one method per program.

## Sources

- [LinuxCNC G-code reference: G52](https://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g52)
- [LinuxCNC: Coordinate systems](https://linuxcnc.org/docs/html/gcode/coordinates.html)
- [LinuxCNC G-code reference: G92](https://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g92)
- [Wikipedia: G-code](https://en.wikipedia.org/wiki/G-code)

---

Source: https://gcodepractice.com/journal/g52-local-coordinate-system-explained/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
