Understanding the RC circuit equation - Page 1
Forum section: electronics / projects

author: Azmarith
author_rank: Newbie
timestamp: November 16, 2019, 06:05:47 pm
content: Hey everyone,I've been having some trouble understanding something, and was hoping that people here might be able to help figure it out.I've been trying to derive the output of a basic RC as shown below:I'm trying to derrive how the capacitor charges and discharges. Though, I'm only going to go over how the capacitor charges in this post, as I'm assuming that I'm making the same mistake for both charge and discharge.I know that the equation to describe the charing of the capacitor is:However, It doesn't take into account the initial voltage accorss the capacitor, plus I would like to derrive it from Ohm's, Faraday's, and Kirkoff's laws in order to get a better mathematical understanding of the circuit.I've tried two approaches: one where I (wrongly) assume that the current flowing into the capacitor is a constant, and another where I subsitiure the current as derived from Ohm's and Kirkoff's laws into faraday's law. I find that both methods have elements that look correct, but are totally different, and are both wrong.Method 1First I start off with Faraday's law, to describe the capacitor:Faraday's law only give the rate of change of the voltage accross the capacitor, not the actual voltage. Therefore, I rearrange Faraday's law, integrating the current over the capacitance. Then once integrated define the constant as the initial voltage accross the capacitor.If I use Ohm's law to specify the current, as it's limited by the resistor, I get:n.b. VI is denoted VS in the diagramI think this is the way forward. However, my skill in maths isn't good enough to solve this, as the voltage accross the capacitor is on both sides.Going back a step, I (wrongly) assume that the current is a constant. I then integrate to give:I can then just derive the current from the resistor, and substitute it into the equation to give:Rearrange to get the voltage accross the capacitor:After plotting this equation, I thought that I'd worked out the answer. It's the correct shape, and behaves as you would expect when the starting voltage is adjusted. However, the rise time is slower than you would expect it to be.Method 2Here, I start by substituting the current from the start:Rearrange:Then integrate:Then rearrange to get the voltage accross the capacitor:This appears to be close to the actual answer, in appearance. However, when it's plotted it's totally wrong.Can anyone here give some insight? I feel that I'm close, but I'm making a dumb mistake somewhere.

author: iMo
author_rank: Super Contributor
timestamp: November 16, 2019, 06:14:19 pm
content: The capacitor charges to Vs immediately. It discharges via RC.

author: Azmarith
author_rank: Newbie
timestamp: November 16, 2019, 06:16:28 pm
content: Appologies Imo, the circuit diagram is just something I quickly grabbed off google, and didn't realise that it's wrong. I've updated it to the correct diagram.

author: iMo
author_rank: Super Contributor
timestamp: November 16, 2019, 06:18:21 pm
content: That is a fully different situation, however..It charges via RC eq to Vs and it never discharges..

author: Azmarith
author_rank: Newbie
timestamp: November 16, 2019, 06:22:03 pm
content: Quote from: imo on November 16, 2019, 06:18:21 pmYes, I'm only looking at how it charges at the moment.

author: iMo
author_rank: Super Contributor
timestamp: November 16, 2019, 06:32:19 pm
content: 1. consolidate the variable names, what is Vi, Vo?2. always index the equations otherwise we have to reference them like"when Vi is your Vs then the 4th equation from top is not correct.."

author: Azmarith
author_rank: Newbie
timestamp: November 16, 2019, 06:39:18 pm
content: Quote from: imo on November 16, 2019, 06:32:19 pmWell spotted. Yes, Vi is Vs. Why isn't it correct?

author: duak
author_rank: Super Contributor
timestamp: November 16, 2019, 06:42:10 pm
content: I don't have an equation editor handy so I hope this comes out OK.Vc = (Vi - Vci)(1 - e^(-t/RC)) + Vci where Vci is the initial voltage across the capacitorI'll have to leave the nuts n' bolts of the math to someone else.

author: SiliconWizard
author_rank: Super Contributor
timestamp: November 16, 2019, 06:47:48 pm
content: Let's call i(t) the current flowing through the circuit, and Uc(t) the voltage across the capacitor.As you already figured, you have the following basic equations: Vs = R.i(t) + Uc(t), and i(t) = C.dUc(t)/dtSimple substitution: R.C.dUc(t)/dt + Uc(t) = VsNow it's just a matter of solving the above differential equation. It's a simple one. If you're willing to save time, or are not confident in your math skills (although I'd suggest brushing up on them in that case), you can use tools to help with this. For instance, in Maxima (/wxMaxima), you can solve it with the following line:Code:desolve(R*C*'diff(Uc(t), t)+Uc(t)=Vs, Uc(t));Spoiler:After arranging it a bit, you get:Uc(t) = Vs + (Uc(0) - Vs).exp(-t/(RC))There is your initial condition (initial capacitor charge), Uc(0).

author: IanB
author_rank: Super Contributor
timestamp: November 16, 2019, 06:54:36 pm
content: Quote from: Azmarith on November 16, 2019, 06:05:47 pmThat's an initial condition for the problem. The capacitor could have any arbitrary initial voltage. For the standard case it is normal to assume the initial voltage is zero.As for how to derive the equation, you proceed as indicated above, you write down a differential equation for the capacitor voltage and then solve it for the solution as a function of time.

author: AndrewHodgson
author_rank: Contributor
timestamp: November 16, 2019, 07:03:07 pm
content: This is a pretty good explanation:If you want take into account the initial voltage across the capacitor:rearrange that equation so t is the subjectt=RC*ln( 1-Vc/Vs)then say you want to know how long it takes you to get from 1V to 4V with a supply voltage of 5V. you sayt= RC(1-4/5)-RC*ln(1-1/5)so you're subtracting the time it takes to get to 1V.Make sense?

author: AndrewHodgson
author_rank: Contributor
timestamp: November 16, 2019, 07:44:23 pm
content: Also, if you want to take account of the initial capacitor voltage in your derivation you just integrate between t1 and t2, and q1 and q2

author: Azmarith
author_rank: Newbie
timestamp: November 16, 2019, 08:09:25 pm
content: Quote from: AndrewHodgson on November 16, 2019, 07:03:07 pmQuote from: AndrewHodgson on November 16, 2019, 07:44:23 pmThank you so much guys! I see where I was going wrong now. I wasn't integrating between t1 and t2, and q1 and q2. I was integrating and just adding on a constant which I assumed was the starting voltage/charge.Thank you all so much for you help

author: bson
author_rank: Unknown
timestamp: November 17, 2019, 07:19:50 pm
content: As has been pointed out, just subtract the initial voltage from the supply voltage. Charging a capacitor from 2 to 5V with a 5V supply is exactly the same as charging it from 0 to 3V with a 3V supply.