RC transient response of a sinusoidal input

Discussion in 'Analog & Mixed-Signal Design' started by Ermanno, Oct 1, 2018.

  1. Ermanno

    Thread Starter New Member

    Nov 19, 2017
    5
    0
    Hello there, was examinating a simple RC circuit in LTSpice when the input was sinusoidal (DC=0V) and I noticed an exponential transient I didn't expected. I took pen and used Laplace to gain more insight.
    Applying a sin(wt) gave me the exact behavior of LTSpice, a decreasing exponential starting from wRC/(1+(wRC)^2) ~ 1/wRC. But when it comes to an applied cos(wt) things doesn't work out at all. The LTSpice simulation is in the attachment: as you can see the exponential starts from the same starting point of the input (a cosine of 1V amplitude). This is somehow intuitive, but using Laplace I get the following exponential :-w/(1+(wRC)^2) *exp(-t/RC) obtained by calculating the effect of the pole -1/RC of the output expression Vo(s)=s/(s^2+w^2) * H(S) where s/(s^2+w^2) = Laplace(cos(wt)) and H(s)=1/(1+sRC) is the LPF transfer function. The obtained exponential starts from a negative value and has little value. Also, the contribution of the other two imaginary poles reflects in the sinusoidal steady state output which is not of my interest (I have calculated that aswell and it's ok).

    What am I doing wrong? Thanks.
     
  2. AlbertHall

    AAC Fanatic!

    Jun 4, 2014
    6,392
    1,485
    In the simulation settings, tick 'skip initial operating point calculation'.
    The sine wave starts at 1V and so that initial calculation has the capacitor charged to 1V before the start of the simulation. With that calculation skipped, the capacitor voltage starts at 0V.
     
  3. Ermanno

    Thread Starter New Member

    Nov 19, 2017
    5
    0
    Thanks for the hint. So basically I had to include a initial condition on the capacitor and so in the Laplace equations? Still the exponential decay which comes out of Laplace (the one which should start from -w/(1+(wRC)^2) according to my calculations) is not present, the output is just sinusoidal around zero (steady state).
     
  4. crutschow

    Expert

    Mar 14, 2008
    19,805
    5,543
    That start-up transient depends upon the circuit initial conditions and the phase of the sinewave at the start of the transient.
    With proper selection of the initial conditions there is no exponential decay at the start (which does show up in your post #1 simulation).
     
  5. Ermanno

    Thread Starter New Member

    Nov 19, 2017
    5
    0
    Thanks for answer but I'm not sure about the non presence of decay with zero condition applied. Have you tried using Laplace? For example, look at the images I attach here, it is the output when an input sine wave (starting from 0V) is applied (with "skip initial operating point calculation" on). You can see the transient and that's what you get with Laplace. With a cosine it doesn't show up in simulation even if it does so in my Laplace calculations. That's my problem.
     
  6. crutschow

    Expert

    Mar 14, 2008
    19,805
    5,543
    Sorry it's been many years since I've use Laplace transforms, so I'm not that cognizant with their use.
    But I would expect that if you put the same initial conditions into the Laplace transform as for the cosine in the simulation, the Laplace transient values should end up having essentially a zero value.
     
  7. MrAl

    AAC Fanatic!

    Jun 17, 2014
    5,189
    1,121
    Hi,

    Not sure what you mean by "cos(wt) does not work out at all".
    You should be able to excite the circuit with either sine or cosine.

    If we excite with a sine with phase=0, we get three terms (A is peak amplitude):
    (w*A*C*R*e^(-t/(C*R)))/(w^2*C^2*R^2+1)-(w*cos(t*w)*A*C*R)/(w^2*C^2*R^2+1)+(sin(t*w)*A)/(w^2*C^2*R^2+1)

    and if we excite with cosine with phase=0 we get three terms:
    -(A*e^(-t/(C*R)))/(w^2*C^2*R^2+1)+(w*sin(t*w)*A*C*R)/(w^2*C^2*R^2+1)+(cos(t*w)*A)/(w^2*C^2*R^2+1)

    and you can see that both of these solutions have a non zero exponential term and because the exponent is negative there is something decreasing in the wave for some time which is what you would see in a simulation or on a scope. After some long time relative to the time constant we would see mostly a sinusoid as the exponential would have damped out, but before that the exponential part shows itself.

    In the sine case, if you set the initial voltage of the cap to exactly:
    v=-(w*A*C*R)/(w^2*C^2*R^2+1)
    (although it looks like something else is going on in your sim too)

    the exponential part goes to zero so you only see sinusoidal parts.

    Alternately in the sine case, if you set the phase to exactly:
    ph=atan(w*C*R)

    again the exponential part goes away.

    So you have those choices and there may be others that i did not explore. Of course you could always let the time go to a long time and then you'd see mostly a sinusoid.

    The general form is usually something like:
    A*e^(-a*t)+(B*sin(w*t)+C*cos(w*t))

    and that can be reduced to a simpler form:
    A*e^(-a*t)+(D*sin(w*t+Ph))

    where Ph is solved for, Once you get rid of the exponential part then you end up with something like:
    D*sin(w*t+Ph)
    or
    E*cos(w*t+Ph2)

    which are clearly sinusoids.
     
    Last edited: Oct 3, 2018
    Ermanno likes this.
  8. Ermanno

    Thread Starter New Member

    Nov 19, 2017
    5
    0
    Thanks for this deep comment. In my sin simulation I didn't put any initial condition and thus spice correctly starts the output sinusoid from w*A*C*R*/(w^2*C^2*R^2+1) which would be canceled out as you say if I putted the initial condition at -w*A*C*R*/(w^2*C^2*R^2+1). What I meant by "cos(wt) does not work out at all" is that if I excite the circuit with a cosine setting NO initial condition (as done in the sin case) the exponential that you said starting from -A/(w^2*C^2*R^2+1) is just not there and the output starts already at steady state (pure sinusoid).
    I hope I have explained my problem better now.
     
  9. MrAl

    AAC Fanatic!

    Jun 17, 2014
    5,189
    1,121
    Hi again and thanks for the reply,

    You could check the exponential coefficient for both sine and cosine excitation given your values which i think you indicate are:
    R=1k
    C=60uf
    f=1kHz
    A=1
    (you could verify these)

    and see what the amplitude is using the formulas given. If the amplitude is low relative to the sinusoid parts, then you may see very little exponential effects just because they are small anyway.
    With simulators though sometimes there are background things going on which change results somewhat so you'd have to check that too.
    I'll check myself too if i get a chance today using a different simulator.

    [LATER]
    This was actually easy to do so here are some results.

    The two solutions (sine, cosine) with the given values came out to:
    7.0361438008277502*10^-6*sin(6283.185307179586*t)
    -0.0026525637209138*cos(6283.185307179586*t)
    +0.0026525637209138/e^(16.66666666666667*t)

    and:
    ,0.0026525637209138*sin(6283.185307179586*t)
    +7.0361438008277502*10^-6*cos(6283.185307179586*t)-
    (7.0361438008277502*10^-6)/e^(16.66666666666667*t)]

    and if we zero out the less significant sinusoidal parts we end up with:
    -0.0026525637209138*cos(6283.185307179586*t)
    +0.0026525637209138/e^(16.66666666666667*t)

    and:
    ,0.0026525637209138*sin(6283.185307179586*t)
    -(7.0361438008277502*10^-6)/e^(16.66666666666667*t)]

    Examining and comparing these last two, we see that in the first case (sine) we see the exponential part coefficient equal to the sinusoidal part coefficient, which tells us that the exponential part is very significant.
    In the second case (cosine) we see the exponential part coefficient a small percentage of the sinusoidal part coefficient and so the exponential part is very insignificant and probably will not be noticed. Also, due to the numerical instability of basic floating point calculations it could actually be zero but we'd have to look into that. Even with this small level though it probably can not be seen on a regular simulation output graphic.

    It's not uncommon to see a cosine wave excitation have this kind of effect so i had to wonder what was meant by the quote about the cosine wave not working at all.

    [LATER LATER]
    I calculated the required phase shift in the sine case and came up with:
    ph=89.848 degrees
    which of course is very close to a cosine wave (but not exact) and this is why it would appear that a cosine wave completely eliminates the exponential part while there is still a very small exponential part. It's so small though in a simulation it probably wont matter except in some extreme case.
     
    Last edited: Oct 5, 2018
    Ermanno likes this.
  10. Ermanno

    Thread Starter New Member

    Nov 19, 2017
    5
    0
    Everything checks out. I confirm all your calculations. Thanks a lot!
    I did calculations by hand, did you as well or you got numbers from a different simulator? If the latter can you share the name? Could be handy!
     
  11. MrAl

    AAC Fanatic!

    Jun 17, 2014
    5,189
    1,121
    Hi,

    I used MicroCap just to see the simulation and Maxima to do the calculations.
    If you do the network solution for both initial voltage and phase shift, then you can zero either one and solve for the other and that helps determine the required offset and/or phase shift that would be required to completely eliminate the exponential part.
     
    Ermanno likes this.
Loading...