Establish initial capacitor voltage.asc


 

.IC can only use terms whose values are known before the simulation starts, fairly obviously, so V(vc1_L) can't be used. Why have you used a E source rather than an ordinary voltage generator?

On 2024-11-21 20:48, Group Notification wrote:

The following items have been added to the Files area of the LTspice@groups.io group.

By: Christopher Paul <christopherrpaul1@...>

Description:
Attempting to establish an initial voltage across an ungrounded capacitor using the .ic directive. Voltage is established, but I'm getting a .ic syntax error and one side of the capacitor has been grounded. How can I achieve my goal and avoid the syntax error?

-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.www.avg.com


 

I may be mistaken, but I believe you want to use:

               .ic V(c1) 10m

 

Dave

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of John Woodgate
Sent: Thursday, November 21, 2024 12:58 PM
To: LTspice@groups.io
Subject: EXTERNAL: Re: [LTspice] File /Temp/Establish initial capacitor voltage.asc uploaded #file-notice

 

.IC can only use terms whose values are known before the simulation starts, fairly obviously, so V(vc1_L) can't be used. Why have you used a E source rather than an ordinary voltage generator?

On 2024-11-21 20:48, Group Notification wrote:

The following items have been added to the Files area of the LTspice@groups.io group.

By: Christopher Paul <christopherrpaul1@...>

Description:
Attempting to establish an initial voltage across an ungrounded capacitor using the .ic directive. Voltage is established, but I'm getting a .ic syntax error and one side of the capacitor has been grounded. How can I achieve my goal and avoid the syntax error?

-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

 

Virus-free.www.avg.com


 

The E source is a simple simulation of the gain of 2 op amp in my circuit. The problem exists even if it is replaced with a simple 2V source.

 

Can you suggest how to establish an initial voltage across the capacitor without initially grounding one side?

 

 

.IC can only use terms whose values are known before the simulation starts, fairly obviously, so V(vc1_L) can't be used. Why have you used a E source rather than an ordinary voltage generator?


 

Dave Bell, unfortunately, that causes the more negative side of he capacitor to be initially grounded


 

Clearly violates the Principal of Least Astonishment for an application!

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of Christopher Paul via groups.io
Sent: Thursday, November 21, 2024 1:23 PM
To: LTspice@groups.io
Subject: EXTERNAL: Re: [LTspice] Establish initial capacitor voltage.asc

 

Dave Bell, unfortunately, that causes the more negative side of he capacitor to be initially grounded


 

Any circuit is unaffected by where the 'ground' is, as long as there is only one ground symbol and you aren't using one of a few subcircuits that violate the rules. So you could either attach the ground symbol to one plate of the capacitor, or interchange  the capacitor and resistor. Then ic=10m.

This point can be difficult to grasp, but think of any physical circuit that is working from batteries or an isolated mains supply. Now connect a grounding wire to any point on the circuit. It will continue to operate, unaffected.

On 2024-11-21 21:18, Christopher Paul via groups.io wrote:

The E source is a simple simulation of the gain of 2 op amp in my circuit. The problem exists even if it is replaced with a simple 2V source.

 

Can you suggest how to establish an initial voltage across the capacitor without initially grounding one side?

 

 

.IC can only use terms whose values are known before the simulation starts, fairly obviously, so V(vc1_L) can't be used. Why have you used a E source rather than an ordinary voltage generator?

-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.www.avg.com


 

Thanks John. No, I well understand the ground placement idea.

 

I can’t just reverse the positions of the cap and resistor. To keep things simple, I did not show that the circuit has a current flowing from ground into the junction of the capacitor and the 100-ohm resistor.

 

But with your suggestion, it just occurred to me that I CAN reverse their positions if I connect the current source terminals to the re-positioned 100-ohm resistor terminals.

 

Thanks for the discussion, which allowed me to come up with a solution.

 

 

Any circuit is unaffected by where the 'ground' is, as long as there is only one ground symbol and you aren't using one of a few subcircuits that violate the rules. So you could either attach the ground symbol to one plate of the capacitor, or interchange  the capacitor and resistor. Then ic=10m.

This point can be difficult to grasp, but think of any physical circuit that is working from batteries or an isolated mains supply. Now connect a grounding wire to any point on the circuit. It will continue to operate, unaffected.

On 2024-11-21 21:18, Christopher Paul via groups.io wrote:

