Electronics-Related.com
Forums

Voltage-variable capacitor doesn't work in LTSpice

Started by Joerg March 16, 2015
On Wed, 18 Mar 2015 16:34:10 -0700, Joerg <news@analogconsultants.com>
wrote:

>On 2015-03-18 2:50 PM, Jim Thompson wrote: >> On Wed, 18 Mar 2015 14:44:39 -0700, Joerg <news@analogconsultants.com> >> wrote:
[snip]
>>> >>> I have not given up yet but so far I got all kinds of error messages. >>> The next step would be to try it on an XP machine where I'd have to get >>> LTSpice going again. XP was IMHO the last known good OS and I've had >>> error message in other software caused by Windows 7 (meaning they didn't >>> happen on an XP machine). >> >> What kind of error messages? >> >> If you use the LTspice _symbol_ I made, you need to open the .ASY file >> with a text editor and change the path to wherever you've located the >> subcircuit definition library. >> > >And there is the first problem. Windows 7 no longer allows writes to the >program directories.
I have LTspice installed in a directory outside of Program Files. I haven't "upgraded" to Win7 yet. I hope I can still get away with that.
>Well, it does but secretly stashes them some place >else but then access become an issue. I'll get to the ground of that, >hav to for my CAD as well, just not right now. The usual, swamped in >work plus honey-do stuff.
I appreciate the problem ;-)
> >And, we had to get a Mexican Burger at one of our favorite watering >holes. Along with an Old Republic red ale.
Aha! The most important interruption >:-}
> > >> The latest version, on the website, shows how more clearly. >> >> ...Jim Thompson >>
...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.
On 2015-03-18 2:55 PM, John Larkin wrote:
> On Wed, 18 Mar 2015 14:03:07 -0700, Joerg <news@analogconsultants.com> > wrote: > >> On 2015-03-18 1:46 PM, John Larkin wrote: >>> On Wed, 18 Mar 2015 13:36:27 -0700, Joerg <news@analogconsultants.com> >>> wrote: >>> >>>> On 2015-03-18 11:54 AM, Syd Rumpo wrote: >>>>> On 17/03/2015 00:26, Joerg wrote: >>>>>> 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. >>>>>> >>>>> <snip> >>>>> >>>>> This is what I did for a time-varying capacitance. In the component >>>>> 'Value' field, I put Q=(4p/(0.25 +(time*5)))*x which swept the >>>>> capacitance from 16pF downwards controlled by the internal variable 'time'. >>>>> >>>>> I can't remember why you need the Q and the x, but you do, and it took a >>>>> good while to find out - it seems you can't just vary the capacitance >>>>> directly. Replace time with a voltage and the appropriate scaling and >>>>> you should be good to go. >>>>> >>>> >>>> Tried it and that completely bungled the linearity when the cap is >>>> inside a resonant circuit. At least no more error messages which is >>>> good. Well, maybe I just do it in hardware then, firing up the old >>>> Weller. I'd have to buy a bag of varicaps but those are cheap. >>> >>> Are you trying to sim a VCO? Simulating oscillators is always tedious. >>> >> >> No, it's a circuit where a capacitive sensor is employed and I want to >> mimic the sensor output. The capacitor itself will be inside a somewhat >> resonant circuit so it has to behave like a real and clean capacitor. > > Would something like this work? > > https://dl.dropboxusercontent.com/u/53724080/Circuits/Caps/Modulated_Cap_1.asc > > The cap is modulated by voltage ZZ, which in this case makes the cap > ramp from 1F to 20F. That in turn sweeps the LC ringing frequency > down. >
Thanks, John, that actually seems to work. Beats me why mine didn't because the only difference was that I called "ZZ" "Y" instead. -- Regards, Joerg http://www.analogconsultants.com/
On Wed, 18 Mar 2015 16:39:38 -0700, Joerg <news@analogconsultants.com>
wrote:

