Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Charge-of-capacitor algebra

Status
Not open for further replies.

tomizett

Active Member
Hi all,
I'm wondering if someone can help me tidy up my algebra? My problem concerns the time taken for a capacitor to charge from one voltage to another (I'm sure this must be a classic electrical engineering exam question).

So...
The capacitor C is charged from 0v through a resistor R towards a supply voltage Vmax. At time t the voltage is:
V(t) = Vmax( 1 - e^(-t/RC) ) [1]

...and so the capacitor reaches an arbirary voltage V1 at time t1, where:
t1 = -RC ln( 1 - V1/Vmax ) [2]

...and likewise sometime later it reaches a higher voltage V2 at time t2, where:
t2 = -RC ln( 1 - V2/Vmax ) [3]

the time taken to charge from V1 to V2 is (t2 - t1), or:
RC ln( 1 - V1/Vmax ) - RC ln( 1 - V2/Vmax ) [4]
and removing the common factor of the time constant RC gives:
t1,2 = RC ( ln( 1 - V1/Vmax ) - ln( 1 - V2/Vmax ) ) [5]

Now, I'm pretty confident that this is correct, but is there a more elegent way to express it? Is there a cleaverer way to aproach this problem? I know that at some point, when Vmax >> (V1 and V2) the charge current becomes nearly constant and the time tends towards:
t1,2 = (V2-V1)RC / Vmax [6]
is there a way to see this limit from [5] above?

This isn't really important, but - as often happens - although I can come up with a solution I believe to be correct, my mathematics is not really good enough to give me a neat and tidy answer.
Thanks!
 
It may be useful to remember a table of values showing the arrival difference from a linear slope of RC=T which you can compute in a spreadsheet

1T 36% error
2T 13%
3T 5%
4T 1.8%
8T 0.7%
 
Your expression number [5] can be simplified to:

t1,2 = RC ln(( 1 - V1/Vmax )/( 1 - V2/Vmax ) )

if indeed that can be considered a simplification.

I cannot see a way of simplifying ( 1 - V1/Vmax )/( 1 - V2/Vmax ), there may be a way but my algebra foo fails in that area.

To get to your expression [6], I seem to be able to get part way and then just get stuck.
It is getting late for detailed thinking, even for an old insomniac like me.

JimB
 
This will be anathema to Tony Stewart and Ratchit, but here goes.:D

After Kirchoff's two laws and Ohms law, a very useful relationship is,
Q=CV=IT (1)
Where:
Q is the charge stored in the capacitor in Coulombs
C is the capacitance in Farads
V is the Voltage across the capacitor
I is the current flowing into the capacitor in Amps
T is the time in seconds, that the current flows into the capacitor

The inverse (wrong word) of capacitance is inductance, so you get:
Q=IL=VT (2)
Where :
Q is the charge stored in the inductor in Coulombs
L is the inductance in Henrys
I is the current flowing through the inductor in Amps
V is the Voltage across the inductor
T is the time in seconds, the the voltage is applied to the inductor

Of course, both (1) and (2) assume perfect components (sorry Tony) and a constant current and constant voltage respectively. They do not relate directly to the exponential voltage across a capacitor when the charging current is derived from a constant voltage via a resistor. As electronic circuits invariably use constant voltages, it is more common to see an inductor charged by a constant voltage though. In any case, the two simple relationships are very useful, if used correctly, for giving a guide to any of the variables. In other circumstances the relationships are accurate.

Take an example.
You would like to specify a reservoir capacitor for a simple mains power supply.
Where:
Type of rectification = full wave (rectification factor =mains period/2)
Mains frequency = 50 Hz (period = 0.02s)
Current drain from reservoir capacitor = 3A
Maximum acceptable ripple voltage = 1V

From, Q=CV=IT, by deleting and transposing, you can get, C=IT/V

Thus, C= (3A*0.02s)/(0.7V * 2 rf) = 0.04286 F, so the closest standard value, 470mF (470,000uF), will do.
Obiously, this is a gross simplification about rectifier/capacitor power supplies, but in practice, it surprising how close it is.

You can do similar calculations with inductors too.

For example, say you need to establish what the maximum current is in an inductor in a basic flyback switch-mode regulator.
Where:
Supply line = 12V
Switching frequency = 100Hz (period= 0.01s)
Switching frequency mark to space ratio =1:1
Inductance = 0.01 Henrys

From Q=IL=VT, by deleting and transposing again, you can get, I= VT/L
Thus I= (12V*0.005s)/(0.01H * 2) = 3A
In this case the answer is accurate because the voltage is constant.

spec
 
Last edited:
Hi all,
I'm wondering if someone can help me tidy up my algebra? My problem concerns the time taken for a capacitor to charge from one voltage to another (I'm sure this must be a classic electrical engineering exam question).

