Capacitor Output Response to Nonsinusoidal Source

Thread Starter

N|kolαTeslα

Joined Sep 17, 2017
19
I'm a little bit confuse about the output waveform of the capacitor. What I mean is, in the capacitor, we can use the formula Vo = Vs(1-e^-t/RC) for charging and Vo = Vse^-t-t1/RC) for discharging but I notice that these use DC sources where Vo is the instantaneous voltage. I figured out that sinusoidal input can be solve to find the Vo but how about sawtooth, triangular or square wave ? how can I find Vo ?
 

Papabravo

Joined Feb 24, 2006
22,082
When you change the forcing function to a differential equation you don't change the underlying dynamics, only the constraints. Go back to your text for ODE and see how the solutions for a step function and a sinusoidal function are derived now do the same thing for the unit ramp function, or a triangle function. Because the system is linear you can do a piecewise analysis, by matching initial anf final conditions.
 

Thread Starter

N|kolαTeslα

Joined Sep 17, 2017
19
When you change the forcing function to a differential equation you don't change the underlying dynamics, only the constraints. Go back to your text for ODE and see how the solutions for a step function and a sinusoidal function are derived now do the same thing for the unit ramp function, or a triangle function. Because the system is linear you can do a piecewise analysis, by matching initial anf final conditions.
When you change the forcing function to a differential equation you don't change the underlying dynamics, only the constraints. Go back to your text for ODE and see how the solutions for a step function and a sinusoidal function are derived now do the same thing for the unit ramp function, or a triangle function. Because the system is linear you can do a piecewise analysis, by matching initial anf final conditions.
Thank you, I will try that.
 

Bordodynov

Joined May 20, 2015
3,431
I=C*dVc(t)/dt=C*dVc(t)/dt ==> (Vin(t)-Vc(t))/R=C*dVc(t)/dt ==>
Vc+R*C*dVc(t)/dt=vin(t), t=time
A differential equation is obtained! For the sine it is easily solved.
 
Last edited:

Janis59

Joined Aug 21, 2017
1,894
The matematically correct - just integrate the differential equation and voila. Little bit more simple solution - just divide the known waveform into Fourier harmonics and calc every harmonic separately, and then superpose them. Fast and relyable. For example, is known that meander form takes 1/3*F3+1/5*f5+1/7*f7 +.... then calc the voltage of each of them at chosen running time and sum.
But most practical OF COURSE, turn on the LT Spice.exe, choose the triangle or what You like the waveform and put the screen oscilloscope over the chosen capacitor.
 

MrAl

Joined Jun 17, 2014
13,704
I'm a little bit confuse about the output waveform of the capacitor. What I mean is, in the capacitor, we can use the formula Vo = Vs(1-e^-t/RC) for charging and Vo = Vse^-t-t1/RC) for discharging but I notice that these use DC sources where Vo is the instantaneous voltage. I figured out that sinusoidal input can be solve to find the Vo but how about sawtooth, triangular or square wave ? how can I find Vo ?
Hi,

When you use 'formulas' like:
Vo = Vs(1-e^-t/RC) and vo = Vse^-t-t1/RC)

what might not be apparent is that these formulas came from an analysis of the RC circuit with a step input and zero initial conditions. For more complicated input waveforms (other than step) you have to go back to the circuit and sort of start all over again and derive the expressions for that new situation. Often we have to include the initial conditions parameter also so that we can work with input waves that change from one form to another.
For example, for a square wave input we would have to change the input wave once when the square wave goes high and once when it goes low, and do that for every single cycle, and that requires having the initial condictions parameter include in the 'formula'.

Another approach is the harmonic analysis approach, which can provide the continuous time solution as a series, although it may not provide the correct result for the first part of the response where the exponentials have not all died out yet.

What makes all this somewhat simpler is the Laplace Transform and the Fourier Series. Sometimes we need calculus to be able to use these two tools, but with online math programs this gets easier today.
 

Thread Starter

N|kolαTeslα

Joined Sep 17, 2017
19
The matematically correct - just integrate the differential equation and voila. Little bit more simple solution - just divide the known waveform into Fourier harmonics and calc every harmonic separately, and then superpose them. Fast and relyable. For example, is known that meander form takes 1/3*F3+1/5*f5+1/7*f7 +.... then calc the voltage of each of them at chosen running time and sum.
But most practical OF COURSE, turn on the LT Spice.exe, choose the triangle or what You like the waveform and put the screen oscilloscope over the chosen capacitor.
That's the answer Im looking for. Thanks!
 