The E source is a simple simulation of the gain of 2 op amp in my circuit. The problem exists even if it is replaced with a simple 2V source.

 

Can you suggest how to establish an initial voltage across the capacitor without initially grounding one side?

 

 

.IC can only use terms whose values are known before the simulation starts, fairly obviously, so V(vc1_L) can't be used. Why have you used a E source rather than an ordinary voltage generator?

_._,_._,_


 

Not true, Dave Bell.

 

Not shown are a pair of 74HC4053 switches connecting each capacitor terminal to an op amp output at time t < 0, thus establishing the voltage across the capacitor.

 

At time t >= 0, the switches are thrown open. I want to establish circuit operation at time t >= 0.

 

A discussion with John Woodward has helped me to come up with a solution.

 

Thanks to you both.

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of Bell, Dave via groups.io
Sent: Thursday, November 21, 2024 4:32 PM
To: LTspice@groups.io
Subject: Re: [LTspice] Establish initial capacitor voltage.asc

 

Clearly violates the Principal of Least Astonishment for an application!


 

Instead of using the .IC V(N1)=V syntax, which references V(N1) to ground, there are two other possibilities:
  1. Use a differential voltage: .IC V(n1,n2)=V, or
  2. Embed the IC within the capacitor: add IC y to the SpiceLine parameter of the capacitor. (You can also add it directly to the Value, i.e.: 100n IC V.) See: Help > LTspice > LTspice® > Circuit Elements > C. Capacitor
--
Regards,
Tony




On 21/11/2024 22:18, Christopher Paul via groups.io wrote:

The E source is a simple simulation of the gain of 2 op amp in my circuit. The problem exists even if it is replaced with a simple 2V source.

 

Can you suggest how to establish an initial voltage across the capacitor without initially grounding one side?



 

Many thanks, Tony, your number 1 is the answer I was looking for. The form .IC V(n1,n2) does not appear in the LTspice 17.1.14 Help menu.

 

Regards,

 

Chris

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of Tony Casey via groups.io
Sent: Thursday, November 21, 2024 5:35 PM
To: LTspice@groups.io
Subject: Re: [LTspice] Establish initial capacitor voltage.asc

 

Instead of using the .IC V(N1)=V syntax, which references V(N1) to ground, there are two other possibilities:

  1. Use a differential voltage: .IC V(n1,n2)=V, or
  2. Embed the IC within the capacitor: add IC y to the SpiceLine parameter of the capacitor. (You can also add it directly to the Value, i.e.: 100n IC V.) See: Help > LTspice > LTspice® > Circuit Elements > C. Capacitor

--

Regards,
Tony

 

On 21/11/2024 22:18, Christopher Paul via groups.io wrote:

The E source is a simple simulation of the gain of 2 op amp in my circuit. The problem exists even if it is replaced with a simple 2V source.

 

Can you suggest how to establish an initial voltage across the capacitor without initially grounding one side?

 


 
Змінено

On Fri, Nov 22, 2024 at 08:56 AM, Christopher Paul wrote:

Many thanks, Tony, your number 1 is the answer I was looking for.

Don't discount his option 2.  I think that was the original way in SPICE to add an initial condition to a capacitor., and it has the advantage that it is independent of node names (which can change around when you edit your schematic).  It can be added either:
  • in the same field with the capacitance value - so your capacitor would have a "value" of "1n  IC=10m",
  • or in the "Value2" attribute:
    • Ctrl-right-click on the capacitor symbol, then write "IC=10m" on the Value2 line, and put an "X" in the "Vis" column for that line.
 

The form .IC V(n1,n2) does not appear in the LTspice 17.1.14 Help menu.

That notation is the normal SPICE way to specify any differential voltage.  I think you can use V(n1,n2) just about anywhere that a voltage is needed or specified.  It is in the LTspice Help, but it might be several pages back and not where you were looking.
 
On Thu, Nov 21, 2024 at 04:12 PM, Bell, Dave wrote:

I may be mistaken, but I believe you want to use:

               .ic V(c1) 10m

I don't think so.  That would try to set the voltage at node C1, which does not exist.

 

That particular notation, where the .IC command refers to the component's name rather that nodes, works only for inductors.  Inductors are special in that way.

 

Andy

 

 


 

Thanks for the recommendation of #2, Andy, the first bullet below, now my favorite choice.

 

