Author Topic: ltspice - what does .ic V(C1)=10 actually do?  (Read 895 times)

0 Members and 1 Guest are viewing this topic.

Offline ledtesterTopic starter

  • Super Contributor
  • ***
  • Posts: 3248
  • Country: us
ltspice - what does .ic V(C1)=10 actually do?
« on: May 13, 2024, 11:41:04 pm »
In the simple RC circuit below setting the initial condition V(C1)=3 doesn't seem to do anything, but setting the initial voltage of the node OUT (e.g. V(OUT)=3) works to start the capacitor voltage at 3V.

So why doesn't .ic V(C1)=3 do the same thing as .ic V(OUT)=3?

 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: ltspice - what does .ic V(C1)=10 actually do?
« Reply #1 on: May 13, 2024, 11:55:11 pm »
You assign it to nodes, not components.

Whether it throws an error or is ignored passively, I suppose depends on the SPICE engine.

You need to put the "IC=3" on the C1 statement itself (or in the part edit dialog), which will set the respective node(s).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: ledtester

Offline ledtesterTopic starter

  • Super Contributor
  • ***
  • Posts: 3248
  • Country: us
Re: ltspice - what does .ic V(C1)=10 actually do?
« Reply #2 on: May 14, 2024, 12:06:20 am »
Ok, I think I understand now...

This directive:

Code: [Select]
.ic V(C1)=3

is quietly ignored. In order to set the initial voltage of C1 you have to:

1. Control-Right-Click on the cap to bring up the Component Attribute Editor.
2. Add "IC=3" to SpiceLine2
3. To make this visible on the schematic click in the "Vis." column to put an "X" on that line.

Whew!
 

Offline Sensorcat

  • Regular Contributor
  • *
  • Posts: 115
  • Country: de
  • Independent Sensor Consultant
    • Sensorberatung
Re: ltspice - what does .ic V(C1)=10 actually do?
« Reply #3 on: May 14, 2024, 12:16:50 am »
Ok, I think I understand now...

This directive:

Code: [Select]
.ic V(C1)=3

is quietly ignored. In order to set the initial voltage of C1 you have to:

1. Control-Right-Click on the cap to bring up the Component Attribute Editor.
2. Add "IC=3" to SpiceLine2
3. To make this visible on the schematic click in the "Vis." column to put an "X" on that line.

Whew!
Yes, but C1 is not symmetric in simulation. It has a first and a second node that define the positive voltage direction. So you can accidentally apply -3V that way. Your original solution to set the node voltage is easier to understand and not ambiguous in the schematic.
 

Offline ledtesterTopic starter

  • Super Contributor
  • ***
  • Posts: 3248
  • Country: us
Re: ltspice - what does .ic V(C1)=10 actually do?
« Reply #4 on: May 14, 2024, 03:08:07 am »
Yes, but C1 is not symmetric in simulation. It has a first and a second node that define the positive voltage direction. So you can accidentally apply -3V that way. Your original solution to set the node voltage is easier to understand and not ambiguous in the schematic.

True but what I've determined is that the voltage is is consistent with the current arrow that the cursor turns to when you hover over the device after running a simulation -- the arrow points from the high voltage end to the low voltage end (assuming your initial condition voltage is positive).

Now that I have read the docs more carefully I think my confusion was that the .IC can set the initial current through a part (like inductors) but for voltage it can only set it for nodes.

Of course, for the polarity of an initial current setting you'll probably have to look at the arrow that the cursor changes to when you hover over it. It would be nice if ltspice could indicate this polarity on the schematic. One proposed solution is to use a different symbol  which indicates which end is which:

https://electronics.stackexchange.com/a/661590/95488
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: ltspice - what does .ic V(C1)=10 actually do?
« Reply #5 on: May 14, 2024, 04:20:54 am »
Can also look at the netlist, in case you're working with it; current is always into the first node. (Likewise, positive voltage sources delivering power have negative current, and current sources are "from-to".)

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf