G54–G59 work coordinate systems: how the same program machines a different location
Explains with an example the relationship between machine and work coordinates, what selecting a G54–G59 work coordinate system means, how to repeat the same program on several vises, and the accidents that happen when the wrong offset is chosen.
The machine origin and the workpiece origin are different
After a machining center is switched on and returned to its reference point, it knows the reference position of each axis. This is the machine coordinate system. But every time a workpiece is clamped in a vise or fixture, it ends up in a different position relative to the machine origin. If drawing dimensions were converted to machine coordinates in the program, every coordinate would have to be changed each time the workpiece is reclamped.
So the operator finds the workpiece datum (for example, the top of the front-left corner) and stores the machine coordinates of that position on the work coordinate offset screen. X0. Y0. in the program then means this stored position, and the program can be written with the drawing dimensions as they are.
Selecting work coordinate systems with G54–G59
Six work coordinate systems, G54 through G59, are available as standard, and depending on options, extended slots such as G54.1 P1 to P48 (or more) can be used. When G55 is commanded in a program, from that moment all absolute coordinates are interpreted relative to the origin stored in the G55 slot.
| Code | Role | Example |
|---|---|---|
G54 | Work coordinate system 1 (often the default at power-on) | First vise |
G55–G59 | Work coordinate systems 2–6 | Second vise, another face of a rotary fixture |
G54.1 Pn | Extended work coordinate systems | Multi-part pallets |
G53 | Moves in machine coordinates for that block only (non-modal) | Moving to the tool change position |
Example: the same slot on two vises
The program below cuts a 20 mm long slot at the G54 origin, then switches to G55 and cuts the slot again at the same coordinates. On the machine, the origin of the second vise is stored in the G55 slot, so the tool moves to the neighboring vise and machines the same shape.
Machining the same slot once on the G54 vise and once on the G55 vise
O3003
T1 M6
G21 G90 G17 G40 G94
G54
S3000 M03
G00 X0. Y0. Z20.
G01 Z-1. F100
X20. F300
G00 Z20.
G55
G00 X0. Y0.
G01 Z-1. F100
X20. F300
G00 Z50.
M30The figure above is the CNC Path Analyzer result for this program (rapid 4 segments, linear cutting 4 segments).
Why the two slots overlap in the drawing
In the path drawing, the two slots are drawn on top of each other in the same place. This shows the essence of work coordinate systems well. Looking only at the program, both operations use exactly the same coordinates; where the cut actually happens is decided by the offset values stored in the machine. Path checking tools, including CNC Path Analyzer, cannot know those values, so they draw the program coordinates as they are.
Put the other way round, even if the drawing is perfect, the machine cuts in the wrong place if G54 and G55 are swapped or an offset slot holds a wrong value. Offset accidents cannot be caught by reviewing the program alone; they must be caught by checking the offset screen before machining and dry-running to the first position.
Common offset accidents on the shop floor
- Missing coordinate system command: G54 is not written in the program, so it runs in the G55 state left by the previous program.
- Z offset applied twice: the same height is entered both in tool length compensation (
G43 H_) and in the work coordinate Z offset, so Z is shifted twice. - Wrong measurement reference: it was agreed to use the workpiece center as the origin, but a corner value was entered. The basic practice is to state the drawing origin on the job sheet.
- Leftover external common offset (EXT or slot 00): a value from a previous job remains in the external offset slot that is added to every coordinate system.
An example procedure for setting the origin
- Find the positions of the workpiece's X and Y datum faces with a touch probe or an edge finder. With an edge finder, the stylus radius must be added to or subtracted from the reading.
- Enter those machine coordinates in X and Y of the corresponding work coordinate slot.
- Enter Z according to the tool length compensation method. If tool lengths were measured from the machine table, put the height of the workpiece top in the Z offset; if they were measured from the workpiece top, leave the Z offset at 0.
- Run something like
G54 G00 X0. Y0.in MDI and confirm visually that the tool comes above the datum point.
Frequently asked questions
How do G92 and G54 differ?
G92 shifts the coordinate system by saying "call the current tool position this coordinate". The result depends on where it is executed and causes great confusion on restart, so the G54–G59 method is the standard on today's machining centers. On lathes, G50 plays a similar role, but it shares its number with the maximum spindle speed limit, so you have to read the context.