Debounce time & stable time for keyboard interfacing

Thread Starter

aamirali

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

What should be stable state time period for normal keyboard interfacing
 

tshuck

Joined Oct 18, 2012
3,534
I am interfacing keyboard.
I have kept debounce time = 20ms.

What should be stable state time period for normal keyboard interfacing
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....
 

tinamishra

Joined Dec 1, 2012
39
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.
 

tshuck

Joined Oct 18, 2012
3,534
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.
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!"
 

ScottWang

Joined Aug 23, 2012
7,398
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.
 

THE_RB

Joined Feb 11, 2008
5,438
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.
 

thatoneguy

Joined Feb 19, 2009
6,359
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.
 
Top