grbl/grbl — Issue #66: Homing Cycles
Author: aldenhart
Created: 2012-02-25 11:53:05+00:00
State: open

I wanted to start a thread to discuss how homing cycles should work and be invoked. This is actually a complicated topic as there is no guidance in the Gcode spec and everybody does it differently. Pardon the lengthy post, I'll try to be brief in summarizing a fair amount of research. To cut to the chase, I think using G28.1 to reference axes (perform a homing cycle) is a good way to go, but there are alternatives that people are using.

--- Invoking Homing ---

To summarize the the two generally agreed references for the Gcode spec:
(1) NIST RS274NGC v3 (Kramer)
(2) CNC Programming Handbook, Edition3 (Peter Smid)
...there is no way to programatically home a machine. Both agree that G28 takes you to the home position, but neither says how to actually hit the switches and reference the axes.

G28 returns the machine zero in each of the following - but is named differently:
- "Return to Home" (NIST)
- "Machine Zero Return" (Smid)
- "Return Home" (Mach3)

EMC2 defines G28 "Go to Predefined Position" and this works differently that the other 3 references, above. It can return to some coordinate other than machine zero:
http://linuxcnc.org/docs/html/gcode_main.html#sub:G28,-G30:-Return

Mach3 defines G28.1 as "Reference Axes" and actually does a homing cycle.

The Reprap Teacup variants use G161 and G162 to perform homing, as do the Makerbot machines. My Machinist friends puke when they hear this as you really shouldn't run around adding new integer Gcodes. Dot extensions are OK, but new Gxx is not. Gxxx is even worse. See:
http://reprap.org/wiki/Teacup_Firmware#Endstop_Handling

--- How Homing Functions ---

EMC actually has a nice spec for how homing cycles should work:
http://linuxcnc.org/docs/html/config_ini_homing.html
... but (unless I'm missing something) no programatic way to invoke it.

Mach3 provides a very terse description of homing operation in section 10.7.11 below. This is different than EMC and doesn't appear to be as flexible:
http://www.machsupport.com/docs/Mach3Mill_1.84.pdf

The requirements for how you actually do homing varies based on the machine and application, but here's what I've been playing with. This is a largely the EMC behavior. There are other details, but in summary:
- Program a Reference Axes using G28.1 Xnn Ynn Znn Ann Bnn Cnn (grbl would use only XYZ)
Axis words are optional but at least one must be present. Only axes present will be homed. Others will be left at their current coordinates.
- Each indicated axis is homed in pre-set sequence (XYZABC, set in code).
- The negative limit switches become homing switches for the duration, and their behavior changes (no Abort)
- The first move is a search for the limit switch in the negative direction at traverse velocity
- When the switch is hit it's backed off by a small, programmable distance
- The second pass at the switch is a Latch move at a programmed, low velocity
- Once the latch move is hit the zero axis is backed off and the backoff is used as the machine zero for that axis

The above doesn't deal with:
- Axes that want to use positive limit switches for homing
- Axes that have middle position homing switches (useful on very large machines)
- A "smart" way of closing in on the switch during search
- Spindle homing (indexing)
- Axis zero being different than the offset
- Programmable homing sequence
- Some homing implementations return to coordinate system zero at the end, or do this through an intermediate point like G28. This implementation does neither.

What are your thoughts on invoking homing, and how it works?

- Alden