Thread Starter

N|kolαTeslα

Joined Sep 17, 2017
19
Hi,

When you use 'formulas' like:
Vo = Vs(1-e^-t/RC) and vo = Vse^-t-t1/RC)

what might not be apparent is that these formulas came from an analysis of the RC circuit with a step input and zero initial conditions. For more complicated input waveforms (other than step) you have to go back to the circuit and sort of start all over again and derive the expressions for that new situation. Often we have to include the initial conditions parameter also so that we can work with input waves that change from one form to another.
For example, for a square wave input we would have to change the input wave once when the square wave goes high and once when it goes low, and do that for every single cycle, and that requires having the initial condictions parameter include in the 'formula'.

Another approach is the harmonic analysis approach, which can provide the continuous time solution as a series, although it may not provide the correct result for the first part of the response where the exponentials have not all died out yet.

What makes all this somewhat simpler is the Laplace Transform and the Fourier Series. Sometimes we need calculus to be able to use these two tools, but with online math programs this gets easier today.
Thank you, really great help. Maybe I should try all suggested solutions.
 

MrAl

Joined Jun 17, 2014
13,704
Thank you, really great help. Maybe I should try all suggested solutions.
Hi,

You are welcome, and i just have to suggest one or two more ideas that i should have mentioned here.
That is, numerical methods.

Numerical methods are invaluable for finding solutions and virtually every circuit simulator in existence that i know about to date uses a numerical solver of some kind. This is mostly because many circuits are non linear and there are no analytical solutions to many non linear circuits, and non linear circuits occur almost exclusively in real life except in academic studies.

One of the simplest methods is Taylor's method for solving ODE's. It goes by other names sometimes. This is simplest for a first order problem but a system solution isnt that much more complicated because it just follows the same pattern for the other variables.

Another simple method is a rough approximation based on a discrete step in both time an amplitude. This is interesting because it gives some insight into the way things work. I'll provide a quick example, which i think you will understand almost as soon as you hear it.

When we have a cap charging with zero initial voltage on the cap, we have the formula:
Vc=Vs*(1-e^(-t/RC))

and i start from this because you are already familiar with this one.
That is for when there is no initial cap voltage, but we need a formula that includes the initial cap voltage, and to get that all we do is subtract Vc from Vs, do the multiplication as before, then add Vc back to it. We end up with:
Vc=(Vs-Vc)*(1-e^(-t/RC))+Vc

and all we did was subtract Vc from Vs and add Vc back again as a separate term. That's because the multiplier depends on the difference between Vs and Vc now, but the cap voltage starts out at Vc.

The idea now that we have that is very simple: we digitize the input signal into discrete steps and calculate the response for each step. This would be more formally called a recursive solution because we keep calcualting the same thing over and over again except with the new values we get from the previous calculation.

