Author Topic: Calculating the voltage of an RC network  (Read 1360 times)

0 Members and 2 Guests are viewing this topic.

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 128
  • Country: au
Calculating the voltage of an RC network
« on: December 11, 2022, 02:37:45 am »
I have attached a schematic of a sample circuit I'm investigating.

V1 starts at 0 volts, and then goes to 3.3 volts in a single step, and I am measuring the voltage at VM1.

I would like to come up with a formula for VM1 that shows how it changes through time after this voltage step. I'm pretty sure I should be able to find an expression for VM1 in terms of the resistor and capacitor values. I.e.:

VM1(t) = f(t, R1, C1, R2, C2, C3)

What's the most 'straightforward' way to do this?  I expect I could probably do it by writing down expressions for the voltages at various nodes (using integrals) and the current through nodes, but that will take a lot of algebra, and I was wondering if there were some more efficient analytical tools I can use?

I've done a bit of Google, but having a hard time seeing how complex numbers, transfer functions, and Laplace transforms might help me for this type of stepped voltage. Would appreciate any pointers in the right direction! Even just confirming that I should be going down the route of e.g. transfer functions would be appreciated.
« Last Edit: December 11, 2022, 02:46:33 am by robzy »
 

Offline BillyO

  • Super Contributor
  • ***
  • Posts: 1588
  • Country: ca
Re: Calculating the voltage of an RC network
« Reply #1 on: December 11, 2022, 03:02:55 am »
Step/transient response calculations are complex to being with .. generally not "straightforward", but your practically improbable circuit makes it that much worse.

Do you have any more background on this?  Is it a question on a college problem set?  What's the end goal here?
Bill  (Currently a Siglent fanboy)
--------------------------------------------------
Want to see an old guy fumble around re-learning a career left 40 years ago?  Well, look no further .. https://www.youtube.com/@uni-byte
 
The following users thanked this post: robzy

Offline jonpaul

  • Super Contributor
  • ***
  • Posts: 3494
  • Country: fr
Re: Calculating the voltage of an RC network
« Reply #2 on: December 11, 2022, 03:12:21 am »
1. read a text book on network analysis
2. use a Simulator
3. build the circuit, use function generator and scope

j
Jean-Paul  the Internet Dinosaur
 
The following users thanked this post: robzy

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1110
  • Country: nz
  • Retired Electronics Design Engineer
Re: Calculating the voltage of an RC network
« Reply #3 on: December 11, 2022, 04:11:12 am »
I have attached a schematic of a sample circuit I'm investigating.

V1 starts at 0 volts, and then goes to 3.3 volts in a single step, and I am measuring the voltage at VM1.

I would like to come up with a formula for VM1 that shows how it changes through time after this voltage step. I'm pretty sure I should be able to find an expression for VM1 in terms of the resistor and capacitor values. I.e.:

VM1(t) = f(t, R1, C1, R2, C2, C3)

What's the most 'straightforward' way to do this?  I expect I could probably do it by writing down expressions for the voltages at various nodes (using integrals) and the current through nodes, but that will take a lot of algebra, and I was wondering if there were some more efficient analytical tools I can use?

I've done a bit of Google, but having a hard time seeing how complex numbers, transfer functions, and Laplace transforms might help me for this type of stepped voltage. Would appreciate any pointers in the right direction! Even just confirming that I should be going down the route of e.g. transfer functions would be appreciated.
Apart from the classical method of writing node equations and doing lots of algebra to solve those equations there are 3 other simpler methods that I know of for writing transfer functions for networks:
(1) the indefinite admittance matrix method,
(2) the indefinite impedance matrix method and
(3) the topological formula method.

All these methods are mostly long forgotten but you can read up on them in chapters 3.6 through 3.8 of the excellent book "Electrical Network Theory" by Balbanian and Bickart. A warning though, some the maths in this book is heavy going.

The most intriguing method is the topological formula method. As the name implies it enables the analysis of a network based on the 'tree' shape of the network i.e. the transfer function is dependent on how the branches connect the nodes of the network rather than the circuit elements in each of those branches.

The derivation of the method is difficult to understand but the actual final technique is remarkably simple and it is a simple mechanical procedure that doesn't require solving any complex equations or complex matrix manipulations. Once you have mastered the technique you can write the complex frequency transfer function, as a Laplace transform, of a simple passive network such as your example by inspection!

