Maker Pro
Maker Pro

switch debouncing

M

Mac

Is there a standard or best way to de-bounce a switch?

After googling for a bit, this seems to be a good candidate:


VCC
|
\
R1 /
\
/
| Schmitt
| trig inverter
| |\
+---/\/\/--+-----| >-- out
| R2 | |/
S1 \ = C
| |
--- ---
GND GND


R2 might be 18 k, and R1 82 k, with a 1uF cap as per this article:

http://www.embedded.com/showArticle.jhtml?articleID=18902552

Seems like it should work. Any comments?

--Mac
 
J

Jonathan Kirwan

Is there a standard or best way to de-bounce a switch?

After googling for a bit, this seems to be a good candidate:


VCC
|
\
R1 /
\
/
| Schmitt
| trig inverter
| |\
+---/\/\/--+-----| >-- out
| R2 | |/
S1 \ = C
| |
--- ---
GND GND


R2 might be 18 k, and R1 82 k, with a 1uF cap as per this article:

http://www.embedded.com/showArticle.jhtml?articleID=18902552

Seems like it should work. Any comments?

He also wrote a somewhat longer piece a little later on, that year:

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

Jon
 
F

Fred Bloggs

Is there a standard or best way to de-bounce a switch?

What is it with you people looking for a "standard way" all the time?
After googling for a bit, this seems to be a good candidate:


VCC
|
\
R1 /
\
/
| Schmitt
| trig inverter
| |\
+---/\/\/--+-----| >-- out
| R2 | |/
S1 \ = C
| |
--- ---
GND GND


R2 might be 18 k, and R1 82 k, with a 1uF cap as per this article:

http://www.embedded.com/showArticle.jhtml?articleID=18902552

Seems like it should work. Any comments?

Pure "bit head" guess work. The worst case occurs when the switch opens
on bounce immediately after pulling the Schmitt input across its low
threshold and the circuit starts to recharge C back towards Vcc. You
obviously don't want the voltage to cross the positive threshold again.
Using VT+ as positive threshold, VT- as negative threshold, and VH as
hysteresis, a worst case calculation for the 74HC14 would look something
like this when you settle on a maximum bounce time an order of magnitude
larger than switch specification. This usually means less than one
chance in a billion of ever seeing a glitch aka switch has failed. A 5ms
switch calculation would look like so:
View in a fixed-width font such as Courier.
 
S

Spehro Pefhany

Is there a standard or best way to de-bounce a switch?

After googling for a bit, this seems to be a good candidate:


VCC
|
\
R1 /
\
/
| Schmitt
| trig inverter
| |\
+---/\/\/--+-----| >-- out
| R2 | |/
S1 \ = C
| |
--- ---
GND GND


R2 might be 18 k, and R1 82 k, with a 1uF cap as per this article:

http://www.embedded.com/showArticle.jhtml?articleID=18902552

Seems like it should work. Any comments?

--Mac

If it's going into a microcontroller, firmware is almost always the
best way.


Best regards,
Spehro Pefhany
 
F

Fred Bloggs

Spehro said:
If it's going into a microcontroller, firmware is almost always the
best way.


Best regards,
Spehro Pefhany

Well, if you can arrange things with external hardware so that the
switch input is always valid, that is just that much less the firmware
has to do- especially if the switch input is a very infrequent occurrence.
 
J

John Larkin

Well, if you can arrange things with external hardware so that the
switch input is always valid, that is just that much less the firmware
has to do- especially if the switch input is a very infrequent occurrence.

But firmware is free!

If you sample the switch state periodically at a rate slower than the
longest possible bounce time, then you don't need to do any software
debouncing. Something like 5-10 Hz sample rate plays right into
typematic logic if you want to do that, too.

John
 
S

Spehro Pefhany

Well, if you can arrange things with external hardware so that the
switch input is always valid, that is just that much less the firmware
has to do- especially if the switch input is a very infrequent occurrence.

Timer-interrupt driven periodic (in the 100-500Hz range) polling uses
negligible bandwidth of a modern processor for any reasonable number
of keys. Even if its a frequent occurence. And it can filter out
electrical noise and momentary contact breaks due to shock or
vibaration as well, if you choose to write it to do so.

There is reason to add some external hardware (especially to deal with
ESD issues and possibly with the miserably small and variable current
that on-board pullups typically deliver) but not for the deboucing.
Even a crummy on-board RC clock will yield debouncing times accurate
within a few percent at zero additional cost, and les need to test the
board for missing parts.


Best regards,
Spehro Pefhany
 
H

Harry Dellamano

