# I want to discharge capacitor in X seconds (Help)

Discussion in 'General Electronics Chat' started by Guest3123, Oct 13, 2016.

1. ### Guest3123 Thread Starter Member

Oct 28, 2014
312
17
I would like to understand the equation for discharging a capacitor in X seconds. I want it discharged when I say so (X).
Extra, but not the subject. I would also like to understand the equation for charging a capacitor in X seconds. I want it charged when I say so (X).

Here's what I learned from MrAl in a previous thread a while back. But those do not teach me how to discharge, and charge a capacitor when I say so. So if I wanted it discharged or charged COMPLETELY in X seconds.. How would I do that?

Time to Charge a Capacitor #1 : Vc=Vs*(1-e^(-t/RC))
Vc = Capacitor voltage after time t.
t = Time in seconds.
Vs = Source voltage (like a battery).
R = Resistance in Ohm's
e = The base of the natural log system. Aka Euler's number : 2.7182818284590452353602874713527.....

Time to Discharge a Capacitor #1 : Vc1=Vc0*(e^(-t/(R*C)))
Vc0 = Starting Voltage of the Capacitor
Vc1 = Ending Voltage after time t.
t = Time in seconds.
e = The base of the natural log system. Aka Euler's number : 2.7182818284590452353602874713527.....
R = Resistance in Ohm's

So if I had a capacitance of 10uF (0.00001F), and a resistance of 100k (100,000 Ω).

So that's 0.00001F * 100,000Ω = 1 second.

Times 5, because in 5 time constants, it will either be fully charged, or discharged. Right? So it will take 5 seconds then to charge or discharge the 10uF capacitor with 100k resistor.

Let's make it five times less than, to get it to actually discharge in 1 second after 5 time constants.

0.00001F / 5t = 0.00002F (50uF)
100,000Ω / 5t = 200,00Ω (200kΩ)

It's still going to be 5 seconds.

Let's just change the resistance then.. Let's make the resistance 5 times less.
I'm keeping the Capacitance at 10uF (0.00001F).

100,000Ω / 5 = 20,000Ω (20kΩ)

t = RC
20,000Ω * 0.00001F = 0.2 BINGO !!!

And after 5 time constants.. 0.2 x 5t = 1

It will charge and discharge in 1 second.

C = 0.00001F (10uF)
R = 20,000Ω

Now, let's amplify that. Let's discharge it in 1h 1m 1s 1ms

Seconds in an hour : 3600

3600s + 1s + 0.001s = 3601.001s (1h, 1m, 1s, 1ms)

20,000Ω x 3601.001 = 72,020,020 Ω (72.020 MΩ)

Do they even exist..? lol.. I bet I could probably lower or raise the Capacitance.. to allow the resistance to be lowered..

Is there a simpler equation for doing this..?

Last edited: Oct 13, 2016
2. ### Papabravo Expert

Feb 24, 2006
10,021
1,757
The answer to your question does not have a unique answer. In the first place exponential functions never reach their limiting value, but they can get arbitrarily close. Trouble is the closer they get to the limiting value the longer it takes to get a bit closer. Five time constants is just an approximation to completely charged or completely discharged -- it never actually achieves complete charge or complete discharge. Any time you have a product of two variable like R and C equal to a constant you should think of the conic section called a hyperbola and realize that there are an infinite number of solutions that give you the desired behavior. In your specific case of 113.033 seconds, I recommend:

$R=C=\sqrt{\frac{113.033}{5}}$

Guest3123 likes this.
3. ### Guest3123 Thread Starter Member

Oct 28, 2014
312
17
After I finished editing my OP, I saw what you posted.. But before I saw your post.. I figured it out kinda.. In my own little way if you look at the OP. But I'm going to take a look at the equation you showed me. Thank for helping.

So Resistance = Capacitance = the square root of (113.033 seconds divided by 5 time constants)

113.033 / 5 = 22.6066, and the square root of 22.6066 is 4.7546398391465993351950404833724

So R & C = 4.7546398391465993351950404833724 ...?

t = RC, 4.754639 x 4.754639 = 22.606592020321 x 5 time constants = 113.032960101605 voilà !!!

I took away some digits after the decimal place, or resolution, so technically, it's correct.

Ok, let's try another one.. I want 1h:1m:1s this time. 3661 seconds.

C = R = Sqrt(3661 / 5)

3661 / 5 = 732.2
Sqrt(732.2) = 27.059194370860341635870732175638

