loading

UPDATE: There are now several easier alternatives than the G-shield and CNC shield which have built in filters amongst other features.

a) GRBL AIO (Arduino + Drivers + Filters + more on one board)

b) GRBL Breakout (Needs Carrier Boards + Arduino)

c) CNC Shield (Needs Carrier Boards + Arduino, + Make sure your buying latest version or no filters)

Limits switches or 'end stops' as they are known to the 3D printing community can be troublesome for Hobby CNC and 3D print setups. Many forums have discussion on how to stop the false triggers and most of it doesn't seem to work 100%.

You need 100% accurate limit sensing, 1 false limit trigger can ruin your whole print or CNC job.

Much discussion, on the Shapeoko & Shapeoko2 side, falls around using low value pull up resistors or special shielded cables and cable routing paths.. but its all difficult, sometimes expensive and unsightly and usually not a perfect solution.

This problem seems to plague everyone who tries to put limit switches on. There are many recommendations about adding resistors and shielding cables and re running limit switch wires away from power wires etc but I feel its all quite unnecessary.

When ever you have interference, you have options -

1) Chase the interference and fix / shield from it

2) Stick a filter in place to negate the noise.

Read on to see how easy option 2 is to get perfect end stop awareness for your Arduino based CNC machines & Printers

Step 1: Behind the Issue

Wether you are using a reprap style printer or a cnc router or other cnc tool like the open source shapeoko(2)

and ox, there is allot of interference in the device due to all the equipment and power sources in the mix.

Its too hard to stop 4 steppers, a spindle, a speed controller, and a power supply + any other equipment near by from interfering with delicate 5V ttl logic, even with low value pull up resistors and expensive shielded cables. Not to mention the pain of rewiring the device!

Im not sure about the constant advice to add low value pull up resistors...

Adding lower val pull up resistors just creates heat and wastes power. When ever your limit switch remains depressed, like after a home command, your resistor will be fighting to bring the pin voltage back up to 5 while the limit switch holds it down at 0v. waste & heat.

All you need to do for 100% perfect limit switch operation with Zero false triggers is: 3 small capacitors.

For each capacitor, connect the negative leg to the ground rail, and the positive to one of the limit sense pins on the controller. On an arduino running GRBL these are pins 9,10, &11.

For Shapeokos I have found that a .47uf is perfect in all instances.

One capacitor for each pin. Then as usual your limit switch wires, one wire from each switch to ground and the other to one of the pins 9,10, or 11 (grbl v.08). Same as all the diagrams everywhere, don't need add any of the resistors or other components from these diagrams. These .47uf value caps will ensure that the interference form your power supplies, steppers, spindle and spindle controllers cant affect the 9,10,11 pin voltages quickly or enough to bring the pins voltage down to the logic low threshold which is where your false positive limit error comes from.

The arduinos internal pull up resistors will constantly be charging the cap and holding the pins high which is why you don't need to add more. (this is not a waste of power / creator of heat, capacitors average consumption not add) The internal pull ups will ensure that the cap cant draw to much current on initial charge from the atmega pins so there is no safety issue for the arduino.

The cap works as it should to filter the line noise, not to (big) much so that the limit switch cannot pull the pin to ground quickly, and not to little that there can be any confusion as to if the shapeoko/printer has hit a limit or not.

Its pretty much foolproof, Ive tested it on 5 seperate shapeoko2's, including with bigger nema 23's, quiet cuts spindles, variable speed drives... There is not need to concern how to route the cabling, no need to worry about shielded cabling, no need to add any resistors anywhere. No need to muck with the grbl debounce timing constant. Just put in 3 caps and forget.

To make it clean, get a blank arduino uno prototyping board and install the caps and limit switch inputs to that, then insert that between the arduino and the gshield or what ever stepper shield you are using. As you first power up the board, the capacitors will pull down the limit switch pins for a tiny bit of a second as they charge, so the board will come online in a 'Limit switch error' state, and you have to soft reset and $x to clear it as usual, its actually nice for the controller to come online disabled though so its a cool side effect.

