LTspice Tip

Oct 22, 2015 10 Replies

As I work my way to a Universal OpAmp Spice Model that you only have to feed the subcircuit 10-12 numbers from the datasheet, I observe that LTspice struggles with what I would consider ordinary hyperbolic functions (bounded, all derivatives exist, are finite, and continuous)... making a straight line out of a transfer curve with soft limiting on each end... and churning... churning... churning... mid-range.



Experimenting I find that setting Tools/Control Panel/Spice to "Alternate Solver" makes it all work properly.



I'd recommend using the Alternate Solver for any circuit that LTspice struggles with, or in my particular case, produces phony output results... in fact I'd recommend Alternate Solver always. ...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.

The LTspice sw statement has smooth turn-on and turn-off if you specify negative hysteresis. It's pretty slick actually.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

What does that have to do with the Alternate Solver? ...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.

The resistance changes continuously? Who knew?!!

That could be useful. I sometimes use mosfets and voltage-source gate drivers, because the switch closes infinitely fast and can do nasty things.

It would be nice to have R = f(t)

Since it's a built-in function, it's pretty well guaranteed to work in LTspice's normal solver.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

You could use Joerg's MOSFET linearization trick, i.e. use two matched voltage-controlled switches and apply feedback around one to set the resistance of both.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

Of course... built-in functions always work, but models devised on other Spice variants platforms often hang... unless you use the Alternate Solver. I can't see that there's any significant speed penalty by using the Alternate Solver, especially on a fast multi-core machine. ...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.

Just a not-instant-turnon switch would be useful. I'll play with the negative-hysteresis thing.

Back in ancient times, I used to run ECA, a non-Spice-based DOS text-netlist circuit simulator. It let you express anything (R, L, C, V, I) as an expression of anything else. That was handy.

It always converged, too. It would occasionally complain about a divide-by-zero event, but you could ignore them; it kept going.

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

Here's the soft switch:

Version 4 SHEET 1 880 712 WIRE -576 240 -768 240 WIRE -496 240 -576 240 WIRE -768 352 -768 240 WIRE -944 368 -1008 368 WIRE -816 368 -944 368 WIRE -496 384 -496 240 WIRE -816 416 -880 416 WIRE -880 480 -880 416 WIRE -1008 512 -1008 368 WIRE -768 512 -768 432 WIRE -1008 640 -1008 592 WIRE -768 640 -768 592 WIRE -496 640 -496 464 FLAG -768 640 0 FLAG -880 480 0 FLAG -1008 640 0 FLAG -496 640 0 FLAG -944 368 R FLAG -576 240 W SYMBOL voltage -768 496 R0 WINDOW 0 58 37 Left 2 WINDOW 3 65 74 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V1 SYMATTR Value 5 SYMBOL sw -768 448 M180 WINDOW 0 56 26 Left 2 WINDOW 3 51 65 Left 2 SYMATTR InstName S1 SYMATTR Value SWX SYMBOL voltage -1008 496 R0 WINDOW 0 -86 58 Left 2 WINDOW 3 -282 115 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V4 SYMATTR Value PULSE(0 1 1u 1u 1u 1u) SYMBOL res -512 368 R0 WINDOW 0 66 40 Left 2 WINDOW 3 74 76 Left 2 SYMATTR InstName R1 SYMATTR Value 1 TEXT -312 456 Left 2 !.tran 0 5u 0 1n TEXT -320 408 Left 2 ;JL Oct 22, 2015 TEXT -1248 288 Left 2 !.model SWX SW(VT=0.5 Ron=1u Vh=-1) TEXT -296 368 Left 2 ;Soft Switch

Saves contact arcing, too. ;)

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

I was simulating a laser driver, including a cable with its resistance and inductance. It was convenient to use a switch and a txline in the sim, to simplify the things I was caring about, but the LT Spice switch made the txline ring approximately forever, which messed other things up. It needed a soft switch, so I used a mosfet. The negative hysteresis thing is cute.

How does one select between a level1 and a level2 switch?

Join the Discussion

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

Didn't find your answer?

Ask the community — no account required