Switches and microcontrollers

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
How subject to bouncing are momentary push-button switches when referring to causing an interrupt?
 

BMorse

Joined Sep 26, 2009
2,675
most of my projects that involved any kind of tactile momentary switch, I always use some kind of debouncing, either in code or in hardware, since most mechanical switches tend to "bounce" most of the time.
 

Tahmid

Joined Jul 2, 2008
343
Hi,
You could implement a debounce by adding a delay after the switch is pressed. I usually use 40ms delay in software.
 

RiJoRI

Joined Aug 15, 2007
536
How subject to bouncing are momentary push-button switches when referring to causing an interrupt?
Reverse the question: How much bouncing can I stand on an interrupt line? :eek:

Answer: N-o-n-e! Each bounce will cause an interrupt, which you probably do not want.

--Rich
 

John Luciani

Joined Apr 3, 2007
475
I have been using a simple circuit by Ron Mancini that was published in EDN
a few years back -- schmitt trigger and few passive components. It works
quite well.

The schematic and the reference to the original article are in my ZB1-PB1
datasheet at http://tinyurl.com/8vfayf

(* jcl *)
 

quiismsky

Joined Oct 6, 2009
1
Hi,
You could implement a debounce by adding a delay after the switch is pressed. I usually use 40ms delay in software.
I have the same idea with you. Great! Thanks for sharing. :cool:
Glad to hear you're using this: I plan to keep it much more aggressively up-to-date than has been the case in the past, but don't hesitate to let me know if you find errors or need clarifications.:)
__________________
Une simulation pret personnel en ligne, Un calcul taux pret personnel en ligne, Demande financement et demande credit personnel
 

jpanhalt

Joined Jan 18, 2008
11,087
In answer to the question of "how subject" pushbuttons are to bouncing, this reference by Ganssle shows some quantitative studies of bouncing: http://www.ganssle.com/debouncing.pdf. Figure 3, page 15 is very similar to the one referenced by John Luciani above.

There are lots of individual schema that debounce. One of my favorites is this from MIT:



However, since you are using a microcontroller, why not just do the debounce in software?

John
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
detect state change on an input (switch push)
goto a delay
wait 40ms
return

??? keep in mind I'm paraphrasing
Yep, that's the idea. A delay of 40 ms is a bit long. You may consider something like 10 ms after reading the Ganssle paper. The project I posted here for a Capacitor Discharge Welder uses 10 ms, and the code is there for a 12FXXX chip.

John
 

russ_hensel

Joined Jan 11, 2009
825
I hate to just use a delay, just by instinct. Note that the RC filter above into a schmidt trigger ( on the input of many microcontrollers ) should have very little bounce.
 

Tahmid

Joined Jul 2, 2008
343
Hi Ke5nnt,
You can use hardware for De-bounce but consider a case where many switches have to be used in let say 10 switches. Then you have to use extra hardwares for those switches and if you use software delay De-bounce routine, you can use the same routine 10 times.
You can use short delay like 10ms or less for De-bounce routine,but I think it is safe to use longer delay.
Thanks.
 
Top