# Mathematically modelling RC circuit with a linear input

I have found a plenty of documents and books that model how the voltage across a capacitor behaves within a transient RC circuit, using the following equation:

$$V_C=V_{MAX}(1-e^{-t/RC})$$

Unfortunately, I have found no resource that discusses how to mathematically model an RC circuit, were one to provide a linearly increasing voltage source as an input.

Attempting to substitute VMAX in the equation above, for a linear equation, results in an equation that converges towards the linear equation, meaning current would cease after a time (I=(VS-VC)/R). This is obviously untrue, since we should be seeing current approach a constant value with time, as given by:

$$I_C=C\frac{dV}{dt}$$

I am fully aware how the voltage across a capacitor would behave with a linearly increasing voltage source, there are plenty of simulators that display that, and I can even think of a physical explanation for the results. What I wish to know is how one could mathematically model the voltage across a capacitor with a linearly increasing voltage source, in a similar way to the equation that models voltage across a capacitor in transients.

• The first equation you use is the particular solution for a RC series circuit with a fixed voltage source, with (pre)defined initial conditions. In your case, you should start over with drawing your circuit, applying Kirchhoff's laws again and solve the ODE. So, no substitutions in the wrong particular solution. – Huisman Jun 17 at 6:57
• The first equation is the result of solving KVL for a step function. You need to solve for the ramp case. – Mattman944 Jun 17 at 6:57
• For a general input signal and a first order system, you need to solve the differential equation using the integrating factor method. – Chu Jun 17 at 7:11
• Your first equation is the impulse response of the RC circuit. Take the convolution of the impulse response and your linear function. That will give you the output of the circuit. – user4574 Jun 17 at 15:01

Unfortunately, I have found no resource that discusses how to mathematically model an RC circuit, were one to provide a linearly increasing voltage source as an input.

This answer is all about converting the circuit to a transfer function in the frequency domain then multiplying that T.F. with the Laplace transform of the input to get the frequency domain equivalent of the output. Finally, a reverse Laplace operation is performed to obtain the time domain formula for the output.

The Laplace transform of a low pass RC filter is: -

$$\dfrac{1}{1+sRC}$$

This is the frequency domain transfer function so, if you multiply this by the frequency domain equivalent of a ramp ($$\\dfrac{1}{s^2}\$$) you get the frequency domain output: -

$$\dfrac{1}{s^2(1+sRC)}$$

Using a reverse laplace transfer table this has a time domain output of: -

$$t + RC\cdot e^{(\frac{-t}{RC})}-RC$$

See item 32 on the table or, if the formula didn't have an obvious table entry you can use an inverse laplace calculator that solves it numerically like this one.

The calculator allows you to build the formula and enter a numerical value for RC. I used an RC value 7 in the above example so I could see how that number propagated to the final answer. The last hurdle is substituting that propagated value of 7 with RC. In other words it's a numerical solver but nevertheless a very useful tool to have to hand: -

• Excellent solution, but you should add a constant for the ramp rate. Maybe: vr = Vr * t – Mattman944 Jun 17 at 7:31
• @Mattman944 maybe I should but I assumed a ramp of 1 volt per second! – Andy aka Jun 17 at 7:33
• Yes, of course 1 V/s, but the OP probably wants a general solution. – Mattman944 Jun 17 at 7:35
• @Mattman944 I think our little discussion will gives enough of a clue to the OP. – Andy aka Jun 17 at 7:37

For a general input signal and a first order system, you may solve the differential equation via the integrating factor, $$\\small (IF)\$$, method* or the Laplace transform, amongst others. The analysis below uses the $$\\small IF\$$ method.

$$\ ^*\$$See edit, below, for an explanation of the integrating factor method.

Given the circuit you describe, the loop equation is:

$$\v_i=v_R+v_C\$$

$$\v_i=iR+\frac{1}{C}\int i\:dt\$$

Differentiating:

$$\\large \frac{dv_i}{dt}\small = R\large \frac{di}{dt}+\frac{i}{C} \$$

Rearranging:

$$\\large \frac{di}{dt}+ \frac{i}{RC}= \frac{1}{R}\large \frac{dv_i}{dt} \$$

Noting that $$\\small \tau=RC\$$:

$$\\large \frac{di}{dt}+ \frac{i}{\tau}= \frac{1}{R}\large \frac{dv_i}{dt} \$$

In your particular case, $$\ v_i\$$ is a ramp, thus: $$\ v_i= \small Kt\$$, where $$\\small K\$$ is the slope of the ramp.

Hence $$\\large \frac{dv_i}{dt} = \small K\$$, and the equation to be solved by the $$\\small IF\$$ method is:

$$\\large \frac{di}{dt}+ \frac{i}{\tau}= \frac{K}{R} \$$

The $$\\small IF\$$ is:

$$\\small IF=\large e^{\int \frac{1}{\tau}dt}=e^{\frac{t}{\tau}} \$$

Therefore:

$$\ i\:e^{\frac{t}{\tau}} =\int \frac{K}{R}e^{\frac{t}{\tau}}dt +A\$$

$$\ i\:e^{\frac{t}{\tau}} =\small KC\: \large e^{\frac{t}{\tau}} +\small A\$$