The time response of your network can then be derived by factoring the transfer function using one of the standard techniques such as partial fraction expansion and taking the inverse Laplace transform of each term to obtain the time response.
 
The following users thanked this post: robzy

Offline MrAl

  • Super Contributor
  • ***
  • Posts: 1522
Re: Calculating the voltage of an RC network
« Reply #4 on: December 11, 2022, 07:44:08 am »
I have attached a schematic of a sample circuit I'm investigating.

V1 starts at 0 volts, and then goes to 3.3 volts in a single step, and I am measuring the voltage at VM1.

I would like to come up with a formula for VM1 that shows how it changes through time after this voltage step. I'm pretty sure I should be able to find an expression for VM1 in terms of the resistor and capacitor values. I.e.:

VM1(t) = f(t, R1, C1, R2, C2, C3)

What's the most 'straightforward' way to do this?  I expect I could probably do it by writing down expressions for the voltages at various nodes (using integrals) and the current through nodes, but that will take a lot of algebra, and I was wondering if there were some more efficient analytical tools I can use?

I've done a bit of Google, but having a hard time seeing how complex numbers, transfer functions, and Laplace transforms might help me for this type of stepped voltage. Would appreciate any pointers in the right direction! Even just confirming that I should be going down the route of e.g. transfer functions would be appreciated.

Hello,

This method is straightforward but with three capacitors it will end up sort of complicated unless you allow some of the component values to be the same.  I'll outline the procedure for this network and then provide a clear way to do it in Maxima which is software that does these calculations for you.


If you know a little bit about network theory this network is not very difficult to do although you may end up with a complicated expression.  You would really want to use math software to plot the result anyway.

You will first note that everything to the right of VM1 and everything to the left of VM1
constitute a simple voltage divider.  The voltage divider formula is:
Vout=Vin*Z2/(Z1+Z2)
where the Z's are the impedances.
Since you are using a forcing function that is a step this is a transient problem and
not an AC analysis, so it is best to work in the Laplace domain.  This boils down to
expressing the impedances in terms of the variable 's' instead of 'jw'.  Actually the
variable 's' can be equal to 'jw' later too if we want it to be, but for the transient
analysis it is easier to keep it as just 's'.
There is a catch however, and that is if there are initial conditions (in this case
that would be initial voltages across each capacitor) then the analysis has to include
those voltage values also, but many times the initial voltages are all zero.  If they
are not zero there are ways to handle that but i'll save that for another time.

Ok so with all cap voltage equal to zero, we want to get the total impedances on both
sides of VM1.  The impedance to the left is simple R1.  The impedance to the right is
a combination of C1,C2,C3, and R2.
Since C2 and R2 are in series, we can write the impedance as:
Z2=R2+1/(s*C2)
and since that impedance is in turn in parallel with C3, we have to use the parallel formula:
ZT=Z1*Z2/(Z1+Z2)
and here Z2 is Z2 as above and Z1 is 1/(s*C2).
For now though, let's use the impedances for each cap instead of combining the full expressions
right away.  The impedances for the caps can be written:
zC1=1/(s*C1)
zC2=1/(s*C2)
zC3=1/(s*C3)
and you can see how simple that is.
Now the series connection of R2 and C2 is (and i'll introduce some new variables also):
z22=R2+zC2
That's even simpler.
That is in parallel with zC3 so we use the parallel formula:
z223=zC3*z22/(zC3+z22)
Now we have the impedance to the right of C1.
Since C1 is in series with that impedance, we can write:
z2231=zC1+z223
Ok so now we have all the required impedances to use the voltage divider formula.
The voltage VM1 is then equal to:
VM1=V1*z2231/(R1+z2231)
and so the transfer function is:
VM1/V1=z2231/(R1+z2231)


Now when you go back and substitute all the previous definitions in you get:
VM1=V1*C1*R1*(s*C2*C3*R2+C3+C2)/(s^2*C1*C2*C3*R1*R2+s*C2*C3*R2+s*C1*C2*R2+s*C1*C3*R1+s*C1*C2*R1+C3+C2+C1)

and since V1 is a step it is equal to Vpk/s we substitute that in for V1 and get:
(Vpk*C1*R1*(s*C2*C3*R2+C3+C2))/(s*(s^2*C1*C2*C3*R1*R2+s*C2*C3*R2+s*C1*C2*R2+s*C1*C3*R1+s*C1*C2*R1+C3+C2+C1))

That is the expression that we would find the Inverse Laplace Transform of.  There could be up to 3
different time solutions depending on the values of the components.

Since this is a little complicated, let's say we have all the caps equal and all the resistors equal, that
means that:
C3=C2=C1=C
and:
R2=R1=R

and if we substitute C in for all caps and R in for all resistors, we end up with:
VM1=(Vpk*(2*s*C*R+3))/(s*(s*C*R+1)*(s*C*R+3))

Taking the Inverse Laplace Transform of that we get:
VM1(t)=-(Vpk*e^(-t/RC))/2-(Vpk*e^(-(3*t)/RC))/2+Vpk
where RC=R*C.
This is just one exponential but if it was more complicated as before we would have to look for 3 solutions
depending on the values of the components, unless we can specify the values before we take the inverse
transform.

If we then set RC=1 and Vpk=1 we get:
VM1(t)=-e^(-t)/2-e^(-3*t)/2+1

Sometimes it comes out simpler even with separate components if we specify the values before we take the
inverse transform.  For example, as we use these values:
R1=1, R2=2, C1=1, C2=2, C3=3,
then we get:
VM1(t)=(e^(-(7*t)/8)*((44*sinh((sqrt(17)*t)/8)*Vpk)/(3*sqrt(17))-4*cosh((sqrt(17)*t)/8)*Vpk))/4+Vpk

and that can be simplifed further.

From the transfer function above we can also get the final value after a long time has passed by taking
the limit as s goes toward zero.  The result will be VM1=Vpk and that is easy to verify by inpection.

Note there are other ways to do this also.  One notable method is to replace V1 with a large number of
harmonics and sum the result at VM1 using superposition.  For that we would use s=j*w and do the complex
math to get the total sum, then find the norm of that to get the voltage.

Using automatic software such as Maxima you can do these lines:
zC1:1/(s*C1);
zC2:1/(s*C2);
zC3:1/(s*C3);
z22:R2+zC2;
z223:zC3*z22/(zC3+z22);
z2231:zC1+z223;
VM1:V1*z2231/(R1+z2231);

and that will give you the solution in 's' and then you can substitute V1=Vpk/s and find the inverse
transform.  I highly recommend replacing the cap and resistors values with their numerical values first though so you dont have to choose which solution you need, the software will choose the correct form.
 
The following users thanked this post: robzy, rstofer

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: Calculating the voltage of an RC network
« Reply #5 on: December 11, 2022, 08:24:39 am »
MrAl did all the hard work (thanks!) so I'll just post a PDF of the wxMaxima solution

That's a LOT of algebra and reminds me of why I struggled in the networks class.  This was long before scientific calculators or home computers.  Slide rules were king and essentially useless for this kind of thing.
 
The following users thanked this post: robzy

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 128
  • Country: au
Re: Calculating the voltage of an RC network
« Reply #6 on: December 11, 2022, 09:39:10 am »
Wow! Thank you so much MrAl!

This turned out to be a much more complicated question than I was expecting.

The backstory here is that I'm (trying) to design a capacitve rotation sensor, but then I stumbled accross this simple-looking-to-me problem and wanted to learn how to solve it.

I've actually spent some time today trying to solve it by hand as a first-order ODE system, but the algebra got nasty REAL quick. I was also reading the Wikipedia article on network analysis, but its a bit topic, and I wasn't sure where I should be starting.

Thank you for telling me about Maxima! That will be super helpful.

I think I need to go read upmore on the Laplace domain!


 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: Calculating the voltage of an RC network
« Reply #7 on: December 11, 2022, 09:48:58 am »
LTspice gives a picture of the response for specific values of V, R & C.

Attached is a screen shot of the transient response for values I picked and the .asc file for LTspice

If you run the .asc file you may need to manually change the Y axis to allow for some negative voltage.  My plot is for -20 uV .. +20 uV.

The step is only 1V.

You can change the values as you wish.  LTspice gives a picture which I find more satisfying than the equations.  Particularly that huge equation for Vm.
 
The following users thanked this post: robzy

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: Calculating the voltage of an RC network
« Reply #8 on: December 11, 2022, 09:55:32 am »
Thank you for telling me about Maxima! That will be super helpful.

You want to download wxMaxima to get the GUI workspace along with Maxima as the solver:

http://wxmaxima-developers.github.io/wxmaxima/
 

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 128
  • Country: au
Re: Calculating the voltage of an RC network
« Reply #9 on: December 11, 2022, 12:03:59 pm »
I got Maxima installed using Homebrew on Mac.... and I ended up getting the Laplace transforms to work in Jupyter. What an awesome analysis tool! Cheers!

https://nbviewer.org/gist/robzyb/f6e0d6551be3be20143315c97738210d

I've just watched a bunch of youtube videos on Laplace space, and its starting to make sense.

But I am curious - how did MrAl know there could be up to 3 different time solutions depending on the values of the components? That was a very specific number of different solutions.
 

Offline MrAl

  • Super Contributor
  • ***
  • Posts: 1522
Re: Calculating the voltage of an RC network
« Reply #10 on: December 11, 2022, 05:50:17 pm »
I got Maxima installed using Homebrew on Mac.... and I ended up getting the Laplace transforms to work in Jupyter. What an awesome analysis tool! Cheers!

https://nbviewer.org/gist/robzyb/f6e0d6551be3be20143315c97738210d

I've just watched a bunch of youtube videos on Laplace space, and its starting to make sense.

But I am curious - how did MrAl know there could be up to 3 different time solutions depending on the values of the components? That was a very specific number of different solutions.

Hello again,

Well that's actually quite simple.  There is always the possibility of an overdamped, underdamped, or critically damped solution.  Those are the three.  The actual one found will depend on the component values and of course the topology, but with a given topology there can still be three different solutions depending on the value of the components (R, L, and C values).
The overdamped case has an exponential only response, but there could be more than one exponential.
The critically damped case has an exponential.
The underdamped case generally has one or more exponentials and also sinusoidal terms.  The other two dont have sinusoidal terms.
The overdamped case looks like a capacitor charging through a resistor somewhat slowly.
The critically damped case is like a capacitor charging through a resistor but just so fast, and if it were to rise any faster it would turn into the underdamped case, so it's right on the border of looking like a cap charging through a resistor and a solution with exponential and sinusoidal terms.  The critically damped case is kind of rare though because it takes very very specific values, so usually the solution will come out to either overdamped or underdamped.
The typical underdamped case often looks like a ringing pulse waveform where the output rises as it squiggles up and down like a sinusoid and then at some point levels off to a straight line.  In the solution you will see both e^(-a*t) terms and sin(w*t) terms.

I should also point out that if you allow negative square roots in the solution you can get just one single solution, but it will always simplify to one of the three.  That's because sinh() can turn into sin(), and sin() can turn into sinh(), (or same with cosh and cos).

You can tell the order of the solution by the highest power of 's' in the solution after it has been simplified as much as possible.  If you see just 's' in the denominator then it's first order, if s^2 then second order, if s^3 then third order, and so on.  That's before you apply the step Vpk/s.

State vector DE's can help with this too if you are into that.  You can then analyze with initial values also.  The solution with be similar to a set of ODE's and Maxima can handle that too.

If you have some specific values for the components we could go over that as an example and plot the output.

« Last Edit: December 12, 2022, 06:29:17 am by MrAl »
 

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 128
  • Country: au
Re: Calculating the voltage of an RC network
« Reply #11 on: December 12, 2022, 07:12:53 am »
If you have some specific values for the components we could go over that as an example and plot the output.
Heh, I've actually been playing with some specific values for the components, and it was so awesome to see that the plot of VM1(t) lined up perfectly with my simulations on CircuitLab!

https://nbviewer.org/gist/robzyb/ce710eb2b411ae448d59f937d1805896 (see the plot down the bottom)

I've been wanting to play with it more, but I'm running into issues with SymPy's inverse Laplace transform, and its evaluation engine. My next step will be sorting those out.

The overdamped case looks like a capacitor charging through a resistor somewhat slowly.
Interesting!

Since this is only an RC network, wouldn't all solutions be overdamped? The caps will charge up asymptotically to a final state. I don't see why there'd be any resonance or sinusoidal terms.

I've played around with various values in the VM1(s) formula, and they always seem to result in VM1(t)s having exponential but not sinusoids. But maybe there's a combination I haven't tried yet?

Either way, the s-domain feels like a superpower. I'm looking forward to experimenting more!

LTspice gives a picture of the response for specific values of V, R & C.

Attached is a screen shot of the transient response for values I picked and the .asc file for LTspice

If you run the .asc file you may need to manually change the Y axis to allow for some negative voltage.  My plot is for -20 uV .. +20 uV.
Thank you so much for sharing that! I'll be moving from CircuitLab to LTspice for this.
« Last Edit: December 12, 2022, 07:15:06 am by robzy »
 

Offline The Electrician

  • Frequent Contributor
  • **
  • Posts: 745
  • Country: us
Re: Calculating the voltage of an RC network
« Reply #12 on: December 12, 2022, 08:42:28 am »
I got Maxima installed using Homebrew on Mac.... and I ended up getting the Laplace transforms to work in Jupyter. What an awesome analysis tool! Cheers!

https://nbviewer.org/gist/robzyb/f6e0d6551be3be20143315c97738210d

I've just watched a bunch of youtube videos on Laplace space, and its starting to make sense.

But I am curious - how did MrAl know there could be up to 3 different time solutions depending on the values of the components? That was a very specific number of different solutions.

The result you have in "Out[7] doesn't seem to be correct.  I get:



MrAL also got this.
 

Offline robzyTopic starter

  • Regular Contributor
  • *
  • Posts: 128
  • Country: au
Re: Calculating the voltage of an RC network
« Reply #13 on: December 12, 2022, 08:59:02 am »

The result you have in "Out[7] doesn't seem to be correct.  I get:

Good pickup. I believe that the two expressions are equal but in slightly different form.

The differences in form are due to:
  • My calculation factored out exp(-3t/CR)/2 from the brackets. I don't know how to push it back in.
  • The theta(t) in my calculation is simply the Heaviside step function and can be ignored. It sets VM1(t)=0 for t<0. More info. I've since learned that I can avoid it by limiting t to be positive with: t = symbols('t', positive=True)
« Last Edit: December 12, 2022, 09:09:55 am by robzy »
 

Offline MrAl

  • Super Contributor
  • ***
  • Posts: 1522
Re: Calculating the voltage of an RC network
« Reply #14 on: December 13, 2022, 09:11:38 am »
If you have some specific values for the components we could go over that as an example and plot the output.
Heh, I've actually been playing with some specific values for the components, and it was so awesome to see that the plot of VM1(t) lined up perfectly with my simulations on CircuitLab!

https://nbviewer.org/gist/robzyb/ce710eb2b411ae448d59f937d1805896 (see the plot down the bottom)

I've been wanting to play with it more, but I'm running into issues with SymPy's inverse Laplace transform, and its evaluation engine. My next step will be sorting those out.

The overdamped case looks like a capacitor charging through a resistor somewhat slowly.
Interesting!

Since this is only an RC network, wouldn't all solutions be overdamped? The caps will charge up asymptotically to a final state. I don't see why there'd be any resonance or sinusoidal terms.

I've played around with various values in the VM1(s) formula, and they always seem to result in VM1(t)s having exponential but not sinusoids. But maybe there's a combination I haven't tried yet?

Either way, the s-domain feels like a superpower. I'm looking forward to experimenting more!


Hello again,

The three possible solutions are 'general' to a second order system.  It is entirely possible that a given network has only overdamped or critically damped solutions regardless what components you select.  If you leave it up to the software you dont have to think about it, but if you do then you would have to prove that the expression under this radical:
sqrt((C2*C3*R2+C1*C2*R2+C1*C3*R1+C1*C2*R1)^2-4*C1*C2*C3*(C3+C2+C1)*R1*R2)

is either always positive, always negative, or always zero.  I think it is positive but you can check that.
If it is always positive then you prove that the solution will always be overdamped, and if always zero then critically damped, and if aways negative then sinusoidal with possible exponentials also.

That expression is referred to as the discriminant.  That determines which of the three cases you will have.  If you change components, the case may change also, but there could of course be times when if they are all positive (as many cases in electronics) then the solution will have to always be one of the three.

If you care to do that then just assume all the values there are positive and see if you can prove that the value under the radical always comes out positive.

Just to note, I didnt check out your numerical result yet.

You may also want to look at Fourier as that helps in AC analysis as much as Laplace helps in transient analysis.
To analyze for AC, replace s with j*w where w=2*pi*f where f is frequency in Hertz.  To find the amplitude find the norm of the result, and to find the phase shift use the two argument inverse tangent tan2(imag,real) where imag is the imaginary part and real is the real part of the result.

These are both very powerful methods.
« Last Edit: December 14, 2022, 04:40:11 am by MrAl »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf