Things you should know about LTSpice

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Not sure what you mean by "over a timeline"? If you use .step for a single parameter with N values, N simulations will be performed, and N curves will be shown on the output graph. Tuning is only useful IMO when the time duration of a simulation is very short, like AC analysis. Transient can take a while, which makes tuning clumsy. I worked as a developer on a simulation tool that had tuning, so I'm familiar with its uses. I'm not aware of any freeware that has it.

TI's Tina simulator has real-time features, but Tina is very limited in the demo version, and the full version is $omewhat expen$ive...... if you get too carried away with tweaking pots and such while Tina is running a real-time sim, the software gets confused and either gives you very strange results, or just plain locks up and crashes.... LTSpice on the other hand is very difficult to crash, even intentionally.... unless you simulate something really off the wall like a perfect current source charging a perfect capacitor, though even that doesn't seem to do it. LTSpice seems perfectly happy to give you an output ramp that goes from 0 to Petavolts and beyond. it only seems limited as to how many zeros it can put between the first digit and the TV (TeraVolt) designator.

another thing i've run into using LTSpice are amplifier circuits that never resolve, or that error out with "Time Step too small". usually now when i see this with an amplifier circuit, the first thing i double check is whether or not i have an inversion step i missed. when you apply what is supposed to be negative feedback to what you think is the inverting input (but ends up being the noninverting input), the solver will never find a stable operating point. instead it tries to hit a moving target, and finally gives up (after quite a wait, and continuous DEFCON 1 messages).

actually i tried to sim something like that now that i have LTSpice 4, and it doesn't seem to want to get confused.... it just gives me an off-the-wall result (2.4e+26 TV spike), but never goes into DEFCON.......
 
You can tick the "skip initial operating point solution" box, but this won't do well for your FFTs without adding some settling time to your simulation.

It turns out I can't (yet) indefinitely edit my first post, but will have to send my revision to moderators. I will do the next update when I have the time.

- keantoken
 
I want to get a bunch of updates together and add them at once, and this includes adding some of my models.

For those watching this this thread, I want to discuss whether my models are good enough to add to the list I will eventually add to the first post. Discussion is here:

http://www.diyaudio.com/forums/showthread.php?t=151168

I presently have these models. Please post if you have your own models or know of other user-made models I should add.

Andy_C:
MJL3281A
MJL1302A
2SA1837
2SC4793

Syn08:

2SA1407
2SC3601
2SA1930
2SC5171

Christer:

2SD669
2SB649

- keantoken
 
On the topic of good FFT's

Not sure if it is something I'm failing to understand, but I usually set up the Transient analysis to start recording after some period of time to allow biasses to stabilize, capacitors to charge etc. I find that you must arrange for the signal to start at zero when you begin recording data to avoid a dirty FFT. This is easily arranged by specifying a time delay for the signal source to start and use this also to establish the start time of transient data recording.

For example, define .param Tdelay = 1/F1
where F1 is the signal frequency.
In the signal source, usually with me a simple Voltage source (sinusoidal) set it turn on at {Tdelay} and in the transient analysis set the start recording to {Tdelay}

I've seen plenty of other people do this so please correct my explanation if it's not correct !
 
I am aware of these tips, thank you for reminding me to add them to my eventual update.

I personally have found using voltage sources as caps to be a better solution; look at it in terms of the logarithmic scale. 5mS of delay might get you a noise floor some decibels lower, but in order to get the same number of decibels lower you will have to use 20mS of delay! The simulation time adds up (I'm "absolutely approximate" on my math here, but you can see the pattern). I want to know how well my circuits really work before I change the design to compensate for simulator errors. This is my personal preference, it won't affect the update.

- keantoken
 
Measuing the difference between the result of two .measure statements

Hi Folks,

I am trying to model a RIAA filter in LTSpice. But I am not getting the results I expect. The curve is pretty close. But I am trying to produce a report in the log.

I am trying to show the relative ac voltage difference between the 1Khz reference point and the measured AC voltage at he current step point frequency.

Here are the relevant .step and .measure commands and the results which I find puzzling.

The measurement for ref is correct.

The measurement for fs is correct.

But when I try to measure the difference between fs and ref (fs - ref) the answer does not make any sense to me.

And ideas you folks have to get the correct answer would be very much appreciated.

Code:
.step oct param fac 20 20K 1
.meas AC REF find V(out+,out-) when freq = 1000
.meas AC FS find V(out+,out-) when freq = fac
.meas RESULT param FS - REF

and in the log:

Direct Newton iteration for .op point succeeded.
.step fac=20
.step fac=40
.step fac=80
.step fac=160
.step fac=320
.step fac=640
.step fac=1280
.step fac=2560
.step fac=5120
.step fac=10240
.step fac=20000


Measurement: ref
  step	v(out+,out-)	at
     1	(0.0206938dB,131.159°)	1000
     2	(0.0206938dB,131.159°)	1000
     3	(0.0206938dB,131.159°)	1000
     4	(0.0206938dB,131.159°)	1000
     5	(0.0206938dB,131.159°)	1000
     6	(0.0206938dB,131.159°)	1000
     7	(0.0206938dB,131.159°)	1000
     8	(0.0206938dB,131.159°)	1000
     9	(0.0206938dB,131.159°)	1000
    10	(0.0206938dB,131.159°)	1000
    11	(0.0206938dB,131.159°)	1000

Measurement: fs
  step	v(out+,out-)	at
     1	(19.3631dB,159.807°)	20
     2	(17.8642dB,144.625°)	40
     3	(14.5555dB,128.718°)	80
     4	(9.84162dB,120.591°)	160
     5	(5.09813dB,122.76°)	320
     6	(1.58234dB,129.662°)	640
     7	(-0.795996dB,129.994°)	1280
     8	(-3.72349dB,119.763°)	2560
     9	(-8.21593dB,106.678°)	5120
    10	(-13.7368dB,96.7739°)	10240
    11	(-19.4281dB,89.5999°)	20000

Measurement: result
  step	fs - ref
     1	(18.5135dB,163.076°)
     2	(16.7128dB,146.578°)
     3	(12.753dB,128.154°)
     4	(6.55826dB,115.634°)
     5	(-1.7234dB,112.474°)
     6	(-14.0009dB,122.118°)
     7	(-20.7212dB,-37.2088°)
     8	(-8.26935dB,-29.3612°)
     9	(-3.49641dB,-34.9139°)
    10	(-1.50696dB,-40.8994°)
    11	(-0.675443dB,-44.4484°)


Date: Sun Sep 27 17:38:17 2009
Total elapsed time: 0.468 seconds.

tnom = 27
temp = 27
method = trap
totiter = 10
traniter = 0
tranpoints = 0
accept = 0
rejected = 0
matrix size = 137
fillins = 264
solver = Normal
Matrix Compiler1:    1286 opcodes
Matrix Compiler2: 16.5 KB object code size

Cheers!
Russ
 
Last edited:
...
It turns out I can't (yet) indefinitely edit my first post, but will have to send my revision to moderators. I will do the next update when I have the time.

- keantoken

the new Wiki needs input - now that IMG links work a lot more can be illustrated in an article

http://www.diyaudio.com/wiki/Main_Page

I don't know if we need content/editing/attribution/authorization rules beyong the normal Wiki model but cut/paste from best threads should be a way to quickly get significant content into the Wiki
 
the new Wiki needs input - now that IMG links work a lot more can be illustrated in an article

http://www.diyaudio.com/wiki/Main_Page

I don't know if we need content/editing/attribution/authorization rules beyong the normal Wiki model but cut/paste from best threads should be a way to quickly get significant content into the Wiki

are we allowed to cut and paste from other sources (i.e. the LTSpice yahoo gtoup)?? there's a lot of good stuff there, and i think people here could benefit from it.
 
are we allowed to cut and paste from other sources (i.e. the LTSpice yahoo gtoup)?? there's a lot of good stuff there, and i think people here could benefit from it.

I don't know what's acceptable - some (most?) forum owners assert ownership of the content

despite any such "clik thru" agreement I certainly feel anything I've contributed is nonexclusively given and I should be able to copy my posts freely - including posting them in other forums

however I see less justification for copying other peoples contributions

moving diyAudio posts from forum threads to the diyAudio Wiki wouldn't seem to have any such limitation

but then when do you literally quote and point to origin vs cut/paste into an article body of text?

quoting could also be used in ways the original author disapproves – some disgruntled users have asked for all of their posts to be removed from the forum

also some audio topics seem to generate strong controversy - how to prevent edit wars - perhaps restricting meaning changing edits to separate point-counterpoint paragraphs?
 
Last edited:
ok, so if i find interesting content in the LTSpice yaoo group, i'll just paste the URL. that will probably be a pain in the neck for anybody that isn't a member of that group, but if one is using LTSpice, it's important to be a member of that yahoo group. there have been many times, i've encountered a problem with LTSpice, or wanted a behavioral model of something "outside the box", and found the solution on the yahoo group. there are a lot of things that are not covered very well in the LTSpice user manual pdf that are explained in better detail on the yahoo group. the group also has links to manufacturer website pages of SPICE models.

on another subject, i recently found (this will be of interest for linux users) that LTC tests LTSpice for compatibility running in Wine under linux.
 
Member
Joined 2008
Paid Member
I have a question regarding importing models that are posted as text in forum posts.

I tried following the instructions posted on the user group to "create a new file and copy it into the directory" but I'm not an advanced PC Pilot and the instructions were just general enough that I was able to conform to the letter of the instruction a few different ways and still not get it right . That was almost a year ago and having some real build projects to keep me happy LT Spice did all I needed with native models. (Building was more fun anyway.) But now I'd like to give it another go. Would somebody post a descriptive step by step for the whole procedure?
 
for 3rd party models of subcircuit components (like op amps, etc...):
1) open notepad or other text editor
2) copy and paste the text of the model
3) save the text file as "c:\Program files\LTC\SWCadIII\lib\sub\whatever.sub
(or whatever directory the subcircuit files are kept)

