Spice simulation

Try this. You are not following my directions in the first place. It looks like you are trying to follow someone else's directions. I too tried to do this ridiculous stuff and constantly had trivial, aggravating problems; I found an easier and simpler way and never needed anything more. It is convenient to have the subcircuit in your schematic directory anyways, so you can zip it up and send it to someone else like this.

When using models like this make sure the pinout of the model matches the pinout of the transistor.
 

Attachments

  • MOSFETModelTest.zip
    2.2 KB · Views: 82
The line ".subckt ecf10n20.txt" doesn't make sense. Think about it.

Makes sense to me, but not to LTSpice. Deleting the line worked.
I am using the primer done by Laurier in Canada. It was making me think I needed to build a dedicated three terminal icon for the model instead of the supplied "M". There was another electronics forum with explicit steps that included the .subckt line in the parameters box.

The problem is all the instructions are written by folks who know how to do it. What you were saying was obvious to you, but not quite to me.

I was looking at the libraries that came with SIMetrix. They have a lot more old parts. Now I get the idea, I will try to link them. Old parts as I am reverse engineering old amps.

Much thanks. I hope my next question is harder.
 
Sage advice. Models seem highly variable. Even for relatively simple things like a diode.

Today's question. Playing with the FFT function. I would have guessed the generator to be a mathematically perfect sine wave. This does not seem to be correct as measuring the output of a "perfect" source into a resistive load shows harmonics only about 80dB down. Any tips on size and windows when working in the 1 to 100K Hzrange?
 
a unobvious Ltsipce specific problem is that data compression for output files is the default setting

you have to add ".option plotwinsize=0" to every high resolution sim

then t_max_stepsize needs to be set in .TRAN to as small a value as needed by your analysis - be quided by test signal frequency, loop gain intercept, device ft

10 ns isn't too small - millions of points in the output raw file are "reasonable" with today's PCs

for very complex circuits, long sims you can restrict the number of nodes, currents saved
 
AX tech editor
Joined 2002
Paid Member
Today's question. Playing with the FFT function. I would have guessed the generator to be a mathematically perfect sine wave. This does not seem to be correct as measuring the output of a "perfect" source into a resistive load shows harmonics only about 80dB down. Any tips on size and windows when working in the 1 to 100K Hzrange?

I see the same with a completely other product, the Labcenter VSM simulator. Source has pronounced 2nd and 3rd on FFT, yet the output of the circuit is much less and seems OK.
I haven't been able to find out why that is.

jan
 
not a problem in Ltspice with good settings

10 ns max step size, plotwinsize=0, default fft settings gives -180 dB numerical noise floor with 10 KHz sine, 2ms sim

selecting Blackman window function in the fft helps with settling time "tilt" of the fft noise floor, just saving the final few ms after a settling time can be done with .TRAN settings or in the fft dialog window
 
Last edited:
It's the 120 I was simulating. LTSpice was showing harmonic distortion only 80dB down right at the output of the voltage source. Model is a perfect source; no internal impedance. So, less than perfect generation is what I was seeing. I bet they have their reasons.
LTspice's generator is pretty good, but one needs to take care of some parameters.


attachment.php


Consider the cap replaced with a short, for the moment. Then this sim will have distortion levels at 1e-15 (-300dB), using the .four command, not the FFT in the graph display. This comes from the small time step (10,000 points per period, de-rationalized with the Pi/3.14-thingie which helps when you want to analyse multiple periods) and the double precision option, and most of all from the directive plotwinsize=0, which tells the program to turn OFF waveform compression (which is lossy).

Then put the cap back in. Distortion will skyrocket inspite of the perfect oscillator... because the circuit has not settled from the wideband input (down to DC) that a suddenly started sine intrinsicly shows. It gets even worse when you add a dead-time to the generator. One can use generators circuits that fade in with a raised cosine envelope which reduces settling time quite a bit.
 
Here is a .asc file with every performance tweak I've found so far (well, not quite all of them, but all of the functional ones). I use this param set for every amplifier I simulate. This will let you tweak simulation speed without causing problems with sample aliasing and compression.
 

Attachments

  • ampsim2.asc.zip
    1.5 KB · Views: 210
WRT the FFT window.

If you open up the preview for the window you choose, you'll see there are many different types. The sine-like ones are the most natural and intuitive. It is important that the tail ends of the window end at 0, or your noise floor will be artificially heightened. The window should average to a straight line if it is placed in a series of windows. I believe I'm correct here but I may be wrong.

Playing around with the FFT windows in Baudline (only available for Linux unfortunately) gives you a good idea of what the FFT window does to the spectrogram.

A narrower FFT window seems to decrease the Hz resolution of the FFT, so perhaps a good audio window would be Kaiser, adjusted so the spikes are exactly 1 octave wide, so they don't overlap. But I haven't studied this in detail so I'm not sure what the side-effects would be. I know MikeB seemed to prefer the Kaiser window.

EDIT: I'm pretty sure the .four parameter, which automatically calculates THD, uses the rectangular window, which is why it will read a ridiculous THD on a simulation where the FFT shows very low THD (provided you used a good window). It would be nice if there were a way to change the FFT window. Maybe someone has come up with a DIY alternate feature that uses the windowed FFT values.
 
Last edited:
SUPER. Much thanks. I also found some notes and a plug in over on Audio-Perfection.com Lots to study. All this as a side track when trying to understand why my Rotels sound better than my other amps. Amp design became fascinating. I have a renewed appreciation for analog design. Everything is a catch-22 at the levels mere consumer grade equipment works at. .000-something. Not long ago measuring in that range was college physics lab domain. Add the craft and the problem of what measures well does not automatically sound good.

I remember a lecture by TI on digital measurement maybe 30 years ago, but needless to say, the details escape me. In SoundEasy, he recommends a rectangular window. My other free-ware analyzers all recommend Blackman. Sometimes the results look suspiciously too good. I am used to just being able to set the sample rate and size, where that is a bit confusing in LTSpice.

I had not thought of pre-defining several signal sources. Much easier than retyping it all every time. Rookie.
 
I just posted some stuff about FFT windowing that probably pertains more to this thread. New users are often confused about FFT windowing, so I think it's important to make it clear. Most people will probably be very happy with the Hann window, but like jcx says, for a lower noise floor Blackman can be used with a larger number of samples.

http://www.diyaudio.com/forums/soft...ettings-inconsistent-results.html#post2938114
 
Very confused on baseline noise. If I just have a voltage source, 1K resistor back to ground. Run 1K, 1000 cycles through it. Look at the FFT. I have a noise floor at about -80dB and quite a bit of distortion. This implies the sine generator is pretty poor. So poor, I can't really tell much about my simulation as it is better than the generator. Am I doing something very wrong?
 

Attachments

  • baseline.png
    baseline.png
    91.3 KB · Views: 89