Switches and microcontrollers

Discussion in 'Embedded Systems and Microcontrollers' started by ke5nnt, Oct 5, 2009.

  1. ke5nnt

    Thread Starter Active Member

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

    Senior Member

    Sep 26, 2009
    2,675
    234
    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.
     
  3. Tahmid

    Active Member

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

    Well-Known Member

    Aug 15, 2007
    536
    26
    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
     
  5. John Luciani

    Active Member

    Apr 3, 2007
    477
    0
    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 *)
     
  6. quiismsky

    New Member

    Oct 6, 2009
    1
    0
    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
     
  7. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,694
    904
    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:

    [​IMG]

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

    John
     
    Last edited: Oct 6, 2009
  8. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    detect state change on an input (switch push)
    goto a delay
    wait 40ms
    return

    ??? keep in mind I'm paraphrasing
     
  9. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,694
    904
    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
     
  10. russ_hensel

    Well-Known Member

    Jan 11, 2009
    818
    47
    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.
     
  11. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
    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.
     
Loading...