for models such as transistor models, you copy/paste the text into c:\Program Files\LTC\SWCadIII\lib\cmp\standard.bjt. for MOSFET models, copy into standard.mos. it's best if you put it in as a single line and remove all of the + symbols. you can open the standard.xxx files as text files with notepad or wordpad, or another text editor. after adding the lines to the model files, the part number will show up in the device selection list (if you have LTSpice open when you do this, you must exit and restart the program). each line begins with ".model". i have so far pasted about 100 different transistor models into standard.bjt, some of them copied and pasted from pages of this forum
 
Member
Joined 2008
Paid Member
Thanks unclejed613! I'll give this a try tomorrow or Tuesday and see if I can pull it off. I'm assuming the whatever in whatever.sub is to be the name of the part I am importing.
I won't ask how to bring in a tube model and put it together with the appropriate symbol until after I can do the bjt and mos first, but it's on the list.
Thanks again !
 
Hi , problem with the Importing New Model into the LTSpice.

Hi,Everyone,
I am a Final Year Student having a project of power amplifier Class B, named Blameless by Dougles self. I new to the LTSpice and now i requested to use the LTSpice Software to simulate the circuit. but unfortunately there did not have the Model Transistor BC 550 ,BC 560 , MJE15030, BD 139, MJE 15031.. all these types of transistor. BY simulating, i using the model in the LTspice Lib given which is nearly to the expected Vceo and Ic that I need.
I found this
More LTSpice models

and I followed the instruction to import but still cant work it out.
Could anyone give me some advice on how to do it.

Further more, I having the problem to simulate out the DC graph, AC graph and transient graph for the Class B Blameless Amplifier.
 
Hi keantoken

Hope you don't mind if I add a few comments about pitfalls / problems from my own experience.

I'm using CircuitMaker, btw, rather than LTSpice, but I'm sure the principles are the same.

1) Regarding point 3 (ground paths) of your first post - I most often get that with series-connected capacitors. The solution is just to add a (very) large resistor across one of them or from the junction to earth. Similarly, with parallel-connected inductors - a small resistor in series with one of them cures the problem.

2) Keeping it real - Power supplies:
Easy pitfall - you model an amp running off, say a +30V dc power supply. Results may be great in the sim, but real life's not like that.

What happens to your biasing, dc offsets etc if the supply droops to 26V or rises to 33V?

And what about hum? Try adding a couple of volts of 100 or 120 hz garbage to the power supply voltage and see what you get at the output.

3) Switch-on / switch-off behavior:
Probably good to check with other circuits too, but especially the kind of amp that runs off a single supply rail.

With pencil-and-paper design, guesstimates and a bit of calculation, I can get a fair idea of what kind of performance to expect ito output power, distortion, noise etc. Trying to figure out what exactly happens when you switch the thing on (or worse - off) just makes my head hurt, though.

I find modeling that really useful. The results can be scary, but at least you know how bad a problem you have to sort out.

4) Real components:
I've been modeling more radio-frequency stuff than audio lately, and had to be really careful with this.

For example, CircuitMaker thinks all capacitors are "ideal" capacitors, but they're not. So where I'm using e.g. a 33uF electrolytic for supply decoupling, I'll add half an ohm of series resistance in the model to make it more realistic.

Similarly, those little axial inductors that almost look like resistors are self-resonant at a couple of MHz, so to model it properly you have to add a few pF of capacitance in parallel.

With audio circuitry, probably the biggest problem is that spice programs tend to think all transistors (of a given type) are identical, where in fact key parameters like Vbe and Hfe vary between individual devices and also depending on the weather.

That kind of thing probably isn't worth trying to figure out in the spice model. I tend to head back to pencil-and-paper, asking myself questions like: "If the two transistors in the input-stage LTP have HFE's of 200 and 300, how bad is the DC offset gonna be?" or "How bad is this current mirror if the Vbe of the two transistors is different by 100mV - and what size emitter resistors do I need to get it reasonable?".

Hmm ....
Most of my rambling above is more about what to model and how to model it rather than the software itself. I reckon it still counts as "Things you should know" though.

I was reading your "class A amp" and "Alison output stage" threads last night, and seem to remember you having an "Aha!" moment at some point when you were getting insanely good distortion figures like 0.000X % from the output stages ..... when driven from a "perfect" signal generator.

Then you realized the VAS isn't going to be like that, and when you modeled them driven from a source impedance of a few hundred ohms or so, the whole picture changed.

I'm guessing that made more of a difference to the story than the actual choice of transistors or quibbling about how accurate their spice models are.

Thanks for your contributions and good luck with your projects!
- Godfrey
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.