# What causes the 7 volt peak in this 5 volt RC circuit, and why does a diode alleviate it?

I was reviewing this question on an RC circuit design from a Ben Eater video, and came across hacktastical's answer on how it was a bad design because it outputs 7 volts on release of the push button (which stresses the connected IC). They suggested adding a clamp diode, which mitigates the effect.

Here is the circuit in question (without the diode) -- simulate it here:

I went ahead and played with this circuit in Falstad, and it does indeed generate the 7V spike after button release. I also built the circuit on a breadboard and hooked it up to my scope to confirm, and observed the same phenomenon. Photos of my breadboard circuit and oscilloscope reading are below - note that I added 3 100nF capacitors in parallel to exaggerate the effect on the scope, and only had a 470 ohm resistor instead of 680.

My question is how is this 7 volt peak occurring? I do not understand how the output can be pushed to 2 volts ABOVE the 5 volt source voltage? I'm trying to wrap my head around it, but it's a bit beyond my hobbyist pay grade.

My educated guess would be that when the charged cap discharges itself through the series 1k and 680 resistors, the voltage drop across the second resistor (which is connected to output) would be about 2 volts (680/1680 * 5V = ~2V). Is this voltage simply just added to the 5V already coming from the supply? How is that possible?

This seems to make sense, since my scope is showing about a 6.7 volt peak in a circuit where I'm using a 470 ohm resistor instead (470/1470 * 5V = ~1.6V). 5V + 1.6V = 6.6v ... close enough to what I'm reading. But I would still prefer that someone could explain to me what's going on, as I'm not sure if my assumptions here are correct.

Adding a parallell clamp diode after the RC circuit and before the output, as seen below, mostly mitigates the effect (simulate it here. Why is this the case, and how come it doesn't COMPLETELY mitigate it? You still get about 5.5 volts on button release.

• You've seen a stack of 1.5 V AA batteries connected in series. Each AA is 1.5 V but a stack of four produces 6 V. That idea's what you're seeing here. The capacitor acts like a short-lived rechargeable battery. It's charged with the switch closed. With the switch open, the C-R-R circuit has a connection to 5 V, just like the AA cell has a connection to the one underneath it. Like them, that circuit is offset from GND by that voltage. This isn't an answer, just a guide. Once you get the pov, you'll understand the existing answers better. Jan 30 at 18:06
• Charged capacitor behaves just like a "small" voltage source. So, in your example just replace the capacitor with a 5V voltage source. And you will see why you see 7V.
– G36
Jan 30 at 18:19
• Otherwise known as a charge pump. The diode would be referred to as a clamp as there is no inductive flyback present. Examples of a charge pump would be the ubiquitous MAX232 chip which uses it to generate the positive and negative 7volts or so for RS232. Jan 30 at 22:37
• @Kartman corrected the diode terminology to clamp Feb 1 at 3:12

Initially, the capacitor has 5V across its plates.

When the switch closes the capacitor works like a voltage source over a voltage divider made up by the two resistors. Vout = +5V * 680R/(680R+1K) = 2.0238

That is where your 2 volts is coming from. Adding the 5 volts of the V1 source (by closing the switch) you get your 7 volts.

The diode (in parallel with the 680R resistor), with a forward voltage of 0.7V or less, will reduce that 2V to 0.7 (or less).

Maybe this plot will help further understand what is happening (it is the charging/discharging of the capacitor above the 5V power supply).

When the switch closes (at 2us) both of the plates go to ground, but the top plate (Vout in blue) starts charging from the 5V power supply through R1, which is dropping 2V between its terminals.

When the switch is open (at 4.5us), the plates of the capacitor stop charging (top plate is 5V and the bottom plate is 0V).

The capacitor then starts to discharge through R1 and R3, but because the 5V power supply is still there between R1 and R2, the voltage drop on R1 raises both plates of the capacitor by 2V, as the capacitor discharges.

See what happens if we were to remove the 5V power supply before the capacitor was completely charged. The voltage would never be raised by 2V.

See what happens when you exchange the resistors (it follows the voltage divider formula):

Answering your question “how do BOTH plates of the cap go to ground, if only 1 of them is connected directly to ground when switch is closed?”

You know how a capacitor works. There has to be a differential of potential between its plates for the capacitor to charge and, if charged, a path between the plates to discharge it.

As I have said “Initially, the capacitor has 5V across its plates.” But the capacitor is initially discharged. It is just reflecting the voltage from the power supply. There is no current flowing.

As there is no resistance between the ground and the capacitor bottom plate, when the switch is closed the bottom plate is directly connected to ground even though it was +5V before. The capacitor was not charged, so there is no current flowing in it at this time. The bottom plate is just reflecting the potential of the wire coming from ground.

Because the capacitor is discharged, and before the capacitor has time to charge from the current coming from the 5V power supply through resistor R1, its top plate is at the same potential as the bottom plate, that is, ground.

Remember that when a capacitor is discharged and a voltage is connected to it, for a very brief period of time, the plates of the capacitor acted as a short-circuit. That is what you see in the plot at the 2us time (check the two plots in the picture below). Both capacitor plates are draw to ground first and then the capacitor starts to charge from ground to +5V.

PS: You will understand better, when you see what happens when the capacitor is initially charged. It shows a 5V potential between the plates when the switch is closed, and before the capacitor starts to charge. (Remember that the 2 volts are coming from the potential drop of the R1 resistor.):

• Nice. Now, try it with a 1N4148 and a BAT54 to Vcc and see what happens. Jan 31 at 5:33
• I did. It dropped below 7V but still shows the drop on the diode. Jan 31 at 5:36
• Yes, that’s the point. LTspice will be more accurate than Falstad, so it’d be interesting to see what it shows. Jan 31 at 5:40
• Added the plot with the 1N4148 diode. Jan 31 at 5:43
• this totally clears it up for me - thank you for providing your detailed answer and LTspice diagrams/plots. seeing the difference follow the voltage divider formula when you swapped resistors was the "a-ha" moment Feb 1 at 3:02

Adding a parallell flyback diode after the RC circuit and before the output, as seen below, mostly mitigates the effect (simulate it here. Why is this the case, and how come it doesn't COMPLETELY mitigate it? You still get about 5.5 volts on button release.

If the diode were an ideal rectifier, then the voltage at the output would indeed be clamped to the supply voltage.

However real diodes have a voltage drop across them when they are conducting. We often take 0.6 volts as a nominal voltage across a conducting diode. In fact, the voltage depends on the model of diode and the amount of current.

The limiting voltage of the output is the 5 volts from the supply used to charge the capacitor plus the voltage drop across the diode, or something approximating 5.6 V.

The diode doesn’t catch all of the spike for several reasons:

• forward voltage - 0.7V for ordinary silicon and 0.3V for Schottky types
• switching time - Schottky is faster, but it’s still not zero
• internal resistance - adds IR drop across the diode (which varies as predicted by the Shockley model)