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.
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.
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)."
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.
Do not run the limit switch wires next to stepper motor wires w/o adequate shielding.
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 Switch Schematic
- Schematic on Shapeoko Forum
- Re: will1384's Shapeoko 2 --- updated Limit Switch wiring diagram
- http://www.shapeoko.com/forum/viewtopic.php?f=7&t=4788&start=1660#p46206 --- ASCII diagram of wiring in parallel.
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
- Here is a great example by Brian Dickman:
- Also using the same method is AtomSoft in this YouTube video
More examples and plenty of discussion about limit switches is in the forums. Here are a few posts worth calling out:
- Push-buttons with video and schematic
- Limit switches on motor plates
- Slightly different method of mechanical switches onto motor plates
- twforeman's build --- post noting the addition of limit switches w/ a link to the blog post: Limit Switches for the ShapeOko
- Mechanical Limit Switches for the ShapeOko --- blog post noting replacing optical switches w/ mechanical and reasons for making this change.
- Photo interrupter as limit switch.
- Re: Rob's Franken-Mods --- shows hall effect switches and wiring up w/ a breadboard.
- Re: Limit switches --- includes a wiring diagram for hall effect switches.
- Limit switches for ShapeOko2.
- Z-Max Endstop Mounting Position
- SO3 with Hall Effect Limit Switches
- Re: Limit Switch Wiring? --- lengthy thread w/ success using shielded Ethernet cable for wiring, and an external power source to prevent resets.
- Hall Effect Home / Limit Switches
- Re: Limit Switch Wiring? --- third time is the charm --- also described as “...pretty basic. NC would be preferable to that, and changeover (using both the NC and NO contacts) is even better.”
- Re: Limit Switch Wiring? --- diagram showing basics with explanations on how to add to it
Where to Purchase
- Sharp Microelectronics GP1A75EJ000F from Digikey ($1.44 - 425-1954-5-ND)
- Bare Parts
- Mechanical Switches
- Hall Effect Sensors
- HoneyWell SS460S Hall Effect Sensor from Mouser ($0.66 - Board Mount Hall Effect / Magnetic Sensors TO-92 Bipolar Latch South Pole Activated)
- Hall Effect Sensor COM-09312 Hall Effect Sensor COM-09312 from SparkFun ($0.95)
- Also available on Digikey, Analog Devices, Jameco, and many other electronics suppliers
- Carbide 3D: Shapeoko 3 Limit Switch Kit (contact Carbide 3D to order) --- Installation instructions Discussion of installation: http://www.shapeoko.com/forum/viewtopic.php?f=5&t=7536&p=59756
- additional switches (N/O) --- wire in parallel
- photo showing new board having lights for debugging: http://community.carbide3d.com/t/newb-goin-nutz-x-y-y-x/4628/13
- switches are active low, so when a switch is pressed, it makes contact with GND. When the switch is open it is pulled high to 5V.
- https://www.etsy.com/listing/249684351/shapeoko-3-limit-switch-kit-v20 
- https://additive-aerospace.myshopify.com/collections/shapeoko-3-accessories/products/shapeoko-3-limit-switch-and-probe-kit 
- RepRap Generation 7 Opto Endstop (includes parts list and sources)
- Arduino UNO Tutorial 11 - Hall Effect Switch from HobbyTronics
- Connecting Grbl --- notes and examples of connecting electronics to the Grbl Shield.
- Shapeoko 2 -- X Home/Limit Switch Mount
- Cups, Discs and Washers for Rare-Earth Magnets
- 3D printable mount for the Z switches
- Shapeoko 2 -- X, Y, & Z Home/Limit Switch Mounts with no reduction in cut area
- Limit Switch Mounting for X and Y
- Shapeoko 2 Limit Switch Mounts
- Shapeoko 3 Limit Switch Brackets
- Alternate SO3 Z Limit Switch Mount
- end stops: Laserink saddle, endstops, dragchain adapters, rear cover
- Shapeoko 3: Re: Build 00947 (Metal Bed & Upgrades) --- includes links to .stl files: http://www.thingiverse.com/thing:1244604
Supporting Shield Designs
- i/o shield for limit switches, user buttons and controls (also included on the pendant page)
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 
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
Recovering from limit tripping
- 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.