8
\$\begingroup\$

After dealing with software debouncing for a while, I find it takes a huge toll on the system, so I thought of initially making a hardware debouncer with one Schmitt trigger (74HC14), a capacitor, button and resistor as shown below from talkingelectronics.com:

talkingelectronics circuit

But I read that the Schmitt trigger is half as nasty as a regular inverter when determining when to output a high or low, because it switches state at the 33% and 66% mark where as a normal inverter would switch closer to the 50% mark (but with the HC version it's probably more at 55%).

I was wondering, because the Schmitt trigger is six inverters in one package, would debouncing substantially improve with any button of my choice applied to the first input if I made six of the circuit on the right hand side with the same component values and connected all of them in series? (Example: output of the first circuit to the input of the second circuit where the capacitor and resistor meet.)

\$\endgroup\$
  • 3
    \$\begingroup\$ "because it switches state at the 33% and 66% mark", isn't that the whole point of using a schmitt trigger?...So that there is a window in the middle where it doesn't switch, thus debouncing? \$\endgroup\$ – Bort Apr 26 '18 at 17:31
  • 5
    \$\begingroup\$ How does debouncing take a hughe toll on the system?? Software debounding can be as simple as keeping a 50 ms interval between reading the buttons. \$\endgroup\$ – Wouter van Ooijen Apr 26 '18 at 17:59
  • 2
    \$\begingroup\$ @Mike Maybe you have a misunderstanding about Schmitt-triggers? Are you aware that they have hysteresis, and that the asymmetric switch points are "overlapping": there is no mid-band where the signal is undefined. \$\endgroup\$ – pipe Apr 26 '18 at 20:06
  • 4
    \$\begingroup\$ Your problem isn't anything at all to do with this - your problem is that you don't know how to write software debouncing in a way which is not wildly inefficient. I strongly suggest posting another question on the code review forum to ask what you've done wrong in your software, because even the cheapest 8-bit processor can debounce a bunch of inputs without breaking sweat. \$\endgroup\$ – Graham Apr 26 '18 at 21:25
  • 2
    \$\begingroup\$ @Mike Unless you have thousands of events per second you have to debounce, I don't see how this could consume any measurable impact on runtime. \$\endgroup\$ – Dmitry Grigoryev Apr 27 '18 at 9:22
12
\$\begingroup\$

Using Schmitt triggers in series would not further reduce bounce.

Consider the filter:

Schmitt trigger waveform comparison

The input is (U). The red line is a 50% threshold, the output of which is seen as signal (A). It bounces each time the input crosses.

The green lines are something like 33% and 66%, as you had stated. But the output (B) only switches when the input (U) crosses from one green threshold to the other.

Most importantly, the output is either fully HIGH or LOW (digital). So if the output of a Schmitt trigger were fed into the input of another, there were be essentially no difference.

Take the filtered output from above (B), and think about how it would be seen by another Schmitt trigger:

Schmitt trigger in series with another

Again, the output of the first would be either HIGH or LOW. So it would cross the thresholds at the same time, resulting in the same output as the input. There is nothing to debounce! If anything, I would expect it to create more noise, because you're introducing more components and thus more room for error.

It sounds like what you may be looking for is a Schmitt trigger with adjustable thresholds. Some are symmetrical (for example: 33% and 66%, or 10% and 90%). Others are non-symmetrical (for example: 33% and 80%). You can create your own using an op-amp.

Try playing around with this simulation I put together a while back: Schmitt Trigger Simulation - Non-Inverting Non-Symmetric

Schmitt Trigger Simulation - Non-Inverting Non-Symmetric

\$\endgroup\$
  • \$\begingroup\$ Considering that I'll make a PCB, sometimes tying two inverters in series will make the PCB much easier to create. How much more noise will I expect if I tied two of these inverters in series? \$\endgroup\$ – Mike Apr 26 '18 at 23:57
  • \$\begingroup\$ For that setup, the "noise" would likely be negligible. There might be a microsecond of timing propagation. The voltage "noise" would not be too big an issue, as each trigger is a filter after all. I would not worry about it unless the application is heavily dependent on timing, but I'm guessing it's not because it's just a button. \$\endgroup\$ – Bort Apr 27 '18 at 2:03
15
\$\begingroup\$
Can multiple Schmitt triggers in series fully debounce a switch?

A single Schmitt trigger with a analog filter in front of it can be used for debouncing. However, after that Schmitt trigger, the signal is fully digital. Any additional Schmitt triggers won't change that. Ideally they will preserve the signal.

On a separate topic, debouncing in firmware shouldn't present much of a load. The usual way is to sample the switch state in a periodic interrupt you already have anyway. You declare the debounced state the current switch value when you've seen the switch in that state for N consecutive samples. I usually require the switch to be in the same state for 50 consecutive 1 ms interrupts for the new state to be considered valid. That usually takes a very small fraction of the overall processor cycles.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.