Ideas for circuit without MCU that needs switch debounce
Started by 4 years ago●15 replies●latest reply 4 years ago●252 viewsI need to write a column about using hardware techniques to debounce switches -- if the circuit included an MCU we could do the debounce in software, so I'm looking for ideas for circuits/functions that might not have an MCU but that woudl need switch debounce -- any ideas?
Sad to say there is NO good answer in hardware, time constants for debounce will work on some, but not for others. It Totally depends on the mechanical build and how it manifests in electrical. I've fought this for decades, best I've found is recent chips do a great job for hardware. Prior to this, I wrote a software loop set that on seeing a state change starts a counter that decrements unless a state change is seen, which reloads the counter. On counter zero, stable state change is presumed ok.
So, a valid state change has to uniformly persist for the count period. Best part is you set the persistence count. I wrote this after getting apoplectic on trying to do it in hardware on automotive toggle switches (they could dribble a basketball). L8R <<<)))
Yes! Toggle switches are painful to debounce, you put a scope on the thing and you can't believe what you're seeing...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
Actually, I did a 9-part mini-series on switch-bounce (see links below) -- I used to be a hardware fan -- then a software supporter -- now I love the debounce chips from LogiSwitch.net (I think I covered them in Part 6) -- but what I'm talking about now is looking for example circuits that don't have MCUs so a software solution isn't a possibility.
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
https://www.eejournal.com/article/ultimate-guide-t...
A capacitor to ground would do it. Start with a 0.1 uF.
Hi, MaxMaxfield!
If the switch has two poles, one NC and one NO, an RS FlipFlop ( 2 cross-coupled NOR gates ) will do the job.
Otherwise, there is a myriad of methods ranging from the simple ( and humble ) capacitor to sophisticated circuits with monostables and even hardware state machines!
It's all a matter of balance between cost and performance, response time and effectiveness.
And as stated by CustomSarge, it is not guaranteed that it will work for all situations.
It depends on how much the voltage bounces during "debounce" period. On could use a comparator with large Hysteresis in addition to capacitor as suggested by someone else to prevent bouncing voltage from getting through.
seems most of the answers so far are unaware that you have already tackled the topic of debounce in quite some depth and that your question is about where hardware debounce might be used today, in the rare event that there is no micro to help out.
Supplying a bit more information in my reply to your question elsewhere, a digital pot with up/down functions like the Maxim DS1804.
https://datasheets.maximintegrated.com/en/ds/DS1804.pdf
Some more modern devices may have debounce built-in, like the Analog Devices AD5116
Thanks Aubrey -- I love your trimpot suggestion -- I fear that since so many people misunderstood my question, it's probably my fault for not articulating it well enough.
Of course there are a few applications where one is using a really small memory limited micro with no code space left for a debounce routine
also, when measuring elapsed time (edge to edge) depending on hardware or your software, you are likely to get a more consistent measurement using hardware
That's a good point about a tiny micro
Here is a circuit that I have used to denounce a switches in various hardware designs. The circuit using U1 generates high going pulse. The circuit using U2 generates a low going pulse. The values of R4 and C1 or R3 and C2 shown provide a 10msec time constant, which I have found to work with various tactile switches I have used. The time constant can be adjusted to meet the characteristics of a specific switch. The resistors R1 and R2 are use to limit inrush current, if required.
Appropriate credit would be appreciated. An Eagle cad file can be provided, if desired.
Ns Antedeluvian noted in his comment above, I wasn't actually looking for a circuit, but this one is very interesting because it's a twist on one I documented in my miniseries (see image below) -- so in your left-hand circuit you charge your capacitor via R4 and discharge it via R1, thereby providing a nice separation -- the circuit I showed (below) required a diode to achieve this separation (see the column https://www.eejournal.com/article/ultimate-guide-t...) hmmmm, interesting...
Hi Max, interesting question, "circuits/funtions" covers a lot of territory!
There are canned debounce ICs available from various sources. Easy and reliable, this is a good choice for new designs.
If you're bringing the button directly into an FPGA or similar you have the option of synchronizing the input level to a sampling clock domain and constructing a debounce state machine circuit that does the same thing an MCU does in software. (If a software debounce solution doesn't map neatly to a hardware FSM, I think many would agree that the software solution could stand some tidying up!)
An old-school discrete circuit method often uses a pull-up resistor or divider to set an upper voltage (button open), with another resistor in series with a push button to GND defining a lower voltage (button closed). The common node of these resistors is connected to a Schmitt trigger input circuit (or equivalent with hysteresis) and includes a capacitor to GND. Voltages are chosen to guarantee margin relative to input switching thresholds. The input node charge and discharge time constants are controlled, and the RC time constant selection is a trade off between the minimum pulse width passed vs. the responsiveness of the push button. There is no one size fits all circuit, but with appropriate voltage margin and RC time constant selection it can be made to be very reliable for a given application. There are many variations on this type of circuit, examples are easy to find.
There is also the option of using a flip-flop as a debounce circuit in various ways, I don't favor this solution for a couple reasons. One is that whenever you connect a push button input directly to an async SET or CLR, to a CLK, or to the D input of a clocked device, you have built a glitch-catcher. Another is the issue of metastability when you violate minimum high/low times on SET, CLR or CLK, or setup/hold times on D wrt. CLK. This solution generally works and is fine for certain ad-hoc applications, but has reliability issues that will become apparent with sufficient usage.
Perhaps someone has figured out how to implement a debounce circuit with qubits. You never really know if the button is open or closed, you only know which state is more probable!