John Larkin said:
John Larkin said:
On Tue, 18 Oct 2005 15:17:08 GMT, "Harry Dellamano"




.
.
.
.
. VCC
. |
. +-------+
. | |
. | - 74HC14
. [R1] ^
. | | G1
. | | |\
. +-[R2]--+----+---| o---+---->
. | | | |/ |
. o | | |
. -| - === |
. o ^ |C G2 |
. | | | /| |
. +-------+ +---o |---+
. | \|
. ---
. ///
.


Now when you have a switch closure that transitions G1 input to VT- ( in
a
time >=Tmax), G2 reinforces this in a time 2xTpd very much less than any
possibility of an (R1+R2)C pull-up through VH, so that G1 input is
pulled
towards (VT-)-5V, clamped by the diode at -Vf, and the capacitor
discharges to 0V top-to-bottom through the diode->G2 output->GND->diode
loop and the position of the switch is of no consequence until G1 input
reaches 0V, at which point it assume control of the circuit state. You
have a similar action upon switch release and G1 input exceeds VT+. The
G1
input waveform would look something like this:
View in a fixed-width font such as Courier.

.
.
. +5.7V -----
. | \
. 5V | | 5V
. \ 20ms VT+ | ------
. \ /
. \ /
. \ /
. \ VT- /
. | / 20ms
. | 0V /
. | ---------
. | |
. | /
. -0.7V -----
.
.
Hey F B, you are getting close to something really good!
Now parallel C with an R3 to set any hysterias desired. Used this many
times, works like a champ.
Regards,
Harry


I suppose that, if parts are good, then more parts must be better.

John

Ok John,
If your switch closure is on the front wheel of a AB360 (Airbus) with 100s
feet of wiring thru power cables with 10KV transients then a switch receiver
with 1.0V of forward hysterias and +/-5V of transient hysterics and the
flying cap acting as a low pass filter when the output is in the high or low
states requires some parts. I have not seen a switch receiver more tolerant
of noise.
What say you JL??
Regards,
Harry
John, John you are killing me and making me look bad to FB.
Let me try to answer these probing questions.
What sort of response time do you need on a wheel switch?

<100mS is ok.
With 10KV transients (where do you get them on a plane?) I'd be more
worried about the resistors, R1 and R2, arcing over. That's an
ESD-type issue, distinct from denouncing.

True but input is transzorbed to protect resistors.
C, being ungrounded, no longer protects the semiconductors from ESD
zaps.

C is not ungrounded it is tied to AC ground thru G2 < 50 output R and forms a low pass input filter with R2. The low output R of G2 is vital to circuit operation.
I'd also worry about G1 latching up, especially at high temp, since G2
is going to overdrive its substrate diodes pretty hard. Some HC-family
parts can be made to latch (parasitic PNPN scr, Vcc to ground) at
modest currents, and that will fry the chip and possibly drag down Vcc
of the whole system. Or an ESD arc across R2 might latch either gate.

Good point, the circuit shown is only conceptual. There is a 510R between G1's input and the C,R2 node. These ICs are rated +/-20ma input latching current so the two clamp diodes are not needed with large values of R2
A healthy high-frequency transient might well pump two or more edges
through G1 before the G2 hysteresis can respond. Guaranteed, actually.

Guaranteed, Let's calculate the voltage change necessary at the input to cause a miss trigger to propergate from G1 to G2.
Ein = Ehy*R2*C/Tpd= (1.0*1e5*1e-7)/1e-8 = 1,000,000 volts
This is a ROM and I did take liberties but you get the idea. Actually because of G2's output 50R and R2=1e5 we only need a 2000V input change to cross the 1V hytersis threshold.
Overall, looks like more problems created, or at least needing to be
carefully analyzed, than solved. I'd be surprised if this circuit were
used on flight hardware.

That is exactly what my customer is talking about.
 
J

John Larkin

John Larkin said:
On Tue, 18 Oct 2005 15:17:08 GMT, "Harry Dellamano"




.
.
.
.
. VCC
. |
. +-------+
. | |
. | - 74HC14
. [R1] ^
. | | G1
. | | |\
. +-[R2]--+----+---| o---+---->
. | | | |/ |
. o | | |
. -| - === |
. o ^ |C G2 |
. | | | /| |
. +-------+ +---o |---+
. | \|
. ---
. ///
.


Now when you have a switch closure that transitions G1 input to VT- ( in
a
time >=Tmax), G2 reinforces this in a time 2xTpd very much less than any
possibility of an (R1+R2)C pull-up through VH, so that G1 input is
pulled
towards (VT-)-5V, clamped by the diode at -Vf, and the capacitor
discharges to 0V top-to-bottom through the diode->G2 output->GND->diode
loop and the position of the switch is of no consequence until G1 input
reaches 0V, at which point it assume control of the circuit state. You
have a similar action upon switch release and G1 input exceeds VT+. The
G1
input waveform would look something like this:
View in a fixed-width font such as Courier.