Having done so, when I right click on the capacitor, “{C} IC= {Vc0}” (what I wrote for bullet 1) appears on the Capacitance [F]: line. There is no Value2 line or “Vis” column.

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of Andy I via groups.io
Sent: Friday, November 22, 2024 9:22 AM
To: LTspice@groups.io
Subject: Re: [LTspice] Establish initial capacitor voltage.asc

 

On Fri, Nov 22, 2024 at 08:56 AM, Christopher Paul wrote:

Many thanks, Tony, your number 1 is the answer I was looking for.

Don't discount his option 2.  I think that was the original way in SPICE to add an initial condition to a capacitor., and it has the advantage that it is independent of node names (which can change around when you edit your schematic).  It can be added either:

  • in the same field with the capacitance value - so your capacitor would have a "value" of "1n  IC=10m",
  • or in the "Value2" attribute:
    • Ctrl-right-click on the capacitor symbol, then write "IC=10m" on the Value2 line, and put an "X" in the "Vis" column for that line.

 

The form .IC V(n1,n2) does not appear in the LTspice 17.1.14 Help menu.

That notation is the normal SPICE way to specify any differential voltage.  I think you can use V(n1,n2) just about anywhere that a voltage is needed or specified.  It is in the LTspice Help, but it might be several pages back and not where you were looking.

 

On Thu, Nov 21, 2024 at 04:12 PM, Bell, Dave wrote:

I may be mistaken, but I believe you want to use:

               .ic V(c1) 10m

I don't think so.  That would try to set the voltage at node C1, which does not exist.

 

That particular notation, where you refer to the component's name rather that nodes, works only for inductors.  Inductors are special in that way.

 

Andy

 

 


 

On Fri, Nov 22, 2024 at 09:49 AM, Christopher Paul wrote:

Having done so, when I right click on the capacitor, “{C} IC= {Vc0}” (what I wrote for bullet 1) appears on the Capacitance [F]: line. There is no Value2 line or “Vis” column.

 
Read carefully what I wrote.  The lines for [Value2, SpiceLine, SpiceLine2] and the "Vis" column are there only in the "General Attribute Editor".  For many components, including capacitors, LTspice gives you a more specialized component editor instead of the General Attribute Editor when you use just a Right-Click on the symbol.  For those components, you must use Ctrl-Right-Click to get to the General Attribute Editor - from where you can access all the symbol attributes, including Value2 and the Vis column.  Everything that can be edited in the specialized component editor can also be edited in the General Attribute Editor, which is more flexible but less tailored for that particular component type.
 
Bear in mind, my two bulleted choices in that reply were an EITHER-OR choice.  If you use the first bullet, don't also use the second bullet choice.  Use one OR the other.
 
The nice thing about bullet 2 is that the capacitor's value and the IC=<value> can be on two separate lines on your schematic.  You can't do that from the specialized capacitor component editor.
 
Andy
 
 


 

Thanks, Andy.

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of Andy I via groups.io
Sent: Friday, November 22, 2024 10:53 AM
To: LTspice@groups.io
Subject: Re: [LTspice] Establish initial capacitor voltage.asc

 

On Fri, Nov 22, 2024 at 09:49 AM, Christopher Paul wrote:

Having done so, when I right click on the capacitor, “{C} IC= {Vc0}” (what I wrote for bullet 1) appears on the Capacitance [F]: line. There is no Value2 line or “Vis” column.

 

Read carefully what I wrote.  The lines for [Value2, SpiceLine, SpiceLine2] and the "Vis" column are there only in the "General Attribute Editor".  For many components, including capacitors, LTspice gives you a more specialized component editor instead of the General Attribute Editor when you use just a Right-Click on the symbol.  For those components, you must use Ctrl-Right-Click to get to the General Attribute Editor - from where you can access all the symbol attributes, including Value2 and the Vis column.  Everything that can be edited in the specialized component editor can also be edited in the General Attribute Editor, which is more flexible but less tailored for that particular component type.

 

Bear in mind, my two bulleted choices in that reply were an EITHER-OR choice.  If you use the first bullet, don't also use the second bullet choice.  Use one OR the other.

 

The nice thing about bullet 2 is that the capacitor's value and the IC=<value> can be on two separate lines on your schematic.  You can't do that from the specialized capacitor component editor.

 

Andy