grbl homing using NC switches

grbl homing with NC switches can start out as something small but can become very tricky very fast. There are plenty of options within the firmware but getting a combination of settings right is critical. However with the correct wiring and right sequence of options in grbl can lead to flawless homing within minutes.

I’m using NC switches because it relies on a connection being broken to trigger a machine halt which is safer. Its also recommended by many experienced CNC builders and the fact that I can add as many as I want on every axis. I’m using my motionPro controller to run my laser engraver. I have 2 switches on either axis but you can connect as many as you want (within reasonable limits). Wire them as shown below:

On the motionPro controller board connect these on the headers (between 1 and 2) or connectors labeled X-LIMIT.

Note that this is the most basic configuration for the limit switches. It does not include additional noise filtering and other hocus-pocus to prevent false triggering.

The real key to making this work is in the config.h file for grbl and some experimentation. First, here are the changes to the config.h in grbl.

Depending on how many axes you have, enable the right homing cycle. HOMING_CYCLE_0 runs first. You can home multiple axes in one cycle too. This is the case in my laser engraver where Z homing is disabled and X and Y axes home at the same time. Note that if you do not have a Z-axis installed and active, you must disable the homing for this axis. Leaving it enabled will not home your machine since its waiting for the Z-axis homing switch to be triggered before moving on to the rest. You can cheat by placing a limit switch there that can be triggered manually but its far easier to make the change in the firmware.

I also enable HOMING_SINGLE_AXIS_COMMANDS. This enables me to home any individual axis through the serial monitor using $Hx command, ‘x’ representing the axis.

Homing sets the entire machine in negative coordinate space. This is the way with professional CNC machines. However, if you have a two axis machine you probably need a positive coordinate space. To set this, enable HOMING_FORCE_SET_ORIGIN.

My grbl homing process

Enable homing by setting $21=1. $21 sets the hard limits for your machine, one that is tested using the limit switches you just installed. If you’ve not installed limit switches, this won’t work.

Once you’ve done this, go ahead and run homing by entering $H in your control software. If all the axes home in the corner you want, you are set and you can stop reading this post right here. If not, read on.

Now we need to get it to home in the correct corner. This means you need to tweak the homing direction of the X and Y axes. This is done using $23. Note that this is a mask value and not just a binary setting. Refer the chart explained for $2 – Step port invert, mask on the grbl wiki. For e.g. if your machine homes in the top left corner (assuming you have a cartesian machine) and you want it to home in the bottom right corner, reverse the direction for both X and Y axes. This is done by setting $23=7.

Run homing again and your machine should home to the correct corner. If you’ve also set HOMING_FORCE_SET_ORIGIN in config.h this will set the X and Y to (0, 0). However, if you try to move the axes now, your axes might move in the opposite directions.

This is easily remedied by setting the $3 setting which, again, is a mask value. Refer to the chart again and set the right value.

And you are done! That should complete grbl homing configuration. Questions? Leave a comment.

Hi. Just been reading this and noticed that you say you are using NC switches and then say to wire them as in the diagram.

But the diagram shows NO connections not NC.

“I’m using NC switches because it relies on a connection being broken to trigger a machine halt which is safer. Its also recommended by many experienced CNC builders and the fact that I can add as many as I want on every axis. I’m using my motionPro controller to run my laser engraver. I have 2 switches on either axis but you can connect as many as you want (within reasonable limits). Wire them as shown below:”

Right you are! The switches are in fact configured in the NC mode. You will need to daisy chain from Com to NC to Com to NC. This method relies on detecting whether there is a break in the circuit which can occur only because the switches were triggered.