We use technical and security cookies and, only if you accept, analytics with no cross-site tracking. More in the Cookie policy and Privacy policy.
We use first-party cookies and technical storage to make the site work, Google reCAPTCHA security technology and, only if you accept, Vercel analytics (no cookies, no cross-site tracking). You can accept or reject analytics; both options are equivalent and you can change your choice at any time. More info: Cookie policy, Privacy policy, Legal notice and Terms and conditions.
G28 and G30: return to the machine reference point
G28/G30
G28 sends the axes you write in the block home to the reference point, but by way of an intermediate point you define with the coordinates in that same block. G30 does the same toward the second, third or fourth reference point, which the builder usually reserves for the tool change or for pallet loading. The safe form, and the one you will see in almost every program, is G91 G28 Z0.: in incremental and with zero, the intermediate point is the current position and the axis goes straight up.
For reference only: syntax changes with the control, the post-processor and the machine parameters. Check the official manual and run a simulation before cutting. Legal notice.
Family
Machine reference
Machine
Milling, Turning, Mill-turn
Risk
High
Example
G91 G28 Z0
Syntax by control
Fanuc (milling and turning)
G91G28Z0.
In incremental, Z0. means do not move before going up: the intermediate point is the same as the current position. Afterwards you have to restore G90 in the next block, because G91 is modal and everything that follows inherits it.
Haas
G91G28Z0./G53G00Z0.
Haas takes G28 just like Fanuc, but its documentation recommends G53 G00 Z0. for the retract in Z: it is a direct move to a machine coordinate, with no intermediate point and with no dependence on whether the program is in G90 or G91.
Fanuc (G30)
G91G30P3Z0.
P2, P3 and P4 pick the second, third or fourth reference point; leave P out and the second one is understood. Where those points sit is fixed by the builder in parameters, so check before using them on a machine you do not know.
Siemens 840D / 828D
G74X1=0Y1=0Z1=0
Siemens has no G28: approaching the reference point is programmed with G74 naming the machine axes, and G75 goes to a fixed point. Careful, because G74 and G75 on Fanuc are drilling cycles and lathe grooving cycles: same code, different function.
Heidenhain TNC (Klartext)
LZ+0R0FMAXM91
In Klartext there is no G28 as such: you write an ordinary positioning block with M91, which refers the coordinates to machine zero, or with M92, which refers them to a point defined by the builder.
Address letters used with it
Letter
What it sets
Unit
X Y Z
Coordinates of the intermediate point, not of the destination. The destination is always the machine reference point. With G91 and a value of zero, the intermediate point is the current position, which is what you want almost every time.
mm / in
P
G30 only: the reference point number (P2, P3 or P4). With no P, the second point is used. Where it sits is fixed by the builder in the machine parameters.
integer
G90 / G91
They decide how the intermediate point is read: under G91 it is an increment from where the tool is and under G90 an absolute coordinate of the active work offset. That is the difference between going straight up and dropping onto the part first.
modal, no units
Worked example
Tool change on a milling machine with tall clamps on the table, and end of program. This is the full sequence of retract, change and start of the next tool, which is where 90 percent of the G28 blocks in a real program live. You can see why the G91 sits right next to the G28 and why G90 comes back in the block immediately after.
G01X95.F600
( Last pass of the previous operation. )
G00Z50.M09
( Comes out of the material in Z and shuts the coolant off. )
G40G80
( Cancels cutter compensation and any canned cycle. Reaching the G28 with any of that active is asking for an alarm or a compensated move you did not expect. )
G91G28Z0.M05
( Takes the Z axis to the reference point without moving in X or Y, and stops the spindle. The Z0. is not the part Z0: it is a zero increment, that is, the intermediate point is wherever the tool is right now. )
(NUNCA: G90 G28 X0. Y0. Z0.)
( In absolute, that block means go to part zero and then to the reference point: the tool drops in rapid to the face of the part, through whatever is in the way. )
T2M06
( Tool change, with Z already up and the spindle stopped. )
G90G54G00X20.Y20.
( Back to absolute, which is essential because G91 is modal, and positions over the part with Z still up. )
G43H02Z50.M03S2400
( T2 length offset and spindle on: the next operation starts with its own complete state. )
(... MECANIZADO DE LA SEGUNDA HERRAMIENTA ...)
( The body of the operation. )
G00Z50.M09
( End of machining: comes out in Z and shuts the coolant off. )
G91G28Z0.M05
( Z to the reference point and spindle stop. Always Z first. )
G91G28X0.Y0.
( And now, in a separate block, X and Y to the reference point to move the table out so the part can be unloaded. Never in the same block as Z. )
G90M30
( Puts the control back in absolute and ends the program. )
What the intermediate point is and why G91 is used
The G28 block does not say go home: it says go through this point first and then go home. The coordinates you write are that intermediate point, and they are read as absolute or incremental depending on the active modal. With G91 and zeros, the intermediate point is the same as the current position and the move is direct, which is exactly what you want. With G90, on the other hand, G28 X0. Y0. Z0. means go to part zero and then to the reference point: the tool drops to the face of the part at rapid speed. That is why G91 and G28 always travel together and why the next block restores G90.
G28 or G53: which suits each case
G53 goes straight to a machine coordinate, passes through no intermediate point, is not modal and does not depend on whatever G90 or G91 was active; that is why Haas recommends it for the retract in Z and why plenty of programmers prefer it. G28, in exchange, leaves the axis exactly on the reference point, which is what some tool changers, pallet changers and certain builder routines demand. In practice: G53 G00 Z0. to retract safely, and G28 when the machine manual asks for it. Both need the machine to be homed.
What a return to reference cancels and what it does not
When a return to reference runs, most controls cancel cutter compensation and, depending on a machine parameter, the length offset as well, which means the Z coordinate on the screen changes meaning as that block goes by. What does not cancel itself is the canned cycles: a G81 still active can try to read the G28 coordinates as one more hole. Hence the habit of writing G40 G80 right before, and of putting M05 and M09 in the same block or the one before, so the tool goes up stopped and with the coolant off.
Mistakes that cost you a part (or a tool)
Writing G28 with G90 active and zeros: the tool goes to part zero first, in rapid, and only then comes up to the reference point.
Forgetting to restore G90 after the G28: the next block runs in incremental and a positioning move turns into a jump.
Sending X, Y and Z to the reference point in the same block: if the tool is still in the part or down a hole, it takes the wall with it.
Reaching the G28 with a canned cycle active, without having written G80: the control can read the block coordinates as one more drilling position.
Using G28 on a machine that has not been homed since power up.
Assuming the reference point is a safe position in XY as well: the Y home usually leaves the table out, but the travel in X can pass over a tall fixture.
Programming G30 without checking in the parameters where that second or third reference point sits on that particular machine.
Frequently Asked Questions (FAQ)
Why is it always written G91 G28 Z0.?
Because the coordinates in the G28 block are an intermediate point the machine passes through before going home. In incremental, Z0. amounts to do not move anything before going up. In absolute, that same block would send the tool to part zero first, which is exactly the opposite of what you want.
What is the difference between G28 and G53?
G28 takes the axis to the reference point by way of an intermediate point and depends on the G90/G91 mode. G53 makes a direct move to a machine system coordinate, is not modal and passes through no intermediate point. To retract, G53 is more predictable; for whatever the builder demands, G28.
What is G30 and when is it used?
It is the return to the second, third or fourth reference point, picked with P2, P3 or P4. Those points are defined by the builder and are usually tool change, pallet loading or part unloading positions. With no P, the second point is understood.
Does G28 clear the offsets?
Cutter compensation is cancelled on most controls, and the length offset depends on a machine parameter. Since you cannot count on it, the safe habit is to write G40 and G80 before the G28 and to turn G43 back on with its H in the start block of the next tool.
Can I send all three axes home in a single block?
The control allows it, but it is dangerous: the three axes move together and the path is not the one you picture. The correct practice is one block for Z and, if the table has to come out, another block after it for X and Y.