0
\$\begingroup\$

I'm trying to filter the possible bounce of the mechanical switch S1. For a simulation of a sequence of pulses the voltage on C1 keeps adding, it discharges very slow, so after some 10 ms bounces the output signal is activated:

enter image description here

If I place the Schottky diode D1 then it works much better (saw this in some book) but I don't understand why. This is the result:

enter image description here

But anyway the voltage in InputBySW is still increasing, is there a way to improve this?

EDIT:

I guess the effect of the diode is just its leakage current helping discharge the capacitor:

enter image description here

So my question remains, how to decrease the discharge time of the capacitor?

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

It discharges very slowly because of the 20K resistor between it and the ground. What you need is a ON/ON switch which connects either to V+ or to GND. When it connects to GND, the capacitor discharges faster, whereas when connected to V+ it charges gradually thanks to R1. To discharge C1 immediately, you can add a schottky diode from from C1 to SW1 bypassing R1 (not visible on the schematic). R2 prevents bounces and spikes to hit the input before being swallowed by the capacitor.

Values of R1, R2 and C1 are aproximative and up to your discretion.

The Zener diode D1 is better than a voltage divider with two resistors because bounce spikes can be much higher than the supplied voltage. The zenner will always give a predictable voltage while a voltage divider will only divide the voltage it's given and may be higher than expected. Of course you can replace the zenner diode with a resistor if you want or doubling the zenner diode with a resistor in case the switch would be floating or if you can't put a ON/ON switch. If you can't use such a switch, then we must think about reducing the impedance of the resistor to ground. Or something else. But then, it will consume a little bit more power because the supply is 24V.

The schotky diode D2 prevents reverse current which happens inevitably with switch bounces.

schematic

simulate this circuit – Schematic created using CircuitLab

schematic

simulate this circuit

The second schematic shows a solution where ON/ON switch is not an option because we want to use a momentary switch. The idea is to fill C1 with already divided voltage. The zenner limits the voltage to the base voltage. C1 is only 1uF and R2 10K. Discharge time should 40x shorter than with 20uF + 20K.

\$\endgroup\$
12
  • \$\begingroup\$ If you zoom the images you can see its a 10uF capacitor. \$\endgroup\$ – Pedro NF Jun 9 '20 at 7:58
  • \$\begingroup\$ Connecting the diode between ground and SW doesn't make sense, it will not help discharging the capacitor. What I want is a faster capacitor discharge, I'm happy with charge time. The long charge time already filters small spikes but continuous spikes can be a trouble if the capacitor doesn't discharge fast enough. \$\endgroup\$ – Pedro NF Jun 9 '20 at 8:12
  • \$\begingroup\$ The choice of a voltage divider or a resistor zener combination is just a matter of choice and the result is the same. \$\endgroup\$ – Pedro NF Jun 9 '20 at 8:16
  • \$\begingroup\$ @PedroNF See my edited answer. \$\endgroup\$ – Fredled Jun 9 '20 at 11:16
  • 1
    \$\begingroup\$ The problem with your approach is that you can't modelize, or simulate switch bouncing. It's too random and unpredictable. You have to observe directly what happens with an oscilloscope and then apply a strategy. Why do you think you need 20uF? IMO 1uF should be enough and you divide the discharge time by 20 already. You can reduce R4 and R5 for the same purpose. As long as R4+R5 >= 10K ohm it should be ok. \$\endgroup\$ – Fredled Jun 9 '20 at 23:12
0
\$\begingroup\$

I kept the zener on the circuit in order to use this leak current to help discharge the capacitor. I ended up using a different circuit because I needed a pulse on the output even if the switch is kept active.

\$\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.