Debounce time & stable time for keyboard interfacing

Discussion in 'General Electronics Chat' started by aamirali, Feb 26, 2013.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    I am interfacing keyboard.
    I have kept debounce time = 20ms.

    What should be stable state time period for normal keyboard interfacing
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    There is no predetermined time for switch debouncing. Each switch is different, even within a class of switches. 20ms is typically a good place to start from, but it can be more or less depending on your switches. If you want to be really sure, measure the bounce time over multiple iterations for each key and take the greatest settling time to be your debouncing time.

    Since that's generally more work than desired, pick a number and see if you get any recognizable bounce, adjust accordingly over multiple iterations....
  3. tinamishra

    New Member

    Dec 1, 2012
    Bouncing is the tendency of two metal contacts in an electronic device the aim is to generate multiple signals as the contacts close or open, Debouncing is any kind of device or software which ensures that only a single signal will acted upon for the single opening or closing of a contact.
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    Thank you for that.... However bounce is generally regarded as being a bad thing, and certainly not something to aim for.

    Salesperson: "Hey, I've got these great switches, they have contact bounce on the order of seconds!"
    Anyone: "Goodbye!"
  5. ScottWang


    Aug 23, 2012
    Software and Hardware Switch Debounce as this.
    Software Switch Debounce as this.

    Normally I am using 20~40mS in the software, but I will adding some more when I am using in the hardware.
  6. GopherT

    AAC Fanatic!

    Nov 23, 2012
    Any longer than 40 mSec and you can run into problems with the next keystroke being missed.
  7. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    Shouldn't be a problem if you do parallel debouncing.

    One method I have used to good effect is to poll all buttons every 1mS, then if any button is pressed for >20mS CONTINUOUSLY (ie 20 consecutive tests at 1mS between each test) the button is officially "pressed". That can detect parallel pressing with no problems.

    An additional high-quality feature is to make sure the button is released for >50 counts of 1mS, before it can register being "pressed" again. You can re-use the same debouncing variables etc.
  8. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    A simple way of fixing most issues is a small capacitor, SMD, across the switch contacts, and a resistor feeding the + or - side of switch will provide a good deal of debouncing. 100k and 0.1uF catches most.

    I've been very annoyed by keypads that went too far in key debouncing (Some ATMs, but mostly credit card keypads) Roughly 10-12 presses per second on key-presses is about the fastest somebody can hit a button if it is a keypad, and they aren't trying to "outrun" it.