If you want to clean the line best for your particular setup, get an oscilloscope and probe your limit pins while running all the axis and dremel or spindle, and try a bunch of different caps, small as possible going bigger until you get no false limits, then maybe choose the next size up from there to be safe. If you dont have a scope, just use the .47uf or experiment.

Another handy tip, if your using the omron lever style limit switches, set the pull off constants in grbl to about 5mm so that when your homing finishes it pulls back off the limits when done so that its not bending the levers so much, otherwise you constantly have to re bend them back out. Also, I believe that these are the style of switch to use, they are not as convenient for mounting as a momentary push switch as shown in the shapeoko wiki but they are more accurate, they have a threshold from which they literally JUMP from open to closed with a spring effect, it means that the actual point of limit should be more repeatable than using an ordinary momentary push button which bounce more. Also, the momentary switches bottom out when they connect, meaning that if your axis is moving very quickly, you might be able to smash the switch or crash the carriage before the limit is triggered - with the levered switches you get yourself a few extra millimeters before it goes crunch!

Next page some diagrams of the switch filter board

Step 2: Solve the Issue for GRBL/Shapeoko/Xcarve/Ox...

Options:

1) Get a controller with Limit Switch Filters such as

  • GRBL AIO (Arduino + Drivers + Filters + more on one board)
  • GRBL Breakout (Needs Carrier Boards + Arduino)
  • CNC Shield (Needs Carrier Boards + Arduino, + Make sure your buying latest version or no filters)

or

2) Make an intermediary filter board

For Grbl systems, you can use a protoshield like the one here or one of many others found online.

This will slip nicely between your arduino and controller wether its a gshield or my favourite the CNCshield.

See photos 1-3 for the component layout.

  • Careful these electrolytic .47uf capacitors are polarised, positive to the limit wire and arduino pin and negative to ground

Photos 4-6 show the soldering on the back,

  • note the pins from the 3 orange wires are bent over to meet the pins from the socket two holes over.

Photos 7-9 show the finished filter board sandwiched between the controller and arduino uno.

  • If you want the end result instead of making your own, I have a limited number available already made: here.

Then you are left with 4 wires.

1 is ground, its green in my photos. The other 3 are you XY&Z limits.

These are connected to one side of your normally open limit switch. The other terminal of the limit switch is connected to ground. So when the limit switch is depressed, it will short the circuit to ground and the controller will know its at the ...limit.

Please note, grbl v.09 has moved one of the limit switch pins!! https://github.com/grbl/grbl/wiki/Connecting-Grbl

Also note: I have been pulled up on my resistance to adding resistors: http://www.shapeoko.com/forum/viewtopic.php?f=4&t=...

Step 3: Testing Your Switches

Some tips to help test without breaking anything!

Setup Grbl Params:

$20=0 (soft limits, bool)

$21=1 (hard limits, bool)

$22=1 (homing cycle, bool)

$130=XXX (x max travel, mm) Make YYY something larger than the machines travel

$131=790.000 (y max travel, mm)Make XXX something larger than the machines travel

$132=110.000 (z max travel, mm)Make XXX something larger than the machines travel

You Can test the limit switches by setting $10=16 (status report mask:00010000)

Then turning on Verbose logging (checkbox) on UGS.

You will see a stream of numbers like "[verbose]"

When you hit the Z switch (manually with your finger) it should change to "[verbose]"

When you hit the Y switch (manually with your finger) it should change to "[verbose]"

When you hit the X switch (manually with your finger) it should change to "[verbose]"

and off course if you have enough hands to push all switches it will show "[verbose]"

So of these 3 numbers, the first corresponds to Z, next Y and third X (seems a bit backwards so be careful) If you find that any of the switches are showing a different differently on the output then you need to swap some of the leads around so that it shows correctly.