So...
The capacitor C is charged from 0v through a resistor R towards a supply voltage Vmax. At time t the voltage is:
V(t) = Vmax( 1 - e^(-t/RC) ) [1]

...and so the capacitor reaches an arbirary voltage V1 at time t1, where:
t1 = -RC ln( 1 - V1/Vmax ) [2]

...and likewise sometime later it reaches a higher voltage V2 at time t2, where:
t2 = -RC ln( 1 - V2/Vmax ) [3]

the time taken to charge from V1 to V2 is (t2 - t1), or:
RC ln( 1 - V1/Vmax ) - RC ln( 1 - V2/Vmax ) [4]
and removing the common factor of the time constant RC gives:
t1,2 = RC ( ln( 1 - V1/Vmax ) - ln( 1 - V2/Vmax ) ) [5]

Now, I'm pretty confident that this is correct, but is there a more elegent way to express it? Is there a cleaverer way to aproach this problem? I know that at some point, when Vmax >> (V1 and V2) the charge current becomes nearly constant and the time tends towards:
t1,2 = (V2-V1)RC / Vmax [6]
is there a way to see this limit from [5] above?

This isn't really important, but - as often happens - although I can come up with a solution I believe to be correct, my mathematics is not really good enough to give me a neat and tidy answer.
Thanks!

Well, the tidy answer is that t1 = RC Ln(vmax/diff} , where diff is the difference between the voltage at t1 and vmax. I can show you the derivation of the formula if you really care, but let's do an example. Suppose the RC time constant is 0.01 seconds and vmax = 20 volts. To energize the capacitor to 10 volts takes 0.01 Ln(20/10) = 0.00693147 seconds. To energize further to 2 more volts for a total of 12 volts takes another 0.01 Ln(10/8) = 0.00223144 seconds. Notice that vmax from 10 to 20 volts is 10 volts and the difference from 2 to 10 volts is 8 volts. Adding up the two times gives a total of 0.00916291 seconds., Plugging in the total time into the capacitor energizing formula gives 20(1-e^0.00916291/0.01) = 12 volts.

Ratch
 
Thanks for your input everyone, but I think Jim has hit the nail on the head.
When I think of if, of course ln(A)-ln(B) = ln(A/B).... after all, that's more or less the point of logarithms, isn't it? It just hadn't crossed my mind that that was what I was looking at.
In my mind, at least, the form with only one ln() in it is tidier.

I can't simplify the ( 1 - V1/Vmax )/( 1 - V2/Vmax ) easily either - it just seems to get messier. We can at least see that as Vmax increases this term tends towards 1, decreasing the time interval towards 0, as we would expect from an higher supply voltage. The term is also 1 if V1=V2, again giving the time interval of 0, as expected.

Thanks!
 
Having looked at this again, the simplification of the term within the ln() that I was looking for is:
(1 - V1/Vmax) / (1-V2/Vmax) = (Vmax-V1) / (Vmax-V2)
so the entire expression [5] from my original post becomes:

t1,2 = RC ( ln( 1 - V1/Vmax ) - ln( 1 - V2/Vmax ) ) [5]
t1,2 = RC( ln( (Vmax-V1) / (Vmax-V2) ) ) [6]

When x is close to 1, ln(x) can be aproximated as (x-1) - this gives us the linear aproximation for when V1 and V2 are very close.

Sometimes I almost enjoy maths... I just wish it wasn't so hard.
 
Having looked at this again, the simplification of the term within the ln() that I was looking for is:
(1 - V1/Vmax) / (1-V2/Vmax) = (Vmax-V1) / (Vmax-V2)
so the entire expression [5] from my original post becomes:

t1,2 = RC ( ln( 1 - V1/Vmax ) - ln( 1 - V2/Vmax ) ) [5]
t1,2 = RC( ln( (Vmax-V1) / (Vmax-V2) ) ) [6]

When x is close to 1, ln(x) can be aproximated as (x-1) - this gives us the linear aproximation for when V1 and V2 are very close.

Sometimes I almost enjoy maths... I just wish it wasn't so hard.

I don't know what that buys you. That approximation only works if Vmax is close to V1+1 or V2+1. If Vmax is almost equal to V1 or V2, or Vmax is distant from V1 or V2, then that approximation is not valid.

I am unclear as to what you are trying to do. I thought the formula I presented in my previous post gave you the time it would take to energize the capacitor to whatever voltage you could name. Furthermore, it also works if you change the time constant after t1. Perhaps you can manufacture an example that elucidates your goal.

Ratch
 
Having looked at this again, the simplification of the term within the ln() that I was looking for is:
(1 - V1/Vmax) / (1-V2/Vmax) = (Vmax-V1) / (Vmax-V2)
so the entire expression [5] from my original post becomes:

t1,2 = RC ( ln( 1 - V1/Vmax ) - ln( 1 - V2/Vmax ) ) [5]
t1,2 = RC( ln( (Vmax-V1) / (Vmax-V2) ) ) [6]

