CNC Coordinate Systems — Machine Zero, Work Zero, and Local Offsets
A CNC machining center operates within multiple overlapping coordinate systems simultaneously. Understanding how these systems relate to each other — and which one is active at any point in the program — is fundamental to writing correct G-code and diagnosing unexpected machine behavior.
Machine Coordinate System (MCS)
The machine coordinate system has its origin at the machine's reference position — the physical home established during startup homing. This position is fixed by mechanical switches or encoders and does not change.
All machine positions are ultimately measured in the MCS. The controller always knows where it is in machine coordinates, even when a work offset is active.
Machine coordinates are accessed with G53:
G53 G0 Z0. (move to machine Z zero — bypasses any active work offset)
G53 is non-modal. It applies only to the block it appears in. The next block reverts to the active work offset.
Work Coordinate System (WCS)
The work coordinate system is defined by a work offset (G54–G59, extended offsets). It places the program origin at a meaningful location on the part — typically a corner, a centerline, or a datum feature.
The WCS origin is stored as a distance from the machine home in X, Y, and Z. When G54 is active, all programmed positions are measured from the G54 origin rather than from machine home.
G54 (activate work offset 1 — program now references part datum)
G0 X0. Y0. (move to part zero, not machine zero)
You can verify the relationship between MCS and WCS at any time by checking the machine's position display — most controllers show both the work coordinate position and the machine coordinate position simultaneously.
Local Coordinate System (LCS) — G52
G52 shifts the active work coordinate system by a specified amount without changing the offset register. It creates a temporary local origin within the current WCS.
G52 X50. Y30. (shift origin 50mm in X, 30mm in Y from current WCS)
(all subsequent positions are measured from the new local origin)
G52 X0. Y0. (cancel G52 — return to WCS origin)
G52 is useful for:
- Programming a feature relative to its own local datum without changing the work offset
- Mirroring operations (G52 with negative values)
- Temporarily repositioning the origin for a specific subprogram
Fanuc behavior note: On some Fanuc versions, G52 is additive with G92 and can cause confusion. Always cancel G52 with G52 X0 Y0 Z0 before the end of the operation.
Coordinate Rotation — G68 / G69
G68 rotates the active coordinate system by a specified angle around a point in the current plane. G69 cancels the rotation.
G68 X0. Y0. R30. (rotate 30 degrees counterclockwise around X0,Y0)
(machine all features in the rotated system)
G69 (cancel rotation — return to unrotated WCS)
G68 is particularly useful for parts with angled pockets or features that are geometrically simpler to program in a rotated frame. Instead of calculating rotated coordinates manually, you program in the natural geometry and let G68 handle the transformation.
Coordinate Scaling — G51 / G50
G51 scales the coordinate system by a factor around a specified point. G50 cancels scaling.
G51 X0. Y0. P2.0 (scale all coordinates by factor 2.0 around X0,Y0)
(programmed X50 becomes X100 at the machine)
G50 (cancel scaling)
Scaling is used for:
- Producing family parts at different sizes from a single program
- Mirror imaging (P-1.0 in one axis produces a mirror)
- Prototype-to-production scaling
Not all controllers support G51/G50 — check your controller manual.
How the Coordinate Systems Stack
When multiple transformations are active simultaneously, they apply in a defined order:
Machine coordinates
└── Work offset (G54–G59)
└── G52 local shift
└── G68 rotation
└── G51 scaling
└── Programmed position
The programmed position is transformed through each active layer to produce the final machine position. Understanding this stacking order explains why G52 shifts the rotated system (not the machine system) when G68 is also active.
Practical Example — Four-Quadrant Machining with G68
A round part has four identical slots at 0°, 90°, 180°, and 270°. Instead of programming four sets of rotated coordinates, use G68 to rotate the coordinate system 90° four times and run the same slot subprogram each time:
G68 X0. Y0. R0. (0 degrees — first slot)
M98 P6000
G69
G68 X0. Y0. R90. (90 degrees — second slot)
M98 P6000
G69
G68 X0. Y0. R180. (180 degrees — third slot)
M98 P6000
G69
G68 X0. Y0. R270. (270 degrees — fourth slot)
M98 P6000
G69
The slot subprogram O6000 programs the slot in its natural orientation — no trigonometry required.
Common Coordinate System Errors
G53 used without machine being homed — if the machine has not completed its reference return after power-on, G53 positions are unreliable. Always home the machine before running programs that use G53.
G52 not cancelled — leaving G52 active after a subprogram shifts the origin for all subsequent operations. Always cancel G52 explicitly.
G68 rotation not cancelled — G69 must be called before any operation that expects an unrotated coordinate system. Rotation left active between tool changes causes incorrect positioning.
Confusing WCS and MCS — reading the machine display in machine coordinates while programming in work coordinates (or vice versa) leads to incorrect offset values being entered.
Simulate Coordinate Transformations
Stacked coordinate transformations — work offset + G52 + G68 — produce tool paths that are essentially impossible to verify by reading G-code alone. Load the program into Eureka3X to see the actual tool path on the 3D machine model, with all active coordinate transformations applied.
Try Eureka3X free for 30 days →