Once you are done with this you can set the $10 back to 3 (you must do this or things dont work correctly) and at this point try a homing cycle - its the button labelled $H

Might be a good idea to first turn down the homing speeds:

$24=25.000 (homing feed, mm/min)

$25=250.000 (homing seek, mm/min)

Once you have validated the homing is all working in the right way you can turn them back up a bit.

Its nice to have them turned down while testing so you have time to hit the Estop if things are ging wrong, like for example the machine starts homing in the wrong direction!

You need it to home towards the limit switches. If its not going in the right direction you will need to mess with the $23=0 (homing dir invert mask:00000000) parameter. More info on that here: Homing Directions

<p>would like to have the following setup, an opto endswitch on each end of the axis, that means 2 each....</p><p>i have the grbl cnc shield v3.0 where is place for 2 endstops for each axis.</p><p>the setup works with one switch per axis but if i connect 2 its always bridged..</p><p>any recomendation how i can solve that?</p><p>the endstops i use are these.. i already found out that i had to change the pin layout for grbl</p>
<p>Can the homing limit switches share a ground?</p>
<p>yes, they all share a ground at the arduino side and so can also share a gnd at the switch end as well.</p>
<p>Hello everybody!</p><p>I tried to connect endstop/limit switch to arduino UNO. I connected it in NC mode to 11 pin and GRND pin</p><p>So, it works but printer &quot;hangs&quot; after $H command. It finds limit switch and then do not respond. </p><p>To enable Limit stop switch I sent that commands to GRBL:</p><p>$20=1 (soft limits, bool)</p><p>$22=1 (homing cycle, bool)</p><p>I tried hundreds of different iterations (NC, NO mode, $23=1, $5=1 and so on) and can not solve this problem.</p>
<p>You need to increase homing pull off - when homing fails its usually because its trying to pull off the limit switches and doesnt pull off far enough for the switch to open again. Try increasing homing pull off to 3mm and then home again..</p>
<p>Sorry, I wrote wrong. <br></p><p>I connected limit switch in NO mode to 11 pin and GRND pin</p>
<p>Hi, I'm also having issues with interference on my limit switches when my spindle is turned on. I'd just like to know what are the specs of the capacitors. You say we should use 47uF but not at what voltage. So should it be 47uF/5V capacitors or something else? </p><p>Thanks!</p>
<p>No, use caps larger than 5V, always over spec the caps and consider that the noise voltages are likely higher than the logic voltage. Also its 0.47uf not 47uf! 47Uf would take way to long to recharge after being discharged and so when the homing cycle moves off then back onto the switch the state would not have had time to go back high to 5v and the homing cycle will fail!</p>
I recently tested it with 1microFarad that is a bit more than 0.47 microFarad that was recommended in this article. It works well. I wouldn't recommend too high capacity of the capacicator because ever trigger of the switch shorts the saved current in the cap. High capacity means high power short that wears out the contacts earlier.
<p>Hi, i have two switches per axis in parallel. I use your settings. I <br>tested every single switch if there are interferences with $10=16 by <br>pressing with my finger. It works. Homing cycle works too. When i want <br>to move the x or y axis manually after Homing Cycle the universal <br>g-coder sender says Alarm: Hard Limit [Reset to ontinue]. I verified <br>that none of the switches are pressed. What could be the problem?</p>
<p>Sorry For Late reply - </p><p>Its likely because when it pulls of the switches after the homing cycle, that its not pulling of far enough. Increase homing pull off to 3 (mm) and you will find it works. The limit switches pins detect a state change from high to low or low to high, and so you need to make sure the final homing section when it pulls away from the switches that its pulling away far enough for the switches to depress.</p>
does this also work with unpolarised capacitors? and could this guide also help with optical limit switches? thx community
<p>Yes non electrolytic caps work too.</p><p>No difference for optical switches, its the wires to the switches which are the antennas picking up noise.</p>
<p>Very helpful. I also thought about rewiring/shielded cable or inverting to NC.</p><p>I am relative new to Grbl-CNC but limit switch issues seems to be the plague. Before i read your contribution i added non-polar caps to ground. No real success. It only needs to switch the vac to trigger the limits. I ll try now caps with polarity..</p>
<p>Thank you very much. I tried to solve the limit switch issues by using shielded wires but nothing changed. With the three capacitors you suggest everything works fine.</p>
<p>Is this a valid way with cnc probing</p>
If you have noise on a probe line causing issues this will also work. Positive side of cap to the probe pin and beg to ground. There will also be a pull-up operating on this probe pin so it will work the same
<p>I'm almost ready for the electronics on my first CNC build, and was contemplating this very limit/homing switch problem. Your solution was right on time!! I'm not using an Arduino/GRBL controller as your example. My system will be Mach 3 driving thru a breakout board, then eBay/Amazon drivers (542 style). I'm thinking your electrolytic caps @ the breakout board where the limit switch signal terminates. Do you agree?? Thanks for your very thorough analysis of a very aggreviating problem.</p>
<p>I hve just finished my CNC, I had to install the endswitch and saw some issue on the web, but with it I think I will be good!! <br><br>Awersome thank!</p>
<p>So ,you saying add 3 electrolytic capacitors and 3 resistors ?, or just the 3 caps??</p><p>i missed a bit with the last note.</p>
Just 3 caps. you can just put them inline with the limit switch wiring it doesn't really need all the extra fluff. Just a cap across the two wires, close as possible to the arduino, with the + on the limit pin side and - on the ground side.
<p>i missed a bit with the last note .thanks i'll give a try, i builded a lot of OX cnc and limit switch issues are killing me</p>
<p>Great suggestion, Ben! I had a bit of space available on my 24Volt-to-12Volt board powering my cooling fan, and used that space to put pin headers and the three 0.47 mFd capacitors. Moved my switch connectors to the new input headers, and jumpered the new output headers to the gshield - bingo! My false limit switch events are gone. I cut several jobs that have been impossible to finish, and nary a problem in several hours of running time. Thanks!</p>
<p>Thanks, But Why when I look at your first picture am' I seeing one wire from each of the caps to the ground connector and the other pin not on the 5v connector but instead on a non 5volt connectors pins ? Even when I look at you two others pictures of the reverse side I don't see any soldier on the 5 volts connectors ? The images are a little confusing.</p>
<p>WOW!! What was I thinking! It was very early here and I was responding pre coffee!!! You are correct. The Arduino is using the pullup resistors to bring the lines up to 5v, which brings the charge in the cap up as well! </p><p>So there is nothing to do with 5V on this board! Other than the 5v that will be present on the pins 9,10,&amp; 11 by default! </p><p>Sorry Again!!</p>
<p>Hi Ben,</p><p>I'm fairly a beginner in this matter and I got a different arduino shield it the Proto PCB rev 3. My question is that when I look at your diagram and I can't see where is the 5volt connection on your board ? Is there a 5 volt connection or do I have to connect the three wires that come out of the board to each one of the limit switch wire plus a connection to the arduino 5 volt terminal ??</p>
Nicely done.<br>I'm still working this out on my CNC. So far it's got pull-up resistors, filter caps and shielded cable. Still get a few false triggers so next step is grounding the chassis.
If you have shielded cable one side should be grounded already. Have a read about that topic, you often don't ground both ends.<br>Something is wrong, you shouldn't need to goto that amount of effort. Describe your setup.
<p>Nicely done. Thanks for sharing this!</p>

About This Instructable

48,212views

85favorites

License:

More by BenHarper:End Stop / Limit Switch Problems Safetly use CLONE APM Power Modules SM5100B GPRS and General Notes 
Add instructable to: