LTSpice FFT simulation settings and inconsistent results. - Page 3 - diyAudio
Go Back   Home > Forums > Design & Build > Software Tools

Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 9th March 2012, 07:49 AM   #21
Mooly is offline Mooly  United Kingdom
diyAudio Moderator
 
Mooly's Avatar
 
Join Date: Sep 2007
OK, here's the circuit,
If anyone could contribute to this it would be much appreciated. I'm trying to keep this really simple and explain every step I take here.

So here we have the circuit set up for an output of 1 watt rms into 8 ohm. How would you set up a simulation to find a realsitic THD value for this ?

The settings I am using are these,

.op

.option noopiter (because the simulator can not find an operating point using the default method and the error log suggests adding this directive)

.option plotwinsize=0

.maxstep=0.488331106u I've read up on this and how to calculate the value (I think )

.four 1khz 10 4 v(vout) I understand that looks at the first 10 harmonics over the last four cycles.

.tran 8m

The input signal is 1khz for 16 cycles at a level that gives 1 watt rms output. So I run the simulation and get the following THD report showing 0.0011%.

So first question... is there any problem in the settings used so far to derive that figure ?


-----------------------------------------------------------------------------------------------------------------------------------------


Next part of the question...
The figures in the THD print out seem to be the figures that really matter. The FFT plot which I'll come to next can be made to look beter or worse depending on the settings used for the plot while keeping all the spice directives that were set above the same. To me, the text print out is the real guide here.

So second question. Is that a fair statement would you say ?

------------------------------------------------------------------------------------------------------------------------------------------

So I run the FFT plot. My version of spice gives 262144 as the default number of data points. That setting appears to alter the extent or bandwidth to which harmonics are displayed. So am I correct in assuming that a higher number isn't neccessarily better as most of what can be seen in the MHz and Ghz region will just be artifacts of simulation and have no bearing to reality ?

So that's the third question That's enough for now I think.

So here is the plot using a much reduced setting of 32768 and using the full extent of the data (0 to 8ms) and another using the more widely recommended 65536 points and a 4ms to 8ms time range. Although the result looks totally different the peaks are still at the same amplitudes.

Thanks for reading.
Attached Images
File Type: jpg Error log showing THD.JPG (134.7 KB, 224 views)
File Type: jpg FFT using 32768 points 0 to 8 ms.JPG (58.3 KB, 226 views)
File Type: jpg FFT using 65536 points and 4 to 8 ms range.JPG (70.7 KB, 222 views)
Attached Files
File Type: zip Spice files.zip (6.2 KB, 27 views)
__________________
-------------------------------------------------------
Installing and using LTspice. From beginner to advanced.
  Reply With Quote
Old 9th March 2012, 08:49 AM   #22
diyAudio Member
 
keantoken's Avatar
 
Join Date: Aug 2006
Location: Texas
Blog Entries: 2
Only use the .noopiter command if the simulation hangs while computing the operating point. It is normal for the first method to fail and SPICE to revert to Gmin stepping. In most cases the .noopiter command is not necessary and will not give a significant increase in performance.

Increased FFT samples will lower the noise floor and increase the frequency resolution. The biggest reason I found to use a large number was for a low noise floor. All this becomes trivial if you synch everything using my command set.

Your noise floor is wrong. It is flat line, this is not normal and it means potential is being wasted. First thing you need to do is to run the amp for at least 1 sine cycle before starting the simulation. This will get the drift and pulse caused by the abruptly starting sinewave input signal out of the measurement, and out of the FFT, greatly helping resolution. This is the only thing restricting your FFT, since you have no large time constants in the circuit.

It is best to give the simulator the equations, rather than numbers you calculated yourself, as the simulator has 32 bits of accuracy. This is why I use equations in my command set. Everything is nearly automatic, and trivial as long as you understand what the equations do.

First, I define the number of FFT samples I need:

.param FFT=2**16

Because the FFT sample number are selectable from powers of 2, it is easier just to change the exponent (the ** means a ^ to LTSpice). 2**16=65536. With everything synch'd you can get away with a much lower number of samples.

Next, I calculate the timestep for taking that many samples in the given simulator time frame.

.param timestep=10mS/FFT

Because I add an extra rev-up cycle to the beginning, I use this .tran command:

.tran 0 11m 1m {Timestep}

Your .four directive is messed up, it gives a 10-harmonic analysis by default so you only need this:

.four 1kHz v(vout)
Attached Images
File Type: png Mooly_SPICE_Demo.png (93.0 KB, 223 views)
Attached Files
File Type: asc M1 1Khz 1 Watt FFT Simulation_kmod.asc (6.9 KB, 39 views)
  Reply With Quote
Old 9th March 2012, 08:52 AM   #23
diyAudio Member
 
keantoken's Avatar
 
Join Date: Aug 2006
Location: Texas
Blog Entries: 2
It is important to use a large number of samples because without a very low timestep/high samplerate, stability cannot be simulated correctly because the frequencies are beyond the Nyquist frequency.

Sleeping now! There is some more stuff in my command set that I can explain to you, it is a convenience really, there is not much more to it.

The noise floor can be decreased a little if you use more FFT samples than in your simulation, but it doesn't change much.

Last edited by keantoken; 9th March 2012 at 08:58 AM.
  Reply With Quote
Old 9th March 2012, 11:41 AM   #24
Mooly is offline Mooly  United Kingdom
diyAudio Moderator
 
Mooly's Avatar
 
Join Date: Sep 2007
Many thanks for taking the time to do that.

I'm going to have a play around to try and make more sense of it all now.

It's understanding the way it all fits together that is a steep learning curve. Such as the value {timestep} being entered in the CMD box for max timestep.

So that looks at and works the value out from the .param 10ms/FFT directive rather than working it all out manually.

I can tell when I run this how much longer the sim takes to run compared to my settings before.

Plenty to be going on with... many thanks.
__________________
-------------------------------------------------------
Installing and using LTspice. From beginner to advanced.
  Reply With Quote
Old 10th March 2012, 01:39 AM   #25
diyAudio Member
 
keantoken's Avatar
 
Join Date: Aug 2006
Location: Texas
Blog Entries: 2
To make the simulation faster, you can decrease 2**16 to 2**14 or something (but this falls prey to the caveat in post 23). Some fields require the {} braces to go around any variables or equations you enter, but the .param statements don't.

Those "twin tower" spikes from 100KHz onmward in your FFT are what happens when the simulation samples and FFT samples are not sync'd.

Finally, Cordell's models are good, but for BJTs they don't model quasi-saturation, so they will behave too well at very low Vce. No one models quasi-saturation really, so this is a major weak point in simulation.

If you want I can give you some sim files useful for verifying BJT curves with the datasheets. It is important look look at the Vcesat curves to see how simulation differs.
  Reply With Quote
Old 10th March 2012, 07:56 AM   #26
Mooly is offline Mooly  United Kingdom
diyAudio Moderator
 
Mooly's Avatar
 
Join Date: Sep 2007
Thanks keantoken for all your help on this and the offer of the files.

Just getting a grasp of the basics is plenty to be going on with at the moment before I even think to start verifying models and so on.

The info you have given has been brilliant... and I want to make sure I understand it all before trying new things. Even things such as the parametric sweep function I haven't tried yet.

So a lot to learn
__________________
-------------------------------------------------------
Installing and using LTspice. From beginner to advanced.
  Reply With Quote
Old 10th March 2012, 08:07 AM   #27
diyAudio Member
 
keantoken's Avatar
 
Join Date: Aug 2006
Location: Texas
Blog Entries: 2
Glad to help. Having more experience with real circuits, you may soon teach me something about making simulations more realistic.
  Reply With Quote
Old 10th March 2012, 11:18 AM   #28
Mooly is offline Mooly  United Kingdom
diyAudio Moderator
 
Mooly's Avatar
 
Join Date: Sep 2007
Quote:
Originally Posted by keantoken View Post
Glad to help. Having more experience with real circuits, you may soon teach me something about making simulations more realistic.
Now that is where it does get interesting, in seeing how real vs simulations compare.
__________________
-------------------------------------------------------
Installing and using LTspice. From beginner to advanced.
  Reply With Quote
Old 10th March 2012, 06:24 PM   #29
diyAudio Member
 
cogsncogs's Avatar
 
Join Date: Jul 2003
Location: Wayne, West Virginia
Quote:
Originally Posted by keantoken View Post
*snip*
If you want I can give you some sim files useful for verifying BJT curves with the datasheets. It is important look look at the Vcesat curves to see how simulation differs.
Please post 'em!

Wayne
  Reply With Quote
Old 10th March 2012, 07:21 PM   #30
diyAudio Member
 
keantoken's Avatar
 
Join Date: Aug 2006
Location: Texas
Blog Entries: 2
Here they are. The biggest differences are usually found in the Vcesat/Hfe and Hfe graphs. Everything should be looked at in detail, for instance the KSC1845 model has cripplingly high Rc, which will ruin it's behavior in any current mirror; this is easily revealed by looking at the Vcesat curves.

I left the names from some of my experimental models in these files, if you run them as-is you will be told the model doesn't exist, so choose on of your own models to test out.
Attached Files
File Type: zip BJT_Modeling.zip (2.5 KB, 29 views)
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Distortion simulation with LTspice tiagor Solid State 32 22nd December 2012 09:33 PM
Help needed in running LTSPice FFT simulation on the M1 Lateral FET amp Mooly Solid State 11 24th February 2012 06:44 PM
Latest LTspice giving crazy FFT results ray_moth Tubes / Valves 5 6th May 2010 07:07 AM
About LTSpice Simulation. nicholas1113 Solid State 2 15th November 2009 07:52 AM
How to make sense of LTSpice FFT analysis? ray_moth Tubes / Valves 11 12th August 2008 07:43 PM


New To Site? Need Help?

All times are GMT. The time now is 05:24 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2