.
.
. +5.7V -----
. | \
. 5V | | 5V
. \ 20ms VT+ | ------
. \ /
. \ /
. \ /
. \ VT- /
. | / 20ms
. | 0V /
. | ---------
. | |
. | /
. -0.7V -----
.
.
Hey F B, you are getting close to something really good!
Now parallel C with an R3 to set any hysterias desired. Used this many
times, works like a champ.
Regards,
Harry


I suppose that, if parts are good, then more parts must be better.

John

Ok John,
If your switch closure is on the front wheel of a AB360 (Airbus) with 100s
feet of wiring thru power cables with 10KV transients then a switch receiver
with 1.0V of forward hysterias and +/-5V of transient hysterics and the
flying cap acting as a low pass filter when the output is in the high or low
states requires some parts. I have not seen a switch receiver more tolerant
of noise.
What say you JL??
Regards,
Harry
John, John you are killing me and making me look bad to FB.
Let me try to answer these probing questions.
What sort of response time do you need on a wheel switch?

<100mS is ok.
With 10KV transients (where do you get them on a plane?) I'd be more
worried about the resistors, R1 and R2, arcing over. That's an
ESD-type issue, distinct from denouncing.

True but input is transzorbed to protect resistors.


Well, that wasn't shown.
C is not ungrounded it is tied to AC ground thru G2 < 50 output R and forms a low pass input filter with R2. The low output R of G2 is vital to circuit operation.


Neither end of C is connected to ground; both ends are connected to
semiconductors, and semiconductors are what's killed by esd zaps. 50
ohms won't impress a good arc, or G2 can be the IC that's killed. Of
course, the transzorbs fix that problem.

One of my pretty firm rules is to never have semiconductors connected
to the outside world, arcs included.
Good point, the circuit shown is only conceptual. There is a 510R between G1's input and the C,R2 node.

This schematic seems to have all sorts of invisible parts. Good, that
resistor definitely shifts the damage path toward G2.
These ICs are rated +/-20ma input latching current so the two clamp diodes are not needed with large values >of R2


Guaranteed, Let's calculate the voltage change necessary at the input to cause a miss trigger to propergate from G1 to G2.
Ein = Ehy*R2*C/Tpd= (1.0*1e5*1e-7)/1e-8 = 1,000,000 volts
This is a ROM and I did take liberties but you get the idea. Actually because of G2's output 50R and R2=1e5 we only need a 2000V input change to cross the 1V hytersis threshold.

Again, assuming R2 doesn't arc.
That is exactly what my customer is talking about.

Well, if you analyze it carefully enough it should be OK. But simpler
circuits have less hazards. Without the transzorbs, this one would be
scairy.

John
 
J

Jim Thompson

You want debounce. See....

Newsgroups: alt.binaries.schematics.electronic
Subject: Switch Debounce (from S.E.D) - NoiseBlank-555-RC.pdf
Message-ID: <[email protected]>

...Jim Thompson
 
W

Winfield Hill

Jim Thompson wrote...
You want debounce. See....

Newsgroups: alt.binaries.schematics.electronic
Subject: Switch Debounce (from S.E.D) - NoiseBlank-555-RC.pdf
Message-ID: <[email protected]>

I've seen switches with bounces 50 to 500x as long as yours.
 
J

Jim Thompson

Jim Thompson wrote...

I've seen switches with bounces 50 to 500x as long as yours.

Sheeesh, Win, It's just an example, dredged from a noisy voltage
signal application... change the RC already!

I have some EXTREME "debouncers" if anyone is interested.

...Jim Thompson
 
F

Fred Bloggs

Jim said:
You want debounce. See....

Newsgroups: alt.binaries.schematics.electronic
Subject: Switch Debounce (from S.E.D) - NoiseBlank-555-RC.pdf
Message-ID: <[email protected]>

...Jim Thompson

I'm not sure that could be called a debouncer- maybe more of a noise
blanker. You have that known V1 clock and corrupt it with much higher
frequency (1-V2V3/25). A switch debouncer does not have that luxury.
 
F

Fred Bloggs

John said:
John Larkin said:
On Wed, 19 Oct 2005 01:09:48 GMT, "Harry Dellamano"



On Tue, 18 Oct 2005 15:17:08 GMT, "Harry Dellamano"




