Author Topic: Switch contact debouncing. I found this resource helpful.  (Read 1603 times)

0 Members and 1 Guest are viewing this topic.

Offline wilfredTopic starter

  • Super Contributor
  • ***
  • Posts: 1252
  • Country: au
Switch contact debouncing. I found this resource helpful.
« on: May 30, 2014, 12:46:35 am »
/.
« Last Edit: August 21, 2018, 10:40:05 am by wilfred »
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: Switch contact debouncing. I found this recource helpful.
« Reply #1 on: May 30, 2014, 03:06:32 am »
That's a lesson every micro newbie has to learn the hard way.  I managed to reliably crash an Arduino with a mechanical rotary encoder by trying to use interrupts.  If you twirled the knob fast enough, it would lock up and/or restart.

That read-and-shift code works really well.  I consider that the ideal software debounce method, although I do tend to use the dumb routine (sample, wait 50ms, sample again, compare) for minor hobby projects. ::)
 

Offline georges80

  • Frequent Contributor
  • **
  • Posts: 912
  • Country: us
Re: Switch contact debouncing. I found this resource helpful.
« Reply #2 on: May 30, 2014, 06:03:28 am »
Seems a little 'extreme' to just state not to connect a switch to an interrupt pin. I do that on most of my designs, wakeup on interrupt or pin change (interrupt). Once awake I then disable further interrupts on that pin and transition to a timer driver interrupt routine that then samples and debounces the switch. Very easy to implement.

So, yes, connecting a switch with bounce to an interrupt pin AND trying to use interrupts to detect switch status is not a good idea, but no reason to not use an interrupt pin as the wakeup source.

I can safely say that with several 10's of thousands of shipped boards that this scheme works 'just fine'...

cheers,
george.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf