How to Send a Home Zero CNC Mill With G-Code
Reference return is the first move of every safe program. This guide shows the exact G-code sequence, the parameters you must set first, and the errors that turn a homing move into a crash. Written for operators and engineers running Fanuc, Haas, Siemens or LinuxCNC controls.

In this article
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Key takeaways
What home zero means on a CNC mill
Home zero is the fixed machine reference. Every work offset, every tool length, and every G54 through G59 value is measured from it. The control does not know where the table is when you power up, because most mills use incremental encoders. Homing drives each axis until a limit switch or an absolute encoder reference mark trips, then the control assigns that point a known machine coordinate.
That assignment is why homing matters more than most operators think. If the reference is off by 0.05 mm, every part on that setup shifts by 0.05 mm. On a home zero cnc mill running a ±0.005 mm tolerance, that error is ten times the allowed band. You cannot inspect your way out of a bad reference.
Older mills use mechanical limit switches with a repeatability of roughly 0.01 mm. Better machines use inductive proximity switches or glass-scale reference marks, which hold closer. The axis decelerates, trips the switch, backs off, then approaches at a slow feed. That final slow approach is what gives you repeatability. If your machine slams into the switch at rapid, the reference point will drift part to part.
- 1Machine zeroThe controller's fixed origin. Set by homing, not by the operator.
- 2Work zeroYour part origin, stored in G54–G59 offsets relative to machine zero.
- 3Reference returnThe axis move itself, usually G28 or a controller-specific button.
Pre-checks before you send the machine home
Do these checks with the machine stopped. A homing move at rapid into a fixture is the most expensive mistake in this whole procedure, and it takes about forty seconds to prevent.
Clear the envelope. Remove the vise handle, the indicator arm, the chuck key, and any parallel left on the table. Swing the spindle by hand if the control allows a handwheel mode. Anything within the axis travel will be hit.
Check the feedrate override. Set it to 25–50% for the first homing move after a crash, a battery change, or a controller parameter edit. Once the sequence proves repeatable, run at 100%. There is no prize for homing at full rapid.
Confirm the soft limit parameters and the grid shift values are the ones you expect. If someone zeroed the absolute encoder on the wrong side of the switch, homing will drive the axis the wrong way and trip a hard limit. That stops the machine but usually bends nothing. Usually.
- 1Envelope clearNo tooling, clamps or handles inside the travel envelope.
- 2Override 25–50%First homing move after any service or parameter change.
- 3Air and hydraulics onSome machines refuse to home without clamp pressure present.
- 4E-stop within reachHand on the button for the first move, not on the keyboard.
Homing behavior on Fanuc, Haas, Siemens and LinuxCNC
Fanuc controls use G28 with an intermediate point stored by G28.1. Absolute encoder machines may not need a reference return at all after a power cycle, but they still need a manual reference once after a battery change. Check parameter 1815 or the equivalent for the absolute position bit.
Haas mills accept G28 and also have a dedicated Zero Return button. Haas machines home Z first by default, then X and Y. The order is set in settings and should not be changed without reason.
Siemens 828D and 840D controls use G74 for reference approach, not G28. Running a Fanuc-style G28 on a Siemens control will either alarm out or do something unexpected. Read the control family before you type anything.
LinuxCNC and Mach3 use G28 and G28.1 in a way that is close to Fanuc, but the homing sequence itself is defined in the configuration file, not in G-code. On those controls, the reference switches and the homing order live in the .hal or .ini file, and the G-code only calls the result.
- 1FanucG28 plus G28.1. Check parameter 1815 for absolute encoders.
- 2HaasG28 or the Zero Return key. Z homes first by default.
- 3SiemensG74, not G28. Verify the control family first.
- 4LinuxCNCG28 calls a sequence defined in the config file.
Common homing problems and what causes them
Axis runs the wrong way. The axis direction parameter or the encoder polarity is inverted. Stop the move, fix the parameter, and re-home. Do not let it reach the hard stop; a hard limit trip on a ballscrew can damage the coupling.
Machine homes to a different point every cycle. The switch is loose, contaminated with chips, or the slow approach feed is too fast. Clean the switch, check the mounting, and reduce the final approach feed to 50–100 mm/min. Repeatability should improve to within a few hundredths of a millimeter.
Control alarms out mid-homing with an overtravel or servo error. The grid shift or the soft limit is set inside the physical travel. On Fanuc, check the grid shift parameter. On other controls, check the reference position offset. The axis should reach the switch before the soft limit trips.
Z does not lift before X and Y. The G28 block order is wrong, or the intermediate point was stored below the current position. Re-store the intermediate point at a safe height, well above the tallest fixture in the cell. Keep it clear of the tool changer arc as well.
- 1Wrong directionAxis direction parameter inverted. Fix before re-homing.
- 2Repeatability driftLoose or dirty switch, or approach feed too fast.
- 3Overtravel alarmGrid shift or soft limit set inside physical travel.
- 4Crash on the way to referenceIntermediate point stored below the fixture.
Step-by-step: send the mill to home zero
Run this in MDI or single block the first time. Keep the feed override low until the sequence repeats.
- 1Power up and release the E-stopEnergize the control, release the E-stop, and reset any alarm. Do not jog yet. Many controls ignore a homing call while an alarm is active, and a few will move anyway. Confirm the axis position display is blinking or marked as unreferenced.
- 2Lift Z clear with G53Enter G53 G0 Z0 in MDI at 25% override. This moves Z to machine zero in one block, ignoring the work offset. If the machine is already near the top, it will barely move. If it moves down, stop immediately; the axis direction parameter is wrong.
- 3Home Z with G28Enter G91 G28 Z0. The G91 makes the intermediate point incremental, so the machine goes straight up to the Z reference. Listen for the deceleration and the slow re-approach. A single hard hit with no slow approach means the switch or the grid shift needs attention.
- 4Home X and Y togetherEnter G91 G28 X0 Y0. Both axes travel to their reference positions. Keep the override at 25–50%. On a knee mill or a machine with a quill, confirm the quill is retracted before this move.
- 5Verify the machine position readoutCheck the machine coordinate display. Most controls show a small nonzero value because the reference sits slightly off the switch trip point. Compare against the value recorded after the last successful homing. It should repeat within the switch repeatability, roughly 0.01 mm on mechanical switches.
- 6Re-establish the work offsetAfter homing, the G54–G59 values are still valid only if they were set from the same reference. Touch off again if the machine lost position, changed batteries, or was crashed. Re-check tool length offsets on at least the first tool.
- 7Run a dry pass above the partLoad the program, raise Z by 50 mm in the offset, and run at rapid with the spindle off. Watch the first approach move. If the tool dives toward the part before the first cutting move, the work offset or the G28 intermediate point is wrong.
G-code and M-code commands used for homing
Behavior differs by control. Verify against the machine builder's manual before running any of these.
| Command | What it does | Typical use | Watch out for |
|---|---|---|---|
| G28 | Reference return through an intermediate point | G28 G91 Z0 then G28 X0 Y0 | Without G91 the intermediate point is absolute and may be unsafe |
| G28.1 | Stores the current point as the G28 intermediate position | Set once, then reuse | Stored value may sit inside the fixture after a job change |
| G53 | One-block move in machine coordinates | G53 G0 Z0 to lift Z clear | Must be on the same block as the move, never modal |
| G30 | Second reference return point | Tool change or pallet position | Only exists if the builder defined it in parameters |
| G91 G28 Z0 | Incremental zero return on Z only | Lift Z before any X Y motion | G91 stays active until G90 cancels it |
| M91 / M92 | Controller-specific axis homing calls | Older Fanuc and some routers | Not universal; wrong M-code can call a tool change instead |
| M19 | Spindle orientation | Pre-homing on machines with a spindle clamp | Orientation must finish before Z is released |
Home Z first, every time
If you take one rule from this page: lift Z to machine zero before any X or Y move, and keep the feed override at 25–50% until the sequence repeats. A homing move is the cheapest place to be careful and the most expensive place to guess.
Frequently asked questions
Do I have to home the mill every time I start it?
On a machine with incremental encoders, yes. The control has no position data until each axis trips its reference. Without homing, the work offsets and tool lengths mean nothing.
On a machine with absolute encoders, the position survives a power cycle as long as the backup battery holds. You still need to home once after a battery change, a servo swap, or a parameter edit.
Can I home one axis instead of all three?
Yes. G91 G28 Z0 homes Z alone, and G91 G28 X0 homes X alone. This is useful when you only lost one axis, or when a fixture blocks travel on another axis.
The risk is forgetting which axes are referenced. Most controls will not let a program run until every axis shows a reference, but some will. Check the position display before you trust it.
What is the difference between G28 and G28.1?
G28 is the reference return move. G28.1 stores the current point as the intermediate point that G28 passes through on the way to the reference.
The intermediate point is a safety position. Set it once, well above the tallest fixture, and it protects you every time G28 runs.
Why does the display show a nonzero value after homing?
Most controls assign the reference position a value that sits a short distance off the switch trip point. That offset is a parameter, and it exists so the switch does not have to trip at the exact machine origin.
A value that changes every cycle is a different problem. That points to switch repeatability, a loose mount, or an approach feed that is too fast.
Can homing damage the machine?
Homing itself is gentle when the switch and the grid shift are set correctly. Damage happens when the axis runs the wrong way, when the intermediate point sits inside a fixture, or when the override is at 100% after a service.
Set the override to 25–50%, keep a hand on the E-stop, and verify the direction on the first move.
Does GreatLight home machines the same way on the shop floor?
Our 127 CNC machines follow the same reference-return discipline described here, with documented warm-up and re-reference points between setups. Process control is part of how we hold ±0.005 mm across a production run.
If a part needs a specific setup or an unusual fixture, send the drawing and we will review the machining plan before quoting.
Need parts machined to a repeatable reference?
Upload your drawing and we will return a quotation with a DFM review within 12 hours. No minimum order quantity, from one prototype to 10,000+ parts.
12-hour quote100% inspection±0.005 mmNDA on request