Resistor and capacitor for limit switches

Discussion about the arduino based g-code interpreter, grbl
Post Reply
arvacon
Posts: 8
Joined: Tue Aug 14, 2012 11:52 am

Resistor and capacitor for limit switches

Post by arvacon » Thu Dec 12, 2013 7:20 am

Hi.
I have build a small 2 axis laser engraver from dvd parts and I just finished the installation of the limit switches.
The system seems to work ok for now, but I read that it may have problems at limit switches during working, because of noise from stepper motors, so as I was searching at the forum and google for long time, I felt really confused with all those answers.
Some people suggests to put a 10K resistor as pull up and 100nF capacitor for the noise. Others says 1K resistor, others 2K, others 3K, even someone mentioned 680ohm. About the capacitor, I saw someone was suggesting 4.7nF too.

As you understand, I feel a little lost with all these info, so can you please help me take the right decision?
I am using Arduino UNO and my engraver is simular with this one. http://www.instructables.com/id/Pocket-laser-engraver/

Thanks in advance.

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Resistor and capacitor for limit switches

Post by cvoinescu » Thu Dec 12, 2013 9:08 am

The short answer is that it doesn't matter all that much.

The long answer is that the lower the resistor value, the better the noise immunity, but the more current needs to flow through the switch, so the more likely you are to see bouncing. Because the software does debouncing quite successfully, go for the lowest value resistor that still gives reasonable current through the switch. 470 ohm to 1 Kohm should be good, but anything between about 200 ohm and 2 Kohm will work.

The choice of capacitor is even less critical. The goal is to suppress high-frequency noise, so anything above 100 pF or so should do. More is better, up to a point; 1-10 nF is probably ideal, but 100 nF is a little on the large side: the extra current may stress the contacts of your switch.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

arvacon
Posts: 8
Joined: Tue Aug 14, 2012 11:52 am

Re: Resistor and capacitor for limit switches

Post by arvacon » Thu Dec 12, 2013 2:03 pm

What it scares me is that the switces are just a tiny smd kind with soft movement at trigger (I removed them also from a dvdrw device) and these seems to not be able to afford too much current (I guess..) .
Would a so low resistant like the 1K could harm them at all?

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Resistor and capacitor for limit switches

Post by cvoinescu » Thu Dec 12, 2013 3:44 pm

My recommendation is for microswitches with metal-on-metal contacts. If you have membrane switches or switches with carbon-coated rubber contacts, I don't know. 10 K definitely won't harm them, but won't give you serious noise immunity either.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

potatotron
Posts: 135
Joined: Sun Apr 29, 2012 12:47 am
Location: Southern California
Contact:

Re: Resistor and capacitor for limit switches

Post by potatotron » Thu Dec 12, 2013 5:01 pm

arvacon wrote:What it scares me is that the switces are just a tiny smd kind with soft movement at trigger (I removed them also from a dvdrw device) and these seems to not be able to afford too much current (I guess..) .
Would a so low resistant like the 1K could harm them at all?
1K Ohm @ 5 Volts = 5mA which is a pretty small amount of current. I just checked 'miniature smd snap action switches' at Digikey and out of 2828 parts there's only 50 that can't handle 5mA. So it's possible the low resistance could harm them, but unlikely. Do they have any kind of ID markings so you could look up their data sheets?

I agree with cvoinescu, lower is better. When I was building my last Shapeoko I used 10K resistors and a Normally Open setup and had all kinds of noise problems when the spindle started or stopped; I switched to NC and 1K resistors and now for the most part things work as expected.

arvacon
Posts: 8
Joined: Tue Aug 14, 2012 11:52 am

Re: Resistor and capacitor for limit switches

Post by arvacon » Thu Dec 12, 2013 10:42 pm

I will check them to see if they have any code up to their old board and I will inform you. The good is that I use laser instead of router, so I will not have noise from there. I didn't use bigger switches with metal contact, because I need wait more than a month until to receive them via ebay and also I am not sure how hard is their movement, because dvd steppers are weak and maybe have not the power to push them.
How do you count the current that passes from the resistors?

arvacon
Posts: 8
Joined: Tue Aug 14, 2012 11:52 am

Re: Resistor and capacitor for limit switches

Post by arvacon » Thu Dec 12, 2013 10:47 pm

Here is a picture I have at my phone right now, about the switches. If you need a closer one, i will take one later, when I will go at my workshop.
ImageUploadedByTapatalk1386888932.505412.jpg
ImageUploadedByTapatalk1386888932.505412.jpg (180.88 KiB) Viewed 2469 times

potatotron
Posts: 135
Joined: Sun Apr 29, 2012 12:47 am
Location: Southern California
Contact:

Re: Resistor and capacitor for limit switches

Post by potatotron » Thu Dec 12, 2013 11:54 pm

arvacon wrote:How do you count the current that passes from the resistors?
Ohm's Law -- I = V/R … Amps = Volts / Resistance. Unless you're doing something weird then all the logic signals on a grbl board will be 5V, so

10 Ohms -- I = 5 / 10 --> 500mA
100 Ohms -- I = 5 / 100 --> 50mA
1K Ohms -- I = 5 / 1000 --> 5mA
10K Ohms -- I = 5/10000 --> 0.5mA
etc.

arvacon
Posts: 8
Joined: Tue Aug 14, 2012 11:52 am

Re: Resistor and capacitor for limit switches

Post by arvacon » Wed Dec 18, 2013 1:45 am

Good morning.
Sorry for the delayed reply. I checked today my microswitches but they don't have any info written at their case, so I think I will put 1K resistors and I hope them to last long. About the capacitor, from what you said, it seems the best solution must be a 10nF.
Thank you for your very informative replies, as they really helped me to choose finally.
Cheers ;)

Post Reply