Voltage-variable capacitor doesn't work in LTSpice

Mar 17, 2015 92 Replies

Gentlemen,



Setting up voltage-controlled resistors is easy: R=(V(X)+0.01) or whatever. Works, always did. Doing the same with a capacitor fails with this error message:



Error on line 6 : c1 n002 0 c=(v(x)+0.01) Unable to find definition of model "c" * Unknown parameter "x" WARNING: Less than two connections to node X. This node is used by V4. Fatal Error: Missing capacitance value for "C1"



Both sims attached. What gives? Ideas how to make it work? Disregard the values that wouldn't make sense for the cap here, this is just to find the principal reason why the control method doesn't work with capacitors.


Variable resistor:



Version 4 SHEET 1 880 680 WIRE -80 -32 -256 -32 WIRE 64 -32 0 -32 WIRE 320 -32 64 -32 WIRE 64 0 64 -32 WIRE -640 16 -640 -48 WIRE -256 16 -256 -32 WIRE 320 16 320 -32 WIRE -640 112 -640 96 WIRE -256 112 -256 96 WIRE 64 112 64 80 WIRE 320 112 320 80 FLAG -256 112 0 FLAG -640 112 0 FLAG -640 -48 X FLAG 64 112 0 FLAG 320 112 0 SYMBOL voltage -256 0 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V2 SYMATTR Value 2.048 SYMBOL res 48 -16 R0 SYMATTR InstName R1 SYMATTR Value R=(V(X)+0.01) SYMBOL res -96 -16 R270 WINDOW 0 32 56 VTop 2 WINDOW 3 0 56 VBottom 2 SYMATTR InstName R2 SYMATTR Value 2.49k SYMBOL voltage -640 0 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V4 SYMATTR Value PULSE(0 1 1n 1m 2m 1m 5m 1) SYMBOL cap 304 16 R0 SYMATTR InstName C1 SYMATTR Value 1p TEXT -472 -96 Left 2 !.tran 5m


Variable capacitor:



Version 4 SHEET 1 880 680 WIRE -80 -32 -256 -32 WIRE 64 -32 0 -32 WIRE 320 -32 64 -32 WIRE 64 0 64 -32 WIRE -640 16 -640 -48 WIRE -256 16 -256 -32 WIRE 320 16 320 -32 WIRE -640 112 -640 96 WIRE -256 112 -256 96 WIRE 64 112 64 80 WIRE 320 112 320 80 FLAG -256 112 0 FLAG -640 112 0 FLAG -640 -48 X FLAG 64 112 0 FLAG 320 112 0 SYMBOL voltage -256 0 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V2 SYMATTR Value 2.048 SYMBOL res 48 -16 R0 SYMATTR InstName R1 SYMATTR Value 100k SYMBOL res -96 -16 R270 WINDOW 0 32 56 VTop 2 WINDOW 3 0 56 VBottom 2 SYMATTR InstName R2 SYMATTR Value 2.49k SYMBOL voltage -640 0 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V4 SYMATTR Value PULSE(0 1 1n 1m 2m 1m 5m 1) SYMBOL cap 304 16 R0 SYMATTR InstName C1 SYMATTR Value C=(V(X)+0.01) TEXT -472 -96 Left 2 !.tran 5m



Regards, Joerg http://www.analogconsultants.com/

[snip]

See VVC.zip and VVR.zip on the Device Models & Subcircuits Page of my website for the proper notation. ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

Here's one I did a while back... can't remember why.

formatting link

What's annoying is that Q is a function of voltage, not C.

John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

