I have a doubt with debouncing. I have the circuit that is shown down and my debounce of the button works perfectly, but I need to know the theory of why it's working. I have the button connected with a pulll-up resistor of 10k and the capacitor that is connected to ground is of 0.1uF. When I use a RC circuit with a R of 220 ohms, it doesn't work, and when I quit the capacitor neither. I want to know what is this happening.
Well, take a look here and proceed in your project.
I am (always) inclined to ask why you would use this sort of hardware debouncing when you have a fully-fledged microcontroller on hand which can do a vastly better job - in software of course.
However, looking at the circuit you cited, it does not work in the first place. Something is missing.
10k x 0.1µ = 1ms time constant
220 x 0.1µ = 22µs time constant.
Thus your bounces are probably quicker than 1ms, but slower than 22µs
10ms is a safer debounce time-constant to aim for for general use, I'd suggest 33k and 330nF
as suitable values.
The time constant of an RC circuit is just RC. The unit of capacitance, the farad, can also be written as seconds/ohm (capacitance = charge/voltage = current/(voltage x time) = time / resistance)
Thus the units of RC are ohm x (seconds/ohm) = seconds.
I agree with the first para by Paul_B. It is better to do this in software. Unless you have some tricky time-dependent code.
Basically an easy way do do this is to look for a change in the button status (with digitalRead, then wait with delay(50) and then check the button again. If the digitalRead is the same then the button is pressed and de-bounced. You might need to alter the delay.
Other will have their own way to do this. But a delay() is the simplest.
However, in your circuit, what you are doing is charging the capacitor via a resistor when you press the button. When you release the button, the capacitor will stay charged (at least for some time).
Try putting a high value resistor across the capacitor (say 10K) and that might help. That resistor will discharge the capacitor when you release the button.
This assumes that the negative of the capacitor is connected to GND (0V) which isn't clear in the diagram.
It might have something to do the fact that it is miswired.
It should look like this:
with the switch connected to the point labeled Vc.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.