For a simple example of that, say we want to do a ramp input that goes from 0v at t=0 to 1v at t=1 second, and say RC=1.
First we change the variable 't' to 'dt' in the formula because we will make each time step the same (this is not necessary if we make an adaptive formula, but let's keep this simple):
Vc=(Vs-Vc)*(1-e^(-dt/RC))+Vc

Next we need to change Vs because that changes with a ramp, so because we go from 0v to 1v in 1 second the ramp is simple 't', so we replace Vs with 't':
Vc=(t-Vc)*(1-e^(-dt/RC))+Vc

Now we have a recursive solution, and let's say we want to use a time step of 0.1 and since RC=1 we replace them:
Vc=(t-Vc)*(1-e^(-0.1/1))+Vc

so of course we end up with:
Vc=(t-Vc)*(1-e^(-0.1))+Vc

With this means is that the next value of Vc is equal to the right side of that, and that value of Vc becomes the next value to use on the right side for the next time step. Since we can calculate the 1-e part we end up with:
Vc=0.09516258196404*(t-Vc)+Vc

and now all we have to do is run this calculation several times making t first 0.1, then 0.2, then 0.3, etc., until we get to t=1, starting with Vc=0 if the initial cap voltage is zero to start with.
Remember Vc on the right takes on the new value of Vc on the left after a calculation.

Doing this for t=0.1 to 1 we end up with a final value of:
Vc=0.399

which is an approximate solution.

If we do it analytically we get:
Vc=0.368

which is exact for those four digits, so our approximation is somewhat close but not too close. This indicates that we should make the time step smaller, say 0.01 second instead of 0.1 second. We'd get a mroe accurate result then, but we'd have to do the iteration 100 times then for time from 0.01 to 1.00.

So that's another way to do it, and it is possible there is a series summation solution once we find the recursive formula.
 

Thread Starter

N|kolαTeslα

Joined Sep 17, 2017
19
Hi,

You are welcome, and i just have to suggest one or two more ideas that i should have mentioned here.
That is, numerical methods.

Numerical methods are invaluable for finding solutions and virtually every circuit simulator in existence that i know about to date uses a numerical solver of some kind. This is mostly because many circuits are non linear and there are no analytical solutions to many non linear circuits, and non linear circuits occur almost exclusively in real life except in academic studies.

One of the simplest methods is Taylor's method for solving ODE's. It goes by other names sometimes. This is simplest for a first order problem but a system solution isnt that much more complicated because it just follows the same pattern for the other variables.

Another simple method is a rough approximation based on a discrete step in both time an amplitude. This is interesting because it gives some insight into the way things work. I'll provide a quick example, which i think you will understand almost as soon as you hear it.

When we have a cap charging with zero initial voltage on the cap, we have the formula:
Vc=Vs*(1-e^(-t/RC))

and i start from this because you are already familiar with this one.
That is for when there is no initial cap voltage, but we need a formula that includes the initial cap voltage, and to get that all we do is subtract Vc from Vs, do the multiplication as before, then add Vc back to it. We end up with:
Vc=(Vs-Vc)*(1-e^(-t/RC))+Vc

and all we did was subtract Vc from Vs and add Vc back again as a separate term. That's because the multiplier depends on the difference between Vs and Vc now, but the cap voltage starts out at Vc.

The idea now that we have that is very simple: we digitize the input signal into discrete steps and calculate the response for each step. This would be more formally called a recursive solution because we keep calcualting the same thing over and over again except with the new values we get from the previous calculation.

For a simple example of that, say we want to do a ramp input that goes from 0v at t=0 to 1v at t=1 second, and say RC=1.
First we change the variable 't' to 'dt' in the formula because we will make each time step the same (this is not necessary if we make an adaptive formula, but let's keep this simple):
Vc=(Vs-Vc)*(1-e^(-dt/RC))+Vc

Next we need to change Vs because that changes with a ramp, so because we go from 0v to 1v in 1 second the ramp is simple 't', so we replace Vs with 't':
Vc=(t-Vc)*(1-e^(-dt/RC))+Vc

Now we have a recursive solution, and let's say we want to use a time step of 0.1 and since RC=1 we replace them:
Vc=(t-Vc)*(1-e^(-0.1/1))+Vc

so of course we end up with:
Vc=(t-Vc)*(1-e^(-0.1))+Vc

With this means is that the next value of Vc is equal to the right side of that, and that value of Vc becomes the next value to use on the right side for the next time step. Since we can calculate the 1-e part we end up with:
Vc=0.09516258196404*(t-Vc)+Vc

and now all we have to do is run this calculation several times making t first 0.1, then 0.2, then 0.3, etc., until we get to t=1, starting with Vc=0 if the initial cap voltage is zero to start with.
Remember Vc on the right takes on the new value of Vc on the left after a calculation.

Doing this for t=0.1 to 1 we end up with a final value of:
Vc=0.399

which is an approximate solution.

If we do it analytically we get:
Vc=0.368

which is exact for those four digits, so our approximation is somewhat close but not too close. This indicates that we should make the time step smaller, say 0.01 second instead of 0.1 second. We'd get a mroe accurate result then, but we'd have to do the iteration 100 times then for time from 0.01 to 1.00.

So that's another way to do it, and it is possible there is a series summation solution once we find the recursive formula.
Thank you Sir, I get the concept. I have one in mind. How about be we consider the frequency, lets say I input 10kHz.
My point is we will have capacitive reactance and the amplitude may vary.
 

MrAl

Joined Jun 17, 2014
13,704
Thank you Sir, I get the concept. I have one in mind. How about be we consider the frequency, lets say I input 10kHz.
My point is we will have capacitive reactance and the amplitude may vary.
If you are dealing with sine waves only then the amplitude of the output is:
Vout=Vin/sqrt(w^2*C^2*R^2+1)

and the phase shift is:
Ph=-atan(w*C*R)

so that's a lot simpler then. If you want to do different frequencies then just use different w:
w=2*pi*f

where f is the frequency in Hertz.
 
Top