Guides to Switch Debouncing

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Often referenced here is Jack Ganssle's Guide to Debouncing:

 

http://www.ganssle.com/debouncing.htm

 

Here's another "Ultimate" Guide to Switch Debounce - from Clive "Max" Maxfield:

 

https://www.eejournal.com/article/ultimate-guide-to-switch-debounce-part-1/

 

https://www.eejournal.com/article/ultimate-guide-to-switch-debounce-part-2/

 

#Debounce

#ContactBounce

#SwitchBounce

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's also a couple of tutorials right here in the Tutorials forum:

 

[TUT][SOFT][HARD] Button debouncing in software

 

[TUT] [C] My technique for debouncing...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not to mention the classics from Lee Theusch and Peter Dannegger ("danni") and Johan's analysis of the two.

 

Actually a lot of it is all encompassed in the thread:  https://www.avrfreaks.net/forum/my-debouncingbutton-routines-comments-needed

Last Edited: Mon. Feb 3, 2020 - 04:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have references for them? I know what you mean, but I'm not finding the right keyword combination yet ...

 

frown

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See my edit to #3

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't understand why this seems to be a mystery to many people.  When the pin change interrupt happens, disable the interrupt for a while to allow the contacts to stop bouncing.  I guess 40 milliseconds is more than enough, but if you already have a periodic timer that has a longer period, you can use that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

steve17 wrote:
I don't understand why this seems to be a mystery to many people

I think in most cases here it's because people have simply not realised that bounce happens at all.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Aha!

 

"A walkthrough of Dannis debouncer" - here:  https://www.avrfreaks.net/comment/726676#comment-726676

 

Linked from: https://www.avrfreaks.net/commen...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When the pin change interrupt happens, disable the interrupt for a while to allow the contacts to stop bouncin

If you go that route make sure to disable the irq inside the IRQ (so it doesn't refire while going back to main, or before main has a chance to mess with it)...then after 40 ms in main, turn it back on.  You prob don't want to be hanging around in the irq waiting for 40ms.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

another tutorial

Bounce Free Switches Pushbutton and Micro Limit Switches (LogiSwitch)

[3/4 page]

SWITCH BOUNCE / DEBOUNCE TUTORIAL

...

 

POLLING VS. INTERRUPT DRIVEN

...

due to the comment by Luca Matteini in The Embedded Muse 354 by Jack Ganssle.

 

P.S.

Unified-memory AVR CCL and XMEGA XCL have flip flops.

Otherwise, a wee bit of HDL in a FPGA or cPLD.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...