I have a friend runs a math summer camp here in Ann Arbor at the University of Michigan for smart young people. I’ll write more about this later, but here’s how he describes it:
We build a machine that will allow the user to enter data on a breadboard, using nothing more sophisticated than switches, logic gates, and flip flops, and have the result be a tweet that includes a picture. Our class of 16 students will each work on a portion of the machine, and at the end we’ll put it all together.
Since its inception, I’ve been the camp’s “electronics consultant.” I loan them a power supply every year, and have, in the past helped them with various electronics questions.
This year, my friend asked me how to debounce a switch. They use a pushbutton switch to clock in data, and as you can imagine, if the switch isn’t debounced properly, they get multiple clocks, which screw up the operation of their machine.
I understand debouncing, but to be honest, I never really had to design a debounce circuit. So, I did a little Googling and found, “A Guide to Debouncing” by Jack G. Ganssle. Ganssle. This 22-page monograph really gets into the theory of why switches bounce and describes several different ways to debounce a switch. One of the simplest ways to do this—and probably the most appropriate method for this project—is a simple RC circuit:
Basically, the way this works is that C charges to VCC, and when you throw the switch to take the logic circuit input low, C discharges. You set the values of C and R2 such that the time constant is at least as long as the time during which the switch bounces. Ganssle describes how to do this, and he’s even made some measurements on how much time you need for the switch to quit bouncing.
The diode in the circuit is optional. Its function is to speed up the capacitor charging once the switch is released.
I dug though my junk box and found all the components that I needed to breadboard the circuit, then used my fancy, new digital scope to observe both the bouncy switch input and the debounced circuit output. Here is the bouncy switch:
And here is the debounced waveform:
I know that this is a very simple circuit, and that I really shouldn’t be surprised that it works, but I like it when simple things work. The result here is that my friend’s summer camp will have a stable clock input, and the circuit is something that he can easily explain to the kids. It should be as educational for them as it was for me.
Bob, KG6AF says
I’d go with the S/R flip-flop debouncer, which Ganssle also describes. It needs an SPDT switch, but you don’t have to monkey with choosing the correct Rs and C.
As a digital designer, I get nervous whenever I look at a digital schematic and see capacitors on signal lines. It’s rarely a good sign. It’s not that there are no good reasons to use them, it’s just that there are so many bad reasons.
Dan KB6NU says
In general, I agree with you, Bob, but for this particular application, I think the RC circuit will work and be educational as well.
Bob, KG6AF says
I agree. I suspect that there are a lot of folks out there who don’t know that you have to debounce a switch in the first place, so this is a very useful project.
Ross Herbert says
Unless my logic is wrong the output of the inverter should be low when the NO switch is at rest. The output will go high when the switch is pressed. This is opposite to the scope trace.
M. Simon says
A simple zero debounce delay debouncer.
https://spacetimepro.blogspot.com/2023/09/switch-debouncer.html