2
\$\begingroup\$

I was reading a tutorial on debouncing the outputs of a rotary-encoder which are read by a micro-controller. Below is the circuit given:

enter image description here

The writer of the tutorial claims the following:

"In the above circuit we use a 1uF capacitor with an SN7414 Schmitt-trigger input NAND gates that clean up the switch-contact noise."

I have couple of questions regarding this claim and the circuit.

1-) I can understand the reason for the use of capacitors, they act as RC low pass filters and can filter bounces. But how does the SN7414 Schmitt-trigger help debouncing here? Is that really needed or does it improve debouncing?

2-) In the above circuit the resistor and the capacitor forms a low-pass filter with a cut-off freq. fc. What is the motivation/idea when it comes to sizing the capacitor here. Why 1uF? I mean let's say we have a rotary-encoder and it is recommended to be used with 10k resistors. Which parameter of the encoder from its data-sheet should be taken into account when sizing the capacitor. Is there a method or reasoning between choosing the capacitance and a parameter in the data-sheet?

\$\endgroup\$
1
  • \$\begingroup\$ This schematic was already discussed, but I like this question better so I suggest we close the other one as a duplicate of this one. \$\endgroup\$ Commented Jan 24, 2017 at 11:57

4 Answers 4

3
\$\begingroup\$

The schmitt trigger doesn't help debouncing in itself. But it is required because after the RC-filter, the signal will have slow rise/fall times (this is obviously the purpose). And signals with slow rise and fall times are not appropriate for feeding regular logic inputs. If the gate inputs stay "inbetween states" for a long time, you'll experience higher power consumption and may see instability problems. This is fixed by the schmitt triggers.

The capacitor can be sized easily, and depends on the "boucing time" indicated in the encoder datasheet. It also depends on the values of the pullup resistors. Basically, take a RC time constant (here 10k * 1µ = 10m) and it should be higher than the max bouncing time.

\$\endgroup\$
12
  • 2
    \$\begingroup\$ Note that some interface chips are designed with schmitt triggering inputs already, like a lot of AVRs, that can deal easily with slow rise time signals. \$\endgroup\$
    – PlasmaHH
    Commented Jan 24, 2017 at 11:27
  • \$\begingroup\$ @dim Thanks I appreciate for the answer to the second question. Just one more point I wonder. So he uses the schmitt -trigger to sharpen the pulses which are curved after RC. But for that to happen we should be sure that the schmitt -trigger itself doesn't introduce any noise or bouncing right?. And this then requires to add caps to power rails of the schmitt-trigger? Maybe SN7414 is a special one that just doesn't require any external caps? \$\endgroup\$
    – user16307
    Commented Jan 24, 2017 at 11:27
  • \$\begingroup\$ @PlasmaHH So do you think SN7414 actually not necessary? He uses an AVR. \$\endgroup\$
    – user16307
    Commented Jan 24, 2017 at 11:28
  • \$\begingroup\$ The principle of the schmitt trigger ensures that noise is filtered out, especially if preceded with a RC filter. A schmitt trigger has two input thresholds for switching from 0 to 1 and from 1 to zero. Have a look here. You can also use a schmitt trigger without prior RC filter, for example on a slow digital signal coming from an optocoupler. SN7414 is not special, I don't see why you went to think that. \$\endgroup\$
    – dim
    Commented Jan 24, 2017 at 11:35
  • \$\begingroup\$ Also, PlasmaHH is right. Whether you really need it or not depends on what chip you'll be feeding these signals to. Most MCU indeed integrates schmitt trigger inputs, in which case you don't need them. What MCU will you use? \$\endgroup\$
    – dim
    Commented Jan 24, 2017 at 11:37
2
\$\begingroup\$

1) Why use a Schmitt-trigger input device as a buffer.

With that RC low pass circuit you are going to get a fairly slow rise time on the signal. The signal will also have noise on it. If you have an input stage without much hysteresis then the combination of a slow rise time and noise can cause the signal to cross the threshold a couple of times and so generate the exact type of noise you are trying to avoid by using a denouncing circuit. By using a device with lots of hysteresis on the input you eliminate this risk.

Also some logic parts don't like slow ramp rates on their inputs, especially on clock inputs. I've had discrete D-type latches which have failed to clock reliably due to the clock signal coming from an RC rising too slowly.

2) Why that size capacitor?

You want a time constant that is fast in comparison to the rate at which the signals will be changing and too small for a person to notice but slower than the mechanical vibration of the contacts. A few milliseconds seems like a reasonable time period to aim for.
The exact value isn't that important, 10uF may be a little slow and 10nF would probably be a little fast but just about anything in between would probably work fine.

\$\endgroup\$
1
\$\begingroup\$

A quick look at major application of Schmitt trigger:
used to filter noise in digital lines:

enter image description here

The one used in the OP question is inverting schmitt trigger basically to improve the transition response of the circuit:
Yellow: Input
Green: Output

enter image description here

The capacitor size depends on the debounce time required by the encoder. In the datasheet of the encoder below spec. or similar will be mentioned:
RC time constant to be sized accordingly.

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ @downvoter please care to leave a comment \$\endgroup\$
    – User323693
    Commented Jan 24, 2017 at 13:55
0
\$\begingroup\$

we use a 1uF capacitor

A circuit like that most likely will work but it is wrong : I have seen cases where this type of circuit resets a MCU by pulling the input below ground.

Three tricks here:

  1. You should have a resistor between the capacitor and the switch. That defines the current during discharge. If undefined, that discharge current plus stray inductance, can bee quite nasty.
  2. You should use as small of a capacitance as possible. To limit the amount of energy dissipated when the switch is pressed. 0.1u would be my upper limit. 11n or 1n preferred.
  3. Use a switch with high contact resistance, if you want to eliminate thee resistor recommended in 1) above.

All of this is to reduce the discharge current and it's slew.

\$\endgroup\$
2
  • \$\begingroup\$ can you draw a simple diagram about your suggestion about R C and switch configuration? \$\endgroup\$
    – user16307
    Commented Jan 24, 2017 at 12:30
  • \$\begingroup\$ I saw many people are not happy with 0.1uF. They say they need to increase the capacitance. Here is one example: hifiduino.wordpress.com/2010/10/20/… \$\endgroup\$
    – user16307
    Commented Jan 24, 2017 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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