
Home  Forums  Rules  Articles  The diyAudio Store  Gallery  Blogs  Register  Donations  FAQ  Calendar  Search  Today's Posts  Mark Forums Read  Search 
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 

Thread Tools  Search this Thread 
9th March 2012, 08:49 AM  #21 
diyAudio Moderator

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.
__________________
 Installing and using LTspice. From beginner to advanced. 
9th March 2012, 09:49 AM  #22 
diyAudio Member

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 revup cycle to the beginning, I use this .tran command: .tran 0 11m 1m {Timestep} Your .four directive is messed up, it gives a 10harmonic analysis by default so you only need this: .four 1kHz v(vout) 
9th March 2012, 09:52 AM  #23 
diyAudio Member

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.
__________________
The Kmultiplier rail filter! = The Simple Kuartlotron Superbuffer! LTSpice wiki with special attention to new users' troubles Last edited by keantoken; 9th March 2012 at 09:58 AM. 
9th March 2012, 12:41 PM  #24 
diyAudio Moderator

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. 
10th March 2012, 02:39 AM  #25 
diyAudio Member

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 quasisaturation, so they will behave too well at very low Vce. No one models quasisaturation 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. 
10th March 2012, 08:56 AM  #26 
diyAudio Moderator

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. 
10th March 2012, 09:07 AM  #27 
diyAudio Member

Glad to help. Having more experience with real circuits, you may soon teach me something about making simulations more realistic.

10th March 2012, 12:18 PM  #28 
diyAudio Moderator

Now that is where it does get interesting, in seeing how real vs simulations compare.
__________________
 Installing and using LTspice. From beginner to advanced. 
10th March 2012, 07:24 PM  #29 
diyAudio Member
Join Date: Jul 2003
Location: Wayne, West Virginia


10th March 2012, 08:21 PM  #30 
diyAudio Member

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 asis you will be told the model doesn't exist, so choose on of your own models to test out. 
Thread Tools  Search this Thread 


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