Home/Limit Switches

From ShapeOko
Jump to navigation Jump to search

Homing switches are used (one per axis) at one corner of a machine to set the origin in a consistent and repeatable fashion. Adding homing switches will allow one to enable soft limits (Grbl configuration $20=1).

Limit switches are essentially homing switches doubled up and in addition to setting the origin are used to prevent the motors from hitting the end of each axis which can cause serious alignment problems, potentially serious damage to your Shapeoko, destroy a bit, or ruin a work piece. Adding 6 limit switches (one at the end of each axis) is highly recommended.

The only difference between homing and limit switches is one of terminology (which is often confused), quantity (limit switches, in the physical sense, come in pairs, except maybe the Z), and position (homing switches as noted are all at one corner, while limit switches are paired one at the end of each axis of movement).

Once you have homing/limit switches you are able to take advantage of work coordinate systems.


The basic function of homing/limit switches is to set the origin of the machine for a given job, in relation to the work piece. In their absence, one can use a number of techniques as noted on the Workflow page under Run the Job.


20--24 gauge, preferably shielded. http://www.allelectronics.com/make-a-store/item/2cs22/2-conductor-shielded-cable-w/drain/1.html

A number of the wiring diagrams show one adding in resistors and/or capacitors, while others do not.

Some people have found these necessary, while others have not.[1]

Filter Out Limit Switch Noise --- commentary on GRBL Github by Ben Harper.

In noisy environments (which the shapeoko is in because of the stepper motors and spindle, probably other stuff too), the internal pull-up resistors are not as effective as lower ohm external pull-ups. I think the Uno has 20k internal pull-up resistors. Something like 330 ohms would be more effective in a noise environment; that's what I use.[2]

Normally closed (NC) vs. Open: http://www.shapeoko.com/forum/viewtopic.php?f=3&t=5156&p=37798#p37767 "...interference causes false triggering of the switches. You're much better off running NC switches to GND, but then you need the pull-up resistors (from each pin to IOREF, 1 Kohm or so)."[3]


Electromagnetic, at any rate. Doesn't need to be RF necessarily -- could also be ground-coupling, or capacitive or inductive coupling from the fairly large currents and large voltage swings on the stepper driver wires. I have not had a problem myself, so I had no reason to drag out the scope and look at it, I'm just pointing out that many people have complained about false limit switch triggering. The best proposed solution that emerged from all the collective fiddling with this seems to be an external pull-up (say 1 Kohm to IOREF), followed by a low-pass RC filter (say 10 Kohm in series and 100 nF ceramic to ground). You may have just as much luck adding just a 4.7 uF capacitor to ground, but I don't like that idea for several reasons.[4]

Do not run the limit switch wires next to stepper motor wires w/o adequate shielding.[5]

Home Switches

Initial information gathering for adding home switches to shapeoko.


The pin numbers in this schematic apply to grbl 0.8 and the default configuration on 0.9.
The Z home/limit switch pin will be pin 12 if you have enabled the compile-time option for PWM spindle control on pin 11.

Once switches are in place, turn on:

$21=1 (hard limits, bool)
$22=1 (homing cycle, bool)

to enable them (for Grbl 0.9 and later).

Limit Switches

Limit Switch Schematic

Types of Limit Switches

Limit switches can be mechanical, magnetic, optical, or a combination. There are pros and cons to each. For example, mechanical are the easiest to setup, test, and adjust; but they are also physically moved and therefore can fail or get in the way. Optical sensors don't require contact so the potential for damage is reduced, but calibration can be difficult. Dust and dirt can degrade reliability run-after-run. Magnetic sensors, such as Hall Effect sensors, are a great option as they only need to be calibrated once and are very reliable even if dirty. But you must do your research on the components and some coding may be required.

Discussion of various types and quality of switches in Re: Combatting Endstop Noise.

Hall Effect Sensor Details

  • You can use most regular magnets; just pay attention to the pole(s) that activate it.
  • These sensors are extremely accurate and give consistent results. You'll still need to calibrate and test the distance and orientation specific to your setup.
  • Since the sensors need to be wired back to the microcontroller, it makes sense to mount them on the outsides of the axes. Then the magnets can be attached to inside parts.

Forum discussion: http://www.shapeoko.com/forum/viewtopic.php?f=7&t=6049#p46540

CNCzone: http://www.cnczone.com/forums/open-source-cnc-machine-designs/101878-cnc-forum.html


File:Limit Switch 2.jpg

More examples and plenty of discussion about limit switches is in the forums. Here are a few posts worth calling out:

Limit Switches

Homing Switches

Where to Purchase


Shapeoko 3

External Resources


Mounting Parts

Supporting Shield Designs

One can also use a prototyping shield: http://www.amazon.com/Arduino-Proto-Shield-R3-Assembled/dp/B007QXTRNA/ref=pd_sim_pc_7?ie=UTF8&refRID=1CMZZMGFR2ZFKR0837PA [17]

Touch Plate

A touch plate allows one to home the machine in the Z-axis. See Touch Plate (which has a basic design, usage instructions as well as links to other designs and further information) and the elegant: Touch Plate v2 (which shows how to make a nice one using connectors and soldering).

Also known as a tool setter: http://www.cad2gcode.com/cncprojects/id16.html

https://miscsolutions.wordpress.com/mini-height-sensor-board/ [18]


Cf. http://www.shapeoko.com/wiki/index.php/Touch_Plate#Touch_probe

Recovering from limit tripping


Forum Discussions

Yet Another Limit Switch Discussion

Re: Limit switches sold with the Shapeoko now ?







homing fails with alarm
changing $5=1 (limit pins invert, bool) and $23=3 (homing dir invert mask
00000011). This makes the Z-axis move up and the X & Y move to the lower left corner. Change $23=0 (homing dir invert mask:00000000) for upper right. [19]