# LC Circuit LTSpice Simulation With Time Switch

I'm sorry if this topic isn't adequate for the forum.

Does anyone know how can I make this LC circuit simulation for $$\v_{c}(t)\$$?

The original circuit is the one shown in the figure.

$$\v_{C}(t)=\left(-\dfrac{RC\omega A}{1+(RC\omega)^{2}}\right)e^{-\frac{t}{RC}}+\dfrac{A}{\sqrt{1+(RC\omega)^{2}}}\sin({\omega t+\arctan{(RC\omega)}}) \quad , t\leq 0.24\, s\$$ $$\v_{C}(t)=v_{C}(t=0.24^{-})\cdot\cos{^{2}(0.24\cdot\omega_{0})}+v_{C}(t=0.24^{-})\sin{(\omega_{0}t)}\quad ,t> 0.24\, s\$$

I'm trying to do the LTSpice analysis for $$\t\geq 0.24\, s\$$.

I found $$\v_{c}(t=0.24)=-0.143118\, V\$$ with the values that were given (R = 120Ω, C = 0,1mF, L = 1mH and ω = 120π) which I used as the initial condition along with $$\i_{L}(t=0.24)=0\, A\$$ as it is shown here:

But I'm not getting the sinusoidal curve and I can't understand why.

• I'm not sure I understand. If the inductor and capacitor are ideal, then when the two switches change state (together) the LC will be isolated and will therefore resonate "forever." The only way things diminish over time is if there is a method for dissipating energy (resistance or radiation.) But if the L and C are ideal, then how will they dissipate? I assuming here that when the left switch closes, the right switch opens. Am I wrong in that? (And what is the value of $V$ out of curiousity?) – jonk Apr 30 '19 at 4:19
• It's exactly what you say. I just want that sine wave in the result. – FelipeMedLev Apr 30 '19 at 4:26
• $V=Asin(\omega t)$ . I don't have the value of A, so I'm assuming it's 1. – FelipeMedLev Apr 30 '19 at 4:27
• Your schematic shows the switches changing at t = 0.24 s. Then your text says you want the simulation results for t > 24 s. Why wait 23.76 s after the switches change to start being interested in the results? – The Photon Apr 30 '19 at 5:07
• I tried to reproduce your result in LTSpice IV and I got oscillations. Can you do "View->SPICE Netlist" and copy the netlist into your question (formatted as code)? – The Photon Apr 30 '19 at 5:15

Left click on .ic V(n001)=0.2107 I(L1)=0 and make sure the text is a SPICE directive.
When it is a Comment, you get the output as shown in OP.

Shown below is an example how to implement switches at t=0.24s in the original schematic.
Instead of setting a value for a resistor, it uses an equation.

HINT: To address your possible next question, do read: Ideal LC circuit decays over time in LTspice

• This would be the best simulation I could do, but when I try using the conditional "if" in the resistors, an error pops up which says: "Missing model definition for IF". Thank you! – FelipeMedLev Apr 30 '19 at 16:23
• You didn't forget to proceed it with R= I presume? Where you normally enter "4.7k" as value, you should enter R=if(...) as value, including the R= part – Huisman Apr 30 '19 at 20:16
• Thank you very much! – FelipeMedLev May 1 '19 at 16:37

How is this for a staring point? Play with the values as required. Your question does not explicitly state $$\V_1\$$ and you give 2 different values for $$\t\$$ so I was not sure which you wanted.

You also need to set the parasitics for the inductor and capacitor or it may be damped fairly quickly. For the inductor 'Rpar=0' seems counter intuitive but it actually means there isn't a parallel resistance but there is no $$\\infty\$$ on your keyboard.

Yeah, the way to make variable resistors with a Resistance value equal to a voltage. The voltage can then be triggered by a PWL source or PULSE source like so (the blue is the current through R1, green is the ResistorValue voltage node):

I set the time arbitrarily, but the way this works is the voltage source is a square wave from 0.25 to 0.5s. The initial value I set to 0.1V (which translates into ohms after you set it to a resistance value. I set a high value of 1e9V (Ohms) for the resistance. In your case it might be best to set up two "ResistorValue" nodes one fore each switch.

Here is the code

"ExpressPCB Netlist"
"LTspice XVII"
1
0
0
""
""
""
"Part IDs Table"
"R1" "R={V(ResistorValue)}" ""
"V1" "PULSE(0.1 1e9 0.25 0.0001 0.0001 0.25 10)" ""
"V2" "5" ""

"Net Names Table"
"N001" 1
"0" 3
"ResistorValue" 6

"Net Connections Table"
1 1 1 2
1 3 1 0
2 1 2 4
2 2 2 5
2 3 2 0
3 2 1 0

• How is this answer supposed to connect to the question that was asked? – The Photon Apr 30 '19 at 5:53
• It's not now that I look at it. I thought they were having a problem with the switches, but it looks like they are having problems setting up initial conditions. This kind of answer results from trying to answer late at night – Voltage Spike Apr 30 '19 at 15:12