.
.
.
.
. VCC
. |
. +-------+
. | |
. | - 74HC14
. [R1] ^
. | | G1
. | | |\
. +-[R2]--+----+---| o---+---->
. | | | |/ |
. o | | |
. -| - === |
. o ^ |C G2 |
. | | | /| |
. +-------+ +---o |---+
. | \|
. ---
. ///
.


Now when you have a switch closure that transitions G1 input to VT- ( in
a
time >=Tmax), G2 reinforces this in a time 2xTpd very much less than any
possibility of an (R1+R2)C pull-up through VH, so that G1 input is
pulled
towards (VT-)-5V, clamped by the diode at -Vf, and the capacitor
discharges to 0V top-to-bottom through the diode->G2 output->GND->diode
loop and the position of the switch is of no consequence until G1 input
reaches 0V, at which point it assume control of the circuit state. You
have a similar action upon switch release and G1 input exceeds VT+. The
G1
input waveform would look something like this:
View in a fixed-width font such as Courier.

.
.
. +5.7V -----
. | \
. 5V | | 5V
. \ 20ms VT+ | ------
. \ /
. \ /
. \ /
. \ VT- /
. | / 20ms
. | 0V /
. | ---------
. | |
. | /
. -0.7V -----
.
.

Hey F B, you are getting close to something really good!
Now parallel C with an R3 to set any hysterias desired. Used this many
times, works like a champ.
Regards,
Harry


I suppose that, if parts are good, then more parts must be better.

John

Ok John,
If your switch closure is on the front wheel of a AB360 (Airbus) with 100s
feet of wiring thru power cables with 10KV transients then a switch receiver
with 1.0V of forward hysterias and +/-5V of transient hysterics and the
flying cap acting as a low pass filter when the output is in the high or low
states requires some parts. I have not seen a switch receiver more tolerant
of noise.
What say you JL??
Regards,
Harry
John, John you are killing me and making me look bad to FB.
Let me try to answer these probing questions.
What sort of response time do you need on a wheel switch?

<100mS is ok.

With 10KV transients (where do you get them on a plane?) I'd be more
worried about the resistors, R1 and R2, arcing over. That's an
ESD-type issue, distinct from denouncing.

True but input is transzorbed to protect resistors.



Well, that wasn't shown.

C is not ungrounded it is tied to AC ground thru G2 < 50 output R and forms a low pass input filter with R2. The low output R of G2 is vital to circuit operation.



Neither end of C is connected to ground; both ends are connected to
semiconductors, and semiconductors are what's killed by esd zaps. 50
ohms won't impress a good arc, or G2 can be the IC that's killed. Of
course, the transzorbs fix that problem.

One of my pretty firm rules is to never have semiconductors connected
to the outside world, arcs included.

Good point, the circuit shown is only conceptual. There is a 510R between G1's input and the C,R2 node.


This schematic seems to have all sorts of invisible parts. Good, that
resistor definitely shifts the damage path toward G2.

These ICs are rated +/-20ma input latching current so the two clamp diodes are not needed with large values >of R2



Guaranteed, Let's calculate the voltage change necessary at the input to cause a miss trigger to propergate from G1 to G2.
Ein = Ehy*R2*C/Tpd= (1.0*1e5*1e-7)/1e-8 = 1,000,000 volts
This is a ROM and I did take liberties but you get the idea. Actually because of G2's output 50R and R2=1e5 we only need a 2000V input change to cross the 1V hytersis threshold.


Again, assuming R2 doesn't arc.

That is exactly what my customer is talking about.


Well, if you analyze it carefully enough it should be OK. But simpler
circuits have less hazards. Without the transzorbs, this one would be
scairy.

John

Did the OP say he was designing a wheel-well switch for the AirBus?
 
J

Jim Thompson

I'm not sure that could be called a debouncer- maybe more of a noise
blanker. You have that known V1 clock and corrupt it with much higher
frequency (1-V2V3/25). A switch debouncer does not have that luxury.

The sources are for illustration ;-) NOT "known V1 clock"... it's NOT
a clocked system... look carefully before leaping for a change.

...Jim Thompson
 
J

John Fields

Sheeesh, Win, It's just an example, dredged from a noisy voltage
signal application... change the RC already!

I have some EXTREME "debouncers" if anyone is interested.
 
J

John Larkin

Jim Thompson wrote...

I've seen switches with bounces 50 to 500x as long as yours.


I had a temperature switch that bounced forever. It was mounted in a
tugboat, on the side of a diesel engine.

John
 
J

Jim Thompson

See "NoiseBlank.pdf" on the S.E.D/Schematics page of my website for
several different variations.

...Jim Thompson
 
Top