>On 2015-03-18 2:55 PM, John Larkin wrote: >> On Wed, 18 Mar 2015 14:03:07 -0700, Joerg <news@analogconsultants.com> >> wrote: >> >>> On 2015-03-18 1:46 PM, John Larkin wrote: >>>> On Wed, 18 Mar 2015 13:36:27 -0700, Joerg <news@analogconsultants.com> >>>> wrote: >>>> >>>>> On 2015-03-18 11:54 AM, Syd Rumpo wrote: >>>>>> On 17/03/2015 00:26, Joerg wrote: >>>>>>> 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. >>>>>>> >>>>>> <snip> >>>>>> >>>>>> This is what I did for a time-varying capacitance. In the component >>>>>> 'Value' field, I put Q=(4p/(0.25 +(time*5)))*x which swept the >>>>>> capacitance from 16pF downwards controlled by the internal variable 'time'. >>>>>> >>>>>> I can't remember why you need the Q and the x, but you do, and it took a >>>>>> good while to find out - it seems you can't just vary the capacitance >>>>>> directly. Replace time with a voltage and the appropriate scaling and >>>>>> you should be good to go. >>>>>> >>>>> >>>>> Tried it and that completely bungled the linearity when the cap is >>>>> inside a resonant circuit. At least no more error messages which is >>>>> good. Well, maybe I just do it in hardware then, firing up the old >>>>> Weller. I'd have to buy a bag of varicaps but those are cheap. >>>> >>>> Are you trying to sim a VCO? Simulating oscillators is always tedious. >>>> >>> >>> No, it's a circuit where a capacitive sensor is employed and I want to >>> mimic the sensor output. The capacitor itself will be inside a somewhat >>> resonant circuit so it has to behave like a real and clean capacitor. >> >> Would something like this work? >> >> https://dl.dropboxusercontent.com/u/53724080/Circuits/Caps/Modulated_Cap_1.asc >> >> The cap is modulated by voltage ZZ, which in this case makes the cap >> ramp from 1F to 20F. That in turn sweeps the LC ringing frequency >> down. >> > >Thanks, John, that actually seems to work. Beats me why mine didn't >because the only difference was that I called "ZZ" "Y" instead.
Well, that's what you need an expert for! It may matter about whitespace in the Q equation; it doesn't seem to like any. Well, I may find this useful in the future. -- John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com
On Wednesday, March 18, 2015 at 1:54:56 PM UTC-4, John Larkin wrote:
> On Wed, 18 Mar 2015 17:40:06 +0000 (UTC), DecadentLinuxUserNumeroUno > <DLU1@DecadentLinuxUser.org> wrote: > > >On Wed, 18 Mar 2015 10:30:44 -0700, John Larkin wrote: > > > >> On Wed, 18 Mar 2015 09:28:57 -0700, Jim Thompson > >> <To-Email-Use-The-Envelope-Icon@On-My-Web-Site.com> wrote: > >> > >>>Voltage-Controlled Capacitor Spice Model now on my website. > >>> > >>>See VControlledCap.zip on the Device Models & Subcircuits Page. > >>> > >>>Includes Library File (.LIB), LTspice Symbol (.ASY), and a JPEG showing > >>>how it was developed. > >>> > >>> ...Jim Thompson > >> > >> I don't have time to play with this just now, but one quick question: > >> > >> Given that C is a variable capacitor, set C to 1F and charge it to 1 > >> volt. Now change C to 0.5F. What is the new voltage? > > > > How many 1 farad capacitors are you aware of? > > > In LT Spice, you can use any C value. 1F is the generic capacitor. I > usually normalize theoretical circuits to 1F, 1H, 1 ohm. [1] > > In real life, Digikey will sell you 1F caps. Or 5000F caps. But not > variable 1F caps. > > > > > Oh and would not a 1F charged cap dump into a 0.5F cap and fully charge > >it? If that answer is yes, then the voltage would be the same... > >slightly less even, all elements considered. > > > > You thought it would morph the EMF into something else? > > I'd like to know if Jim's model conserves charge, or conserves energy, > or conserves voltage. Or whatever it does.
Well, energy conservation seems silly... if you are changing C, moving plates around, someone has to provide the energy. And I assume charge or voltage depends on how it's hooked up. George H.
> > > [1] I do find myself picking standard values, like 39nF instead of 40 > nF, and worrying about leakage and stray capacitance and power > dissipation, when none of these matter in Spice. > > > > -- > > John Larkin Highland Technology, Inc > picosecond timing precision measurement > > jlarkin att highlandtechnology dott com > http://www.highlandtechnology.com
On 2015-03-18 4:38 PM, Jim Thompson wrote:
> On Wed, 18 Mar 2015 16:34:10 -0700, Joerg <news@analogconsultants.com> > wrote: > >> On 2015-03-18 2:50 PM, Jim Thompson wrote: >>> On Wed, 18 Mar 2015 14:44:39 -0700, Joerg <news@analogconsultants.com> >>> wrote: > [snip] >>>> >>>> I have not given up yet but so far I got all kinds of error messages. >>>> The next step would be to try it on an XP machine where I'd have to get >>>> LTSpice going again. XP was IMHO the last known good OS and I've had >>>> error message in other software caused by Windows 7 (meaning they didn't >>>> happen on an XP machine). >>> >>> What kind of error messages? >>> >>> If you use the LTspice _symbol_ I made, you need to open the .ASY file >>> with a text editor and change the path to wherever you've located the >>> subcircuit definition library. >>> >> >> And there is the first problem. Windows 7 no longer allows writes to the >> program directories. > > I have LTspice installed in a directory outside of Program Files. I > haven't "upgraded" to Win7 yet. I hope I can still get away with > that. >
Win 7 is a royal pain in the you-know-what. I needed a new PC because of simulation speed and they didn't offer XP anymore :-(
>> Well, it does but secretly stashes them some place >> else but then access become an issue. I'll get to the ground of that, >> hav to for my CAD as well, just not right now. The usual, swamped in >> work plus honey-do stuff. > > I appreciate the problem ;-) > >> >> And, we had to get a Mexican Burger at one of our favorite watering >> holes. Along with an Old Republic red ale. > > Aha! The most important interruption >:-} >
Yeah, but now I have to bicycle lots of extra miles to work off the calories.
>> >> >>> The latest version, on the website, shows how more clearly. >>>
Thanks. I'll still try that but meantime John's version worked on my PC. It doesn't need any custom symbols. I originally tried it almost the same way but mine produced error messages while John's doesn't. -- Regards, Joerg http://www.analogconsultants.com/
Den torsdag den 19. marts 2015 kl. 00.34.08 UTC+1 skrev Joerg:
> On 2015-03-18 2:50 PM, Jim Thompson wrote: > > On Wed, 18 Mar 2015 14:44:39 -0700, Joerg <news@analogconsultants.com> > > wrote: > > > >> On 2015-03-18 2:15 PM, Jim Thompson wrote: > >>> On Wed, 18 Mar 2015 14:03:07 -0700, Joerg <news@analogconsultants.com> > >>> wrote: > >>> > >>> [snip] > >>>>> > >>>> > >>>> No, it's a circuit where a capacitive sensor is employed and I want to > >>>> mimic the sensor output. The capacitor itself will be inside a somewhat > >>>> resonant circuit so it has to behave like a real and clean capacitor. > >>>> > >>>> > >>> [snip] > >>> > >>> I take it you haven't tried my subcircuit? > >>> > >> > >> I have not given up yet but so far I got all kinds of error messages. > >> The next step would be to try it on an XP machine where I'd have to get > >> LTSpice going again. XP was IMHO the last known good OS and I've had > >> error message in other software caused by Windows 7 (meaning they didn't > >> happen on an XP machine). > > > > What kind of error messages? > > > > If you use the LTspice _symbol_ I made, you need to open the .ASY file > > with a text editor and change the path to wherever you've located the > > subcircuit definition library. > > > > And there is the first problem. Windows 7 no longer allows writes to the > program directories. Well, it does but secretly stashes them some place > else but then access become an issue. I'll get to the ground of that, > hav to for my CAD as well, just not right now. The usual, swamped in > work plus honey-do stuff. >
tried right-click "run as administrator" ? you can put stuff the program directory you just have to copy and say yes to a UAC prompt -Lasse
On 2015-03-18 4:46 PM, John Larkin wrote:
> On Wed, 18 Mar 2015 16:39:38 -0700, Joerg <news@analogconsultants.com> > wrote: > >> On 2015-03-18 2:55 PM, John Larkin wrote: >>> On Wed, 18 Mar 2015 14:03:07 -0700, Joerg <news@analogconsultants.com> >>> wrote: >>> >>>> On 2015-03-18 1:46 PM, John Larkin wrote: >>>>> On Wed, 18 Mar 2015 13:36:27 -0700, Joerg <news@analogconsultants.com> >>>>> wrote: >>>>> >>>>>> On 2015-03-18 11:54 AM, Syd Rumpo wrote: >>>>>>> On 17/03/2015 00:26, Joerg wrote: >>>>>>>> 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. >>>>>>>> >>>>>>> <snip> >>>>>>> >>>>>>> This is what I did for a time-varying capacitance. In the component >>>>>>> 'Value' field, I put Q=(4p/(0.25 +(time*5)))*x which swept the >>>>>>> capacitance from 16pF downwards controlled by the internal variable 'time'. >>>>>>> >>>>>>> I can't remember why you need the Q and the x, but you do, and it took a >>>>>>> good while to find out - it seems you can't just vary the capacitance >>>>>>> directly. Replace time with a voltage and the appropriate scaling and >>>>>>> you should be good to go. >>>>>>> >>>>>> >>>>>> Tried it and that completely bungled the linearity when the cap is >>>>>> inside a resonant circuit. At least no more error messages which is >>>>>> good. Well, maybe I just do it in hardware then, firing up the old >>>>>> Weller. I'd have to buy a bag of varicaps but those are cheap. >>>>> >>>>> Are you trying to sim a VCO? Simulating oscillators is always tedious. >>>>> >>>> >>>> No, it's a circuit where a capacitive sensor is employed and I want to >>>> mimic the sensor output. The capacitor itself will be inside a somewhat >>>> resonant circuit so it has to behave like a real and clean capacitor. >>> >>> Would something like this work? >>> >>> https://dl.dropboxusercontent.com/u/53724080/Circuits/Caps/Modulated_Cap_1.asc >>> >>> The cap is modulated by voltage ZZ, which in this case makes the cap >>> ramp from 1F to 20F. That in turn sweeps the LC ringing frequency >>> down. >>> >> >> Thanks, John, that actually seems to work. Beats me why mine didn't >> because the only difference was that I called "ZZ" "Y" instead. > > Well, that's what you need an expert for! >
Yup :-)
> It may matter about whitespace in the Q equation; it doesn't seem to > like any. > > Well, I may find this useful in the future. >
I think I know what it could have been. I had a voltage rail called "X" left in the schematic and it must have not liked that. -- Regards, Joerg http://www.analogconsultants.com/
On 2015-03-18 5:03 PM, Lasse Langwadt Christensen wrote:
> Den torsdag den 19. marts 2015 kl. 00.34.08 UTC+1 skrev Joerg: >> On 2015-03-18 2:50 PM, Jim Thompson wrote: >>> On Wed, 18 Mar 2015 14:44:39 -0700, Joerg <news@analogconsultants.com> >>> wrote: >>> >>>> On 2015-03-18 2:15 PM, Jim Thompson wrote: >>>>> On Wed, 18 Mar 2015 14:03:07 -0700, Joerg <news@analogconsultants.com> >>>>> wrote: >>>>> >>>>> [snip] >>>>>>> >>>>>> >>>>>> No, it's a circuit where a capacitive sensor is employed and I want to >>>>>> mimic the sensor output. The capacitor itself will be inside a somewhat >>>>>> resonant circuit so it has to behave like a real and clean capacitor. >>>>>> >>>>>> >>>>> [snip] >>>>> >>>>> I take it you haven't tried my subcircuit? >>>>> >>>> >>>> I have not given up yet but so far I got all kinds of error messages. >>>> The next step would be to try it on an XP machine where I'd have to get >>>> LTSpice going again. XP was IMHO the last known good OS and I've had >>>> error message in other software caused by Windows 7 (meaning they didn't >>>> happen on an XP machine). >>> >>> What kind of error messages? >>> >>> If you use the LTspice _symbol_ I made, you need to open the .ASY file >>> with a text editor and change the path to wherever you've located the >>> subcircuit definition library. >>> >> >> And there is the first problem. Windows 7 no longer allows writes to the >> program directories. Well, it does but secretly stashes them some place >> else but then access become an issue. I'll get to the ground of that, >> hav to for my CAD as well, just not right now. The usual, swamped in >> work plus honey-do stuff. >> > > tried right-click "run as administrator" ? > > you can put stuff the program directory you just have to copy and say yes to a UAC prompt >
I did that and then it put it into some extra directory and marked the file with a yellow padlock. I can't stand such behavior of an OS that MS calls "professional". -- Regards, Joerg http://www.analogconsultants.com/
On Wed, 18 Mar 2015 16:47:49 -0700 (PDT), George Herold
<gherold@teachspin.com> wrote:

>On Wednesday, March 18, 2015 at 1:54:56 PM UTC-4, John Larkin wrote: >> On Wed, 18 Mar 2015 17:40:06 +0000 (UTC), DecadentLinuxUserNumeroUno >> <DLU1@DecadentLinuxUser.org> wrote: >> >> >On Wed, 18 Mar 2015 10:30:44 -0700, John Larkin wrote: >> > >> >> On Wed, 18 Mar 2015 09:28:57 -0700, Jim Thompson >> >> <To-Email-Use-The-Envelope-Icon@On-My-Web-Site.com> wrote: >> >> >> >>>Voltage-Controlled Capacitor Spice Model now on my website. >> >>> >> >>>See VControlledCap.zip on the Device Models & Subcircuits Page. >> >>> >> >>>Includes Library File (.LIB), LTspice Symbol (.ASY), and a JPEG showing >> >>>how it was developed. >> >>> >> >>> ...Jim Thompson >> >> >> >> I don't have time to play with this just now, but one quick question: >> >> >> >> Given that C is a variable capacitor, set C to 1F and charge it to 1 >> >> volt. Now change C to 0.5F. What is the new voltage? >> > >> > How many 1 farad capacitors are you aware of? >> >> >> In LT Spice, you can use any C value. 1F is the generic capacitor. I >> usually normalize theoretical circuits to 1F, 1H, 1 ohm. [1] >> >> In real life, Digikey will sell you 1F caps. Or 5000F caps. But not >> variable 1F caps. >> >> > >> > Oh and would not a 1F charged cap dump into a 0.5F cap and fully charge >> >it? If that answer is yes, then the voltage would be the same... >> >slightly less even, all elements considered. >> > >> > You thought it would morph the EMF into something else? >> >> I'd like to know if Jim's model conserves charge, or conserves energy, >> or conserves voltage. Or whatever it does. >Well, energy conservation seems silly... if you are changing C, >moving plates around, someone has to provide the energy. >And I assume charge or voltage depends on how it's hooked up. > >George H. >> >> >> [1] I do find myself picking standard values, like 39nF instead of 40 >> nF, and worrying about leakage and stray capacitance and power >> dissipation, when none of these matter in Spice. >>
The simulation I posted ala Joerg's transducer demonstrates energy changes (AM modulation) and the FM modulation you'd expect from the capacitor changing value. I'm musing how to set up an old fashioned "pump" frequency multiplier ;-) ...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.
John Larkin <jlarkin@highlandtechnology.com> wrote:
> On Wed, 18 Mar 2015 18:54:11 +0000, Syd Rumpo <usenet@nononono.co.uk> > wrote: > >> On 17/03/2015 00:26, Joerg wrote: >>> 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. >>> >> <snip> >> >> This is what I did for a time-varying capacitance. In the component >> 'Value' field, I put Q=(4p/(0.25 +(time*5)))*x which swept the >> capacitance from 16pF downwards controlled by the internal variable 'time'. >> >> I can't remember why you need the Q and the x, but you do, and it took a >> good while to find out - it seems you can't just vary the capacitance >> directly. Replace time with a voltage and the appropriate scaling and >> you should be good to go. >> >> Cheers > > Q is charge and X is the cap voltage. > > Q = (expression) * X > > just means that (expression) is the capacitance. Seems silly to me. > > http://ltwiki.org/LTspiceHelp/LTspiceHelp/C_Capacitor.htm > > I tried a capacitor that changes value abruptly at 0 volts, like the > example. That works. If I try to change C abruptly at a non-zero > voltage, the sim crashes. Some conservation thingie was violated. > > >
Which is where I was heading with my question about conservation of charge. Perhaps changing the capacitance breaks something inside the sim related to continuity of charge.