One is Altium and on PSpice. I checked the VVC for Altium in Notepad (can't open it in the viewer) but it seems it's only a LUT version. I need a real voltage control.

Regards, Joerg http://www.analogconsultants.com/

Yes, I'd rather control C directly with a voltage. Why does LTSpice refuse this? Maybe I'll have to ask over at the Yahoo forum, after figuring out the dreaded login there. With that was a NG as well.

Regards, Joerg http://www.analogconsultants.com/

I used to use ECA under DOS, a great netlist-based simulator. It always converged and cruised through divide-by-zero and other errors. It let you express any voltage, current, or R/L/C value as a simple expression of anything else.

John Larkin Highland Technology, Inc picosecond timing laser drivers and controllers jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

Sorry. I had forgotten that "VVC" is a varicap model.

"Real" voltage control is trivial to do. Tell me the desired expression... C = f(V) and I'll knock it for you in a few minutes ;-) ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

ECA224 was a great little simulator. I loved it. When starting self-employed in 1989 I bought a PSpice license. I still have the cloth-covered binders, IBM-style. Those were the days when I entered a SPICE schematic in ASCII, pounding out the netlist in IBM EasyWriter. It felt real manly just like cooking over wood fire. Scared clients though because they couldn't see the schematic.

Regards, Joerg http://www.analogconsultants.com/

Here's an ECA netlist. I may have the hand-drawn schematic around here somewhere. It would be a nuisance to reverse-engineer it from the netlist.

' VARIAN L701 GRADIENT DRIVER MODEL L701.CKT ' ' BY JOHN LARKIN ' HIGHLAND TECHNOLOGY, INC ' SAN FRANCISCO ' ' SEPTEMBER 15, 1993 ' ' THIS VERSION INCLUDES... ' ' 3 AMP PEAK DRIVE ' SIMPLE TRANSCONDUCTANCE OUTPUT STAGE ' WITH THERMAL TAILS ' ' FIRST, DO THE AD1862 20-BIT DAC... ' VDAC 0 0 -3 RDAC 1 0 1u ' ' HERE'S THE SHUNT AND PREAMP... ' SHUNT .05R X GAIN 20 = 1V/AMP ' R10 10 0 .05 U2 10 12 OP278

  • 11 0 R11 11 12 1900.013 R12 12 0 100 ' ' AND THE ERROR AMP... ' U3 0 15 OP278
  • 20 0 R5 1 15 2K R13 11 15 2K ' ' LOOP COMPENSATION PARTS... ' RZ 15 16 10K CZ 16 20 1.5N ' ' THIS IS THE OUTPUT TRANSCONDUCTANCE AMP... ' R21:C21 IS 15 KHZ ROLLOFF ' TRANSCONDUCTANCE IS 3 AMPS/10 VOLTS = 0.3 SIEMENS ' R21 20 21 1K C21 21 0 15N IAMP 21 0 0.3 RAMP 30 0 10K

' SIMULATE THE THERMAL HOOK OF THE OUTPUT ' DARLINGTON. ASSUME... ' ' CHIP THERMAL TAU = 20 mSEC ' THETA = 2 DEGC/WATT ' POWER PULSE = 25 WATTS ' EMITTER RESISTOR = 1 OHM ' TRANSISTOR VBE 5 mV/DEGC ' THERMAL HOOK 250 mV/3V = 1/12

R90 21 90 12K C90 90 0 2U

' ' AND THE GRADIENT COIL LOAD... ' LM 30 31 15U RM 31 10 1.2

John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com
[snip].

I started out with Berkeley Spice on a VAX, pencil-drawn schematics, number the nodes, write the netlist with a text editor... my son Aaron, while still a teenager (now 45 :-), wrote me a netlist version control so I could back up to a previous netlist easily if I made a change that malfunctioned.

When PSpice first came out I continued that procedure until MicroSim Schematics arrived, which I still use to this day. I absolutely hated OrCAD Crapture. ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.
[snip]

Here you go...

.SUBCKT VControlledCap CAP+ CAP- VC+ VC- PARAMS: C1=1nF C2=100pF C_C1 CAP+ N_1 {C1} R_NOF1 VC+ 0 1G R_NOF2 VC- 0 1G V_IM1 N_1 CAP- 0 G_G2 CAP+ CAP- VALUE {C2/C1*V(VC+,VC-)*I(V_IM1)} .ENDS VControlledCap

When VC=,VC1 is zero, cap value is C1

When VC=,VC1=+1, cap value is C1+C2

When VC=,VC1=-1, cap value is C1-C2

I'll post this to my website in a few days... honey-do projects abound ;-) ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

Typos galore, lagging/leading shift key, text should say...

When VC+,VC- is zero, cap value is C1

When VC+,VC- = +1, cap value is C1+C2

When VC+,VC- = -1, cap value is C1-C2 ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

Thanks, Jim. Couldn't make a go of it yet, it errors with "Port(pin) count mismatch between the definition of subcircuit "vcontrolledcap" and instance: "xc1" ... The instance has fewer connection terminals than the definition"

Regards, Joerg http://www.analogconsultants.com/

Read the help files about how to make a symbol in LTspice by highlighting the .subckt line. ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

I bet you could build a variable c-multiplier with a capacitor and a multiplier, or an e source with the right expression.

John Larkin Highland Technology, Inc picosecond timing laser drivers and controllers jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

If you dynamically change the value of a capacitor, do you end up with discontinuities in the stores charge on that cap?

I guess the only way to change the voltage across a voltage-dependant capacitor is to apply current, which takes power, so energy is conserved. A varicap doesn't violate conservation of energy.

If a c value depended on something independent of the terminal voltage, you could apparently violate COE. Imagine a charged parallel-plate capacitor connected to nothing. If you yank (yank!) the plates apart, c goes down, Q is conserved, V goes up, and more energy is stored in the cap. Pulling the plates apart took mechanical work, which is where the added energy came from.

In my proposed c-multiplier, the e source can do work.

John Larkin Highland Technology, Inc picosecond timing laser drivers and controllers jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

Guys, I do not want to change the capacitance by changing the voltage at the cap terminals. I want to change the capacitance by a mathematical expression where the control function is a rail (or a voltage) in some other distant land in the schematic. I still do not understand why this works perfectly for a resistor value but it does not for a capacitor value. For the resistor I do not have to make some other model with more terminals, I can just key in expressions such as "R=V(X)" in the value field where X is a rail somewhere else that I assign the label "X".

Regards, Joerg http://www.analogconsultants.com/

To learn how to do this, search LTspice Help for "automatic symbol"...

VControlledCap.asy

Version 4 SymbolType BLOCK RECTANGLE Normal -64 -40 80 40 WINDOW 0 8 -40 Bottom 2 WINDOW 3 8 40 Top 2 WINDOW 39 8 64 Top 2 SYMATTR Prefix X SYMATTR Value VControlledCap SYMATTR ModelFile C:\Projects\Expments\BehavioralComponents\ASY Copy of VControlledCap.net SYMATTR SpiceLine C1=1nF C2=100pF PIN -64 -16 LEFT 8 PINATTR PinName CAP+ PINATTR SpiceOrder 1 PIN -64 16 LEFT 8 PINATTR PinName CAP- PINATTR SpiceOrder 2 PIN 80 -16 RIGHT 8 PINATTR PinName VC+ PINATTR SpiceOrder 3 PIN 80 16 RIGHT 8 PINATTR PinName VC- PINATTR SpiceOrder 4 ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.
[snip]

My previously posted subcircuit VControlledCap does exactly as you want.

I have just now posted VControlledCap.asy so you can get the pinout correct >:-} ...Jim Thompson

| James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required