$$\ i =\small KC\: +\small A \large \large e^{-\frac{t}{\tau}}\$$

Assuming initial conditions are zero, $$\\small A=-KC \$$, hence:

$$\ i =\small KC\:(1-\large e^{-\frac{t}{\tau}}) \$$

and

$$\ v_c =\small K\:(t-\tau + \tau e^{-\frac{t}{\tau}}) \$$

......................................................................................................................................................

Edit: Solving 1st order ordinary differential equations (ODE) by the Integrating Factor ($$\\small IF\$$) method:

For the ODE:

$$\ \frac{dy}{dt}\small +Py=Q\$$, where $$\\small P\$$ and $$\\small Q\$$ are functions of $$\\small t\$$ (which may be constants), we follow the steps:

1. Determine the integrating factor: $$\\small IF= \large e\small ^ {\int P\:dt}\$$

2. The general solution is then found by solving: $$\\small y. IF=\large \int \small Q.IF\: dt + A\$$, where $$\\small A\$$ is an arbitrary constant.

3. Determine $$\\small A\$$ from the initial condition or a boundary condition, if known.

For example, the ODE: $$\ \frac{dy}{dt}+2y=3\$$, with $$\\small y(0)=5\$$

Solution: we identify $$\\small P=2,\:Q=3\$$

Therefore

$$\\small IF= e^ {\int 2\:dt} = e^{2t}\$$

Hence

$$\\small y\: e^{2t}=\large \int \small 3\:e^{2t}\: dt + A\$$

$$\\small y\: e^{2t}= \frac{3}{2}\:e^{2t}\: + A\$$

Dividing through by $$\\small e^{2t}\$$

$$\\small y= 1.5 + Ae^{-2t}\$$

Applying the initial condition:

$$\\small y(0)=5= 1.5 + A\$$; hence $$\\small A=3.5\$$

Giving: $$\ y= 1.5 + 3.5e^{-2t}\$$

• (+1) But you should explain your abbreviations a little more: what is the IF method for solving a differential equation? I don't know that acronym, and googling it directly doesn't show a direct link. By seeing your calculations I can only guess you mean "Integrating Factor", but I don't think that abbreviation is widespread, so you should link to a source to make the answer more self-contained (If the OP doesn't know the abbreviation or the technique he could well be left wondering why you are doing what you do). – Lorenzo Donati Jun 18 at 10:21
• @LorenzoDonati, Thank you for your comments. I've added an edit on the integrating factor method. – Chu Jun 18 at 12:48

May as well add another approach based upon Chu's recommendation:

The standard form for a first order linear differential equation is:

$$\frac{\textrm{d}y}{\textrm{d}t} + P_x\cdot y = Q_x$$

If you can set things up like that, then your integrating factor (which is a nifty way to solve these) is:

$$\mu=e^{\int P_x\; \textrm{d}x}$$

Then then the solution is:

$$y=\frac{1}{\mu}\int \mu\cdot Q_x\;\; \textrm{d}x$$

Suppose the following circuit:

simulate this circuit – Schematic created using CircuitLab

Then from nodal, you get:

\begin{align*}\frac{V\left(t\right)}{R}+\frac{\text{d}V\left(t\right)}{\text{d}t}C&=\frac{V_s\left(t\right)}{R}\\\\\frac{\text{d}V\left(t\right)}{\text{d}t}+\frac{1}{R\,C}V\left(t\right)&=\frac{V_s\left(t\right)}{R\,C}\end{align*}

Which is in standard form, now.

So, $$\P_t=\frac{1}{R\,C}\$$ and $$\Q_t=\frac{1}{R\,C}\cdot V_s\left(t\right)\$$. Thus, the integrating factor is: $$\\mu=e^{^\frac{t}{R\,C}}\$$ and:

\begin{align*}V\left(t\right)&=e^{^\frac{-t}{R\,C}}\int e^{^\frac{t}{R\,C}}\frac{1}{R\,C}\cdot V_s\left(t\right)\:\text{d} t\\\\&=\frac{1}{R\,C}\cdot e^{^\frac{-t}{R\,C}}\int V_s\left(t\right)\,e^{^\frac{t}{R\,C}}\:\text{d} t\end{align*}

You should be able to readily perform the above given a sufficiently simple $$\V_s\left(t\right)\$$. (Don't forget your constant of integration.)

• I think you should be more consistant in using subscripts or brackets, e.g. $V_t$ or $V(t)$ – Huisman Jun 17 at 8:29
• @Huisman I agree. I'll make the change. – jonk Jun 17 at 8:40

what you wrote as Vmax can be changed for your voltage that changes over time as long as it is not too much faster than the time constant of the capacitor it should give you a decent model.

If you want a more precise answer, you can Fourier/Laplace transform your input voltage and calculate the reactance for the capacitor at every frequency that you get, solve each and add them together which will give you the final voltage.

The second option that gives a much more accurate solution is quite more complex that the simple first thing I suggested, which can only give an accurate solution if the voltage rises much more slowly than the charging of the capacitor.

edit: as some of the comments mentioned it is also possible to solve the differential equation for a ramp instead of a step.