1
\$\begingroup\$

I have a push button that I would like to debounce. I only care about the first rising edge of the signal which is connected to an Arduino's GPIO. After reading on the web about hardware debouncing, I understand that to truly debounce a push button, I would need a latch or a logic gate to keep a sharp edge that the Arduino could read correctly. But I don't have any and it takes a month to order anything from where I am.

So, I came up with this circuit attending to avoid using extra parts:

First edge debouncing

I would like someone to help confirm the following assumptions:

When the button is pressed, C1 will charge almost instantly because there is no resistor to slow it down. When the button is released, C1 will slowly (0.1s) discharge thru R1. This should debounce the rising edge of the button as after the initial rise, R1 prevent C1 to discharge thus keeping the GPIO high.

I don't own a oscilloscope to test this. So this is just what I'm assuming will happen.

My questions are:

  • Is it safe to charge C1 so fast?
  • Is it safe for the GPIO?
  • Are my assumptions correct?
\$\endgroup\$
  • 3
    \$\begingroup\$ why not put a small resistor (with resistance much smaller than R1) in series with the push-button switch S1? to debounce the rise. BTW, i is not uncommon at all in digital circuits and connections to GPIO to a microprocessor to use active-low logic convention. so the voltage will normally be high when the button is not depressed and will go low when the button is depressed. \$\endgroup\$ – robert bristow-johnson Jul 29 '16 at 21:17
  • 2
    \$\begingroup\$ One fine day you will discover how to implement a digital filter (takes 3 bytes of ram) for noisy digital inputs. Then the RC filters become simple RF noise filters. \$\endgroup\$ – Sparky256 Jul 29 '16 at 21:31
  • 1
    \$\begingroup\$ Debounce it in software. NOBODY is debouncing switches in hardware if the switch goes to a microprocessor. If you do this as you plan, C1 needs to be small to avoid loading the 5V rail. I would think that 0.1 or 0.01uF would work, but I don't know how much capacitance you have on 5V. \$\endgroup\$ – mkeith Jul 30 '16 at 4:18
  • 3
    \$\begingroup\$ Lies and mistruths. Many people debounce in hardware. You want an active high debounce circuit. It would be easier as an active low. I'm not familiar with an active high RC debounce. \$\endgroup\$ – Passerby Jul 30 '16 at 6:23
  • 1
    \$\begingroup\$ @Passerby, I have not seen a de-bounced connection to a microprocessor GPIO input that I can remember. Ever. I think it must be exceedingly rare. If it is not a GPIO, then maybe. \$\endgroup\$ – mkeith Jul 30 '16 at 16:13
1
\$\begingroup\$

In my opinion it should work. If you are afraid of the charge rate of C1, you can add a resistor between S1 and +5V. This way, you limit capacitor's loading rate.

By the way, you can simulate your circuit on LTspice, it's a free and helpful software.

\$\endgroup\$
  • \$\begingroup\$ A capacitor cannot be charged or discharged instantaneously, to attempt to do so can result in high frequency oscillations or noise spikes. You must install a resistor in series with the capacitor to do the charge or discharge over time. \$\endgroup\$ – Harvard Jul 29 '16 at 22:02
  • \$\begingroup\$ Remember, the switch and wiring have intrinsic (parasitic) resistance. Nothing is happening instantly or having infinite current. \$\endgroup\$ – user2943160 Jul 30 '16 at 2:32
1
\$\begingroup\$

enter image description here

Blue Highlighted wire goes to gpio. Inductor and 10ohm just emulate the switch. Let me know is this works.

Being this circuit as active low debounce circuit and your requirement may be active high debounce, you can invert the states in the code and it will become high debounce circuit.

\$\endgroup\$
  • \$\begingroup\$ What's with all the tuned circuits? This does not answer the OP's question. \$\endgroup\$ – Sparky256 Jul 31 '16 at 0:08
  • \$\begingroup\$ As i have mentioned, inductor and 10 ohm resistor just depict the practical switch and nothing else. Hence, the actual circuit will be just switch in that path. The user wants to avoid the debounce, which is done by this circuit. Both the edges of output are smooth with no ringing. \$\endgroup\$ – Omibuddyy Jul 31 '16 at 4:14

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.