When x is close to 1, ln(x) can be aproximated as (x-1) - this gives us the linear aproximation for when V1 and V2 are very close.

Sometimes I almost enjoy maths... I just wish it wasn't so hard.


Hi,

If you are looking for an approximation for when Vc2 is close to Vc1 then we have the simpler:
dv=i*dt/C
or:
dv=((Vm-Vc1)/R)*dt/C
or:
Vc2-Vc1=((Vm-Vc1)/R)*dt/C
or:
dt=(Vc2-Vc1)*RC/(Vm-Vc1)

That is derived from the basic definition of a capacitor current and voltage differential relationship which is dv/dt=i/C which is already linear if we think of dv and dt as being some constant values.

Additionally, that can be used repeatedly in a loop to calculate the actual voltage Vc2 at some time later given small values of dt. That is the basis of some simpler numerical differential equation solvers.

For what it is worth I think the following relationship holds too:
e^b=(Vm-Vc2)/(Vm-Vc1)

where b is some time constant like 1, 2, etc. I didnt check this over yet though.
 
Last edited:
MrAl and Mr Ratch are maths gurus methinks.:cool:

spec
 
MrAl and Mr Ratch are maths gurus methinks.:cool:

spec

Hi,

I've been doing this for so long i cant remember when i started now. There is always something new to learn however i find.

Hey, it beats going out and getting drunk right? Oh wait, i do that too ... oh well :)
 
We had an excellent mathematician at work. The first time I met him was in a pub- he was sitting in the corner having a pint while working on some mathematical exotica. He was the best mathematician we had, because not only did like, booze, women and rock, but you could ask him a question about a mathematical problem and get a practical and helpful answer.

He used to apply mathematics to money-making too (stocks, coins, stamps, precious metals, property, etc) and, last time I saw him, about 20 years ago, he was loaded.:cool:

spec
 
Thanks for the contunied interest folks.

Looking at MrAl's work above:
dt=(Vc2-Vc1)*RC/(Vm-Vc1)

I've statisfied myself that I can reach this same result from equation [6] in my post #7 above:
t1,2 = RC( ln( (Vmax-V1) / (Vmax-V2) ) ) [6]

Using the aproximation ln(x) ≈ x-1 when x is close to 1
t1,2 = RC( (Vmax-V1) / (Vmax-V2) - 1 ) [7]
which can be re-written as
t1,2 = RC( (V2-V1) / (Vmax-V1) ) [8]
(hope you don't mind me continuing to use my nomenclature - it just makes it more consistent with my original question).

To my mind, this is again an improvement on [6] in terms of clarity and readability. It's immediately obvious the that time interval varies in direct proportion to the voltage interval and in inverse proportion to the difference between the threshold voltages and the supply.
It's also very satisfying when the same result can be reached in two different ways; MrAl's derivation is the way we'd all probably aproach working out a "back of an envelope" estimate, and it's reassuring to see that it talles up with the more formal aproach.

Ratchit has raised an important point here though:
I am unclear as to what you are trying to do.
...the problem it that, quite often, so am I.
The bigger picture its that I'm trying to improve my design skills on the theoretical level and move away from the "cut and try" aproach. I've always imagined that a propper and rigerous design aproach would start by modeling the circuit algebraically at a high level (assuming the perfect components that spec mentions in #4), before moving on to simulations and more practical considderations. I'm not a trained engineer, so I don't know to what extent professionals work like this in real life.
My problem with maths is that I often don't know what sort of expression I'm expecting at the end of a derevation, I don't recognise the common patterns and I'm not able to reach for the common techniques and identities used to deal with them.
As MrAl says, I suppose it's all down to practice.
 
You have a great objective and one that is quite achievable.:)

In the 'real' world short-cuts and approximations are widely used to get an outline design and often that approach can be pretty close.

Part of this is to get a thorough understanding of what each component actually does. The acid test is if you can look at any circuit, within reason, and define all voltages and currents. Obviously this is not always possible.

Another help is to choose the best analytical approach for a particular situation. For example, when working out the voltage drops across resistors in a network it is often simpler to work in current rather than voltage.

And yet another major help in designing and analyzing electronic circuit is to use rigorous schematic layout rules: data flow, voltage cascading, no trace cockle, consistency, brevity, compactness, legibility, etc etc. As you may have guessed this is a favorite hobby horse.:D

The best advice is to use the minimum and the lowest level of maths consistent with achieving a good design. Very few circuits need a rigid analysis, but some do. Once again, in these cases, you need to be very careful not to get buried in a morass of functions, variables and constants. And, of course, you can always consult the net and the maths experts on ETO to sort out a particularly sticky problem.:)

By the way don't get me wrong; I love maths. It is the language of electronics ... and the universe.:cool:

spec
 
Thanks for the contunied interest folks.

Looking at MrAl's work above:


I've statisfied myself that I can reach this same result from equation [6] in my post #7 above:
t1,2 = RC( ln( (Vmax-V1) / (Vmax-V2) ) ) [6]

Using the aproximation ln(x) ≈ x-1 when x is close to 1
t1,2 = RC( (Vmax-V1) / (Vmax-V2) - 1 ) [7]
which can be re-written as
t1,2 = RC( (V2-V1) / (Vmax-V1) ) [8]
(hope you don't mind me continuing to use my nomenclature - it just makes it more consistent with my original question).

To my mind, this is again an improvement on [6] in terms of clarity and readability. It's immediately obvious the that time interval varies in direct proportion to the voltage interval and in inverse proportion to the difference between the threshold voltages and the supply.
It's also very satisfying when the same result can be reached in two different ways; MrAl's derivation is the way we'd all probably aproach working out a "back of an envelope" estimate, and it's reassuring to see that it talles up with the more formal aproach.

Ratchit has raised an important point here though:

...the problem it that, quite often, so am I.
The bigger picture its that I'm trying to improve my design skills on the theoretical level and move away from the "cut and try" aproach. I've always imagined that a propper and rigerous design aproach would start by modeling the circuit algebraically at a high level (assuming the perfect components that spec mentions in #4), before moving on to simulations and more practical considderations. I'm not a trained engineer, so I don't know to what extent professionals work like this in real life.
My problem with maths is that I often don't know what sort of expression I'm expecting at the end of a derevation, I don't recognise the common patterns and I'm not able to reach for the common techniques and identities used to deal with them.
As MrAl says, I suppose it's all down to practice.

Hi again,

Oh so you just wanted to go at this in a different way then? That's cool i guess, whatever you like.

As long as we are here then we might look at the actual solution for values of Vc2 that are not close to Vc1 using the approximations.
For small changes in t we get small changes in Vc and also not too big values of dVc/dt so we can do this in a simple RC circuit where the cap is charging up..

First rewriting a little from your formula:
dt = RC( (V2-V1) / (Vmax-V1) )

dt*(Vmax-V1)/RC=V2-V1
V2=dt*(Vmax-V1)/RC+V1

and now for dt small we can keep applying this as an estimate so we can calcualte V2 for values of dt that are larger if we apply this several times.

For a simple example let's say RC=2 and Vmax=5 and V1 is 3v to start and choose dt=0.1 seconds, then we have as the first calculation:
V2=dt*(Vmax-V1)/RC+V1
V2=0.1*(5-3)/2+3
V2=0.1*2/2+3=0.1+3=3.1 volts

and now replace V1 with V2 and do it again:
V2=dt*(Vmax-V1)/RC+V2
V2=0.1*(5-3.1)/2+3.1
V2=0.1*1.9/2+3.1=0.1*0.95+3.1=0.095+3.1=3.195 volts

So after 0.1 seconds we get 3.1v, and after 0.2 seconds we get 3.195 volts as approximates.
Compare to the more exact results:
3.09754115
3.19032516

Both somewhere around 0.1 percent error, the first estimate being the better by some amount.

But the exact solution is not that difficult either:
Vc2=(Vm-Vc1)*(1-e^(-t/RC))+Vc1

and you see that is not that much different than the formula for the charging when the initial cap voltage is zero volts.
 
Oh so you just wanted to go at this in a different way then? That's cool i guess, whatever you like.
Not that I thought there was anything wrong with the way you aproached it (like I said, it seemed like the common sense aproach to me) - it's more that I wanted to prove that the aproximation I'd been talking about earlier actually gave the expected results.
 
Not that I thought there was anything wrong with the way you aproached it (like I said, it seemed like the common sense aproach to me) - it's more that I wanted to prove that the aproximation I'd been talking about earlier actually gave the expected results.

Hi,

Well as they say, "It's all good" :)

Can i ask what motivated you to look for a solution when v2 is close to v1?
Just wondering why you would want to look for that if you didnt have anything else planned.

Of course then just to add a little you might be interested in...

For the cap we have:
dv/dt=i/C

and for the resistor we have:
v=i*R

and since they are in series 'i' is the same for both and if we call the voltage source E then we have:
C*dv/dt=i
and
i=(E-vC)/R

and since these are both equal to 'i' we can equate the two and get:
C*dv/dt=(E-vC)/R
dv/dt=(E-vC)/RC

and vC here would be Vc1, but since it is time dependent it would be Vc(t):
dVc(t)/dt=(E-Vc(t))/RC

and that is the differential equation for the charging cap (and RC=R*C):
Solving that for Vc(t) gives the entire solution when Vc(0)=0.
For Vc(0) other than zero we have to add an initial voltage generator for the cap so there's a little more work but not much more.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top