t = RC ; 27.05919437 x 27.05919437 = 732.2 x 5 time constants = 3661 BINGO !!

I can't use a 27 Farad capacitor. That's not going to work. I'll just work with the math I did on top. I'll lower or raise the capacitance, to get a reasonable resistor value. Thanks so much for helping, much apreciated.

Last edited: Oct 13, 2016
4. ### AnalogKid Distinguished Member

Aug 1, 2013
4,290
1,177
As papa said, when discharging a capacitor with a resistor, the charge on the capacitor (and its voltage) never reach zero in theory. In practice, 5 time constants is a good approximation of completely discharged, because it calculates out to less than 1 % (0.674%) of full charge. While a 27 F cap and 27 ohm R are not practical values, here is another approach:

5 x R x C = 3661 s
R x C = 732 s
If R = 100 K, C = 7,300 uF
If C = 7500 uF, R = 97.6 K
If C = 2200 uF, R = 332 K
etc.

ak

5. ### joeyd999 AAC Fanatic!

Jun 6, 2011
2,606
2,473
And, to be pedantic, there is also the concept of dielectric absorption (or "soakage"). This phenomenon causes even a "completely discharged" capacitor to regain some of its charge, even after long discharge periods.

6. ### WBahn Moderator

Mar 31, 2012
17,455
4,701
A few observations.

First, reporting values to 30+ decimal places is complete absurd. That is sufficient to report the mass of the Earth to within a single grain of sand.

Second, trying to get five time constants to be 3661 seconds (not 3660 seconds and not 3662 seconds) is nonsensical from a couple of perspectives. First, consider that at an arbitrarily chosen five time constants you have gotten to 0.67% of the way to the final value, which represents 24.7 seconds out of 3661 seconds. So the precision you are asking for is completely out of line with the arbitrary metric you are using. Second, 1 sec out of 3661 sec is 0.027%. To achieve that goal in a meaningful way, your RC time constant would need to be met to a level considerably better than that, but let's just say we are okay with meeting that. If we split the tolerance equally between the resistor and the capacitor (which is not too reasonable since capacitor tolerances are considerably worse than resistor tolerances in most cases) then each component must be within 0.02% of the nominal value. Good luck finding resistors that are that tight, though you can possibly come into that ballpark if you are willing to pay enough. But capacitors? That is one or two orders of magnitude tighter than you would normally see even with precision timing capacitors.

Third, combing the above, it is perfectly reasonable to ask how you would extend the charge/discharge time by a factor of five or to take it from the range of one second to the range of an hour (though at an hour a lot of other factors come into play, particularly the leakage of the capacitor). But your tolerances must also scale. Wanting an accuracy/precision of one second at the end of an hour is like wanting the original one second to be accurate to within about a quarter of a millisecond. If the latter is unreasonable, then so is the former.

7. ### hp1729 Well-Known Member

Nov 23, 2015
1,846
206
R x C x 5 = T
So how much capacitance do you need to discharge? How quickly? Automatically, through a transistor, or manually putting in a jumper?

8. ### Guest3123 Thread Starter Member

Oct 28, 2014
312
17
I understand Resistors, Ohm's Law, and n-Channel Mosfets pretty well. Every single time I see a video or hear about capacitors, I get nightmares. It's like the #1 thing that I don't fully understand.

I'll explain why this thread was created.
So I watching a horror movie, and like always, I wanted to know how can I turn something on when a specific voltage is met. I stopped my movie, and like I usually do I do a Google search. An example would be the LMT86 chip. It's a tempature chip. If the voltage reading on the chip, if I manually checked it, like I've done with a 6000 counts dmm, and it reads 1.791vdc

How do I turn on the heater/ac, robot, etc. etc. at 1.790vdc

A Google searched showed a topic on a forum, and the thread said OpAmp.

So I watched some videos about OpAmps.

So in his video he shows that the OpAmp is able to shoot out a absolute high value, when V+ > V-. That's really neat !!

So he also explains that the Op amp inputs are very sensitive, when comparing voltages V+ to V-. That's exactly what I wanted.

Then he explains how can we make the clapper detector stay on for a few seconds, after he claps.

A Capacitor.

I was like OMG.. Those damn Capacitors again. Capacitors are like Krytonite to me. Regardless of the other electronic components I don't know about, the capacitor is used allot in circuits, not as much as resistors, but they're often used.

So after learning on here and doing some calculations on my computer in a text document. I found that the absolute lowest I could get the values of R & C, is..

100Ω (200Ω)
0.002F (2000uF)

Yup they are easy to get on Mouser Electronics, I searched for them.

So that right there, will discharge "99.326%" of it's voltage in 1 second.

Then I went back to Circuit Simulator, and boy oh, was everyone right, it turns out that it takes a much longer time to completely charge or discharge the cap even at 1 second. 100Ω x 0.002F = 0.2 x 5t = 1s

So then I also encountered another problem.. With those values, it discharges after the cap is full, at 0.05A (50mA). Well, I was like that SUCKS..

How the heck if I wanted a certain current to flow through something, 'IF" I wanted a certain amount of current to flow A, mA, uA, how am I supposed to juggle the two values to get the discharge rate time, and the amount of current I want..?

Well, it's easy, but not really. It's just a matter of changing both the Capacitance and the Resistance, keeping it at let's say 360 seconds, while starting out at let's say 0.02A (20mA). But that's only because I didn't know about Capacitors that well, and I wanted to mess with the numbers and such in the simulator. But if it's just discharging or charging, without worrying about current flow.. Then now that I have the resistance down pretty low, and the capacitance down pretty low, I can just jack up the resistance, and keep the capacitance where it's at.. Not worrying about the current flow (5v power supply btw..).

So if I wanted let's say 17 seconds.. 17s x 100Ω = 1.7kΩ x 0.002F = 3.4s * 5 time constants = 17s

But with a 1.7kΩ resistor @ 5v, and when the cap is fully charged, and is discharging, then that's 0.0029A (2.9mA).

So the peak detector video is here : Peak Detectors!

He chooses a 10uF Capacitor and a 100k resistor. So roughly 5 seconds the LED will stay lit for after the microphone detects the clap.

But the current is crap. So I honestly don't know how he was able to keep the LED lit with 50uA of current, let alone for 5 seconds.

Sure.. Even a 6 year old could use an Arduino Uno to do all this.. But a person serious about electronics, and wants to learn about actual electronics, would use electronic components, and do it that way.

Yes, I have and own an Arduino Uno.. It sits in a box. It's evil, and it's the lazy way to do things.

Last edited: Oct 14, 2016
9. ### wayneh Expert

Sep 9, 2010
11,920
2,855
The current leaving his peak detector is not powering the LED. It's going to ground through a resistor and through the input impedance of the op-amp, which would be relatively tiny. (The current, I mean, the impedance is huge.) That op-amp watches the voltage of the discharging capacitor and switches the power to the LED.

Guest3123 likes this.
10. ### KL7AJ Senior Member

Nov 4, 2008
2,013
273
The rule of left big toe is that a capacitor is deemed fully discharged after 5 time constants. However this is no absolute guarantee that there will be a safe voltage at that time.

Guest3123 likes this.
11. ### hp1729 Well-Known Member

Nov 23, 2015
1,846
206
Voltage Comparator. LM393 (dual) or LM339 (quad) are cheap, old and popular. It lets you compare two voltages and makes an output high or low depending on the voltages. But these only work for positive voltages. LM311 (single) or LM319 (dual) work with positive or negative input voltages.

Guest3123 likes this.
12. ### WBahn Moderator

Mar 31, 2012
17,455
4,701
Huh?

You can get much lower values than that. In fact, 2000 μF is a pretty large capacitance for most purposes. Run of the mill resistor values are from about 10 Ω to 1 MΩ with another order of magnitude on each side (so 1 Ω to 10 MΩ) still being quite common. Values outside that range tend to be pretty uncommon for most circuit applications, but far from unheard of. Capacitor values are generally between, say, 100 pF and 100 μF, with values down to about 1 pF and up to 1000 μF still being quite common place. And, of course, there are specific types of circuits that need values well outside these ranges; I'm just referring to mundane, every day electronic circuits.

Guest3123 likes this.
13. ### hp1729 Well-Known Member

Nov 23, 2015
1,846
206
R x C will get you one time constant of change in the charge. About 63% of the way. In the next time constant you will go another 63% of the remaining difference. Another time constant gets you another 63% of the remaining way. Five time constants (5 x R x C) is considered fully charged or discharged.

Guest3123 likes this.
14. ### WBahn Moderator

Mar 31, 2012
17,455
4,701
And, to hopefully add to your (i.e., the TS's) understanding, there is nothing magic about five time constants. Where it comes from is the recognition that, in practice, getting results that are within 1% of the desired value is usually around the boundary between what is relatively easy to achieve and what is almost certainly good enough. If we want the charge/discharge to be 99% complete, then we need 4.6 time constants. Since we aren't trying to get anything too precise, we round that to 5 time constants, which is 99.33%, which is close enough.

In fact, from a practical consideration, trying to detect when five time constants has been met is rather difficult because the signal is changing pretty slowly at that point (it's changing at about 1% of the rate it was initially), so small errors in component values make big errors in results -- if your threshold is 1% high your timing might end up off by a factor of two. So we would generally pick different thresholds. One common practice is to use 10% and 90% values. It takes an RC circuit about 2.2 time constants to go between those two levels. The 555 timer uses thresholds that, by default, are at 33% and 67%; it takes about .7 time constants to go between these levels.

It would be quite reasonable to pick thresholds that result in the time to go between them being one time constant. To achieve that we just need to make the natural log of the second threshold (as a fraction between 0.0 and 1.0) 1 greater than the natural log of the first threshold. If we want to have thresholds that are symmetric about the half way point, then we could use 27% and 73%, which put us at 0.995 time constants. If we use 25% and 75%, which are easy thresholds to establish (four identical series resistors), then we have 1.1 time constants, which would be close enough in many instances.

Guest3123 likes this.
15. ### Bernard AAC Fanatic!

Aug 7, 2008
4,140
393
You may also wish to charge & discharge a C with constant current.
1 coulomb , Q, = 1 A for 1 sec.
I T = Q, & CV= Q, or IT = CV, I in amps, C in farads, V = volts, T = sec.
How long to charge a 100 uF @ 1 mA. to 10 V ? T= CV / I, .000100 F X 10 V / .001 A, = 1 sec.
LM 334, temp sensor or constant current source, good from uA to about 10 mA.

Guest3123 likes this.
16. ### Guest3123 Thread Starter Member

Oct 28, 2014
312
17
Thanks so much for all the help and replies I got on this. Seriously. I think I'm really starting to like electronics, and I just got done uploading a video showing the NAND gate being created using two n-Channel MOSFETS. I'm still a long way from understanding a lot of things, but my next big goal is to make a 1Hz signal. Which I've posted about. That thread will sit there for a long time, until I'm good and ready, and have a very good understanding about logic gates and such. I'm still reading the stuff on the website that was referred to me by @Ci139. I started with
Module 1.0 / 1.0 Introduction to Number Systems, and I'm working my way threw it, hopefully one day I'll be able to understand how to generate the 1Hz that I wanted to do. I'm an extremely slow learner, and I'm a procrastinator, so I'll just take my time, and I'll get to it eventually.

That's what I want to do. Make a Clock. I know it doesn't have anything to do with with thread, but with all the threads I've started at AAC, some people probably are aware of me by now, and my interest in electronics. But because of everyone here, I'm learning about electronics, and that's something that I've always wanted to do. Little by little, I'm making my way. I would like to say thank you to all the people that have helped me my my quest to learn about electronics, and even if I don't reply to a specific thing, that doesn't mean I don't come back here, and look at these replies, and use them or take another look at them, and use that information when I'm actually going to apply it with a real circuit using real electronic components.

So here's a little video I did.. It's very simple, but it's just something I did, and I wanted to share with people, that might wanna take a look.

Yes, I'm aware this circuit can be purchased, with 4 NAND gates. Known as the 7400 IC. I was also looking at videos and circuits that show how to hook it up on a solderless breadboard. Very easy it seems. But the video below, is making a single NAND gate using only two n-Channel MOSFETs I purchased from Mouser Electronics. Yes, I'm also aware that it can be done with NPN transistors, etc. etc.

n-Channel MOSFET Logic NAND Gate - 1080p

17. ### hp1729 Well-Known Member

Nov 23, 2015
1,846
206
Sweet!
Along this line, one chip, CD4007, is six transistors. 3 N-CMOS, 3 P-CMOS. Originally it is two complementary pairs and an inverter. But they can be wired as a NAND or an AND, or ...

Guest3123 likes this.
18. ### Guest3123 Thread Starter Member

Oct 28, 2014
312
17
Is a PMOS the same as a p-Channel MOSFET, and an NMOS the same as what I call an n-Channel MOSFET? They sound the same. All joking aside.. I honestly don't know.

19. ### hp1729 Well-Known Member

Nov 23, 2015
1,846
206
Yes, sorry for my brevity. As the schematic shows, enhancement mode MOSFETs.

20. ### Papabravo Expert

Feb 24, 2006
10,021
1,757
Yes they are synonyms. CMOS stands for Complementary MOS because it uses both NMOS and PMOS.