P-spice THD - diyAudio
Go Back   Home > Forums > Amplifiers > Solid State
Home Forums Rules Articles diyAudio Store Gallery Wiki Blogs Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

Solid State Talk all about solid state amplification.

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
Old 2nd October 2002, 01:36 PM   #1
diyAudio Member
JensRasmussen's Avatar
Join Date: Jul 2002
Location: Denmark - Jutland
Send a message via ICQ to JensRasmussen Send a message via MSN to JensRasmussen
Default P-spice THD

Hi all

I would like to make simulations of the THD vs freq in spice.

The problem is that I don't know how to do it, can anyone help ?

Thanks for any reply

  Reply With Quote
Old 2nd October 2002, 01:51 PM   #2
diyAudio Member
jan.didden's Avatar
Join Date: May 2002
Location: The great city of Turnhout, BE
Blog Entries: 8
Default P-spice THD

Hi Jens,

I am not familiar with P-spice, but most simulators let you step the generator frequency, collect data at each point and then make a consolidated graph. Did you try that?

Bear in mind though that THD in spice is handled as a small-signal property. That is, the simulation is done with all active devices linearized around their operating point. The resulting THD will almost certainly have no relation to the real thing.

Jan Didden
  Reply With Quote
Old 2nd October 2002, 02:36 PM   #3
diyAudio Member
Join Date: May 2002
Location: Switzerland
Hi Jens

I have already done quite a lot of simulations on switching amplifier principles using P-SPICE.

In order to be able to calculate THD you have to run transient simulation (you therefore have to enable transient analysis in the analysis setup), preferably over more than one period.

Then you have to select (=> plot/X-axis settings/restricted analog) exactly one (or an integer times) period(s) of the output signal and run FFT by using the FFT button.

You can then scale as you like and by the use of the toggle cursor you can read the values of each spectral line of interest and calculate THD.

Some hints:

I always start the stimulus signal (i.e. input signal) at about -30 degrees and do the calculations for a little longer than the amount of periods in question simply because of the phase shift and startup conditions introduced by the circuit itself (so you have some margins at the beginning and at the end).

Curve forms look a little coarse sometimes (i.e. rather like polygones than like sinusoids) due to the fact that P-SPICE uses an adaptive algorithm to determine the temporal step size. You can force it to do a finer temporal resolution by adding something to the circuit that generates a fast signal (for instance a shorted AC CURRENT source at 2 MHz or whatever) and that doesn't affect the circuit itself. But be aware that the simulation file-size will rise accordingly.

You have to be aware that every simulation is only an approximation whose accuracy is depending on the accuracy of the models used. THD simulations with P-SPICE will never show the real life situation but can be used as guidelines (otherwise I would immediately start to build the class-d amp that showed 0.01 % THD with P-SPICE or even the fully symmetrical double-feedbak loop linear amplifier with 0.001% THD and an f3 of 700 kHz

I hope this helps.


  Reply With Quote
Old 2nd October 2002, 03:11 PM   #4
tiroth is offline tiroth  United States
diyAudio Member
Join Date: Dec 2001
Location: Pittsburgh, PA, USA
I'm not even going to address the accuracy of any measurements. But, to get good THD simulations with Pspice, you need to know how to use the tool.

I would use the FFT to determine the distortion, as this will show you if there are erroneous humps etc. I then do the distortion calculation by hand.

This means you must have enough samples to get a fine FFT resolution; the amount of time you need to capture will thus be dependent on the frequency of your test signal. (and how low you want to measure) It should be quite clear if the FFT floor is covering things up.

You should delay the start of capture long enough to allow your circuit to stabilize if you want good results.

You'll need to choose the target step and maximum step sizes carefully to get good results with the FFT. (there is no need to force the engine to use a smaller step size through some hack) If they are too large the granularity of the waveform is too low to find low-level distortion. (or rather, your result will look more distorted than it really is, which won't give you much useful information) Look for things like weird spikes that aren't a multiple of the test signal--these are almost certainly due to an error in your simulation, not a problem with your circuit.
  Reply With Quote
Old 2nd October 2002, 03:19 PM   #5
diyAudio Member
Join Date: Jan 2002
Location: Livermore, CA
Default Issues for linear distortion analysis

Linear distortion can be analyzed usefully if some basic procedures are followed.

As Charles explained, you'll have to setup for transient mode simulation. I've found it necessary to simulate for quite a few cycles, and to take a Hanning window of the simulation results to analyze with FFT. I usually use 10 or 20 kHz as the test sine wave, since audio circuits are most sensitive to HF THD in most cases.

But there's a bit more to it than that- as setup by default, SPICE and PSPICE don't have the dynamic range for really useful distortion analysis. You'll need to modify some of the numerical controls in the OPTIONS statment, particularly RELTOL, ABSTOL, VNTOL, and sometimes CHGTOL. If you're only working with a preamp level circuit, you have leave everything except VNTOL alone in most cases, but I change it to in the neighborhood of 2E-5. Also, use the Transient statement to force simulation steps at at least 2X the print statement time, 4X if you have the memory and time. All these changes are aimed at eliminating numerical artifacts which could be confused with simulated distortion products.

If you're working with power circuits, you'll have convergence issues unless you change VNTOL, ABSTOL, and CHGTOL; they'll need to be raised an order of magnitude or two above the default values, to aid convergence and reduce simulation time.

If using a simulator other than PSPICE, (such as Intusoft IS-SPICE, or SILVACO SmartSPICE, or Penzar Development TopSPICE) you should have the option to specify GEAR integration; it is slightly overdamped numerically, but compared with the default TRAPEZODAL integration algorithm which is strongly underdamped, it's preferable and converges better, particuarly if there are any strong non-linearities in the circuit. (hopefully not!).

And don't forget your component models.... use the best you can get.


  Reply With Quote
Old 2nd October 2002, 03:46 PM   #6
diyAudio Member
JensRasmussen's Avatar
Join Date: Jul 2002
Location: Denmark - Jutland
Send a message via ICQ to JensRasmussen Send a message via MSN to JensRasmussen
Default Speaking of models


Thanks all

So there is no way of making a graf with freq on rhe x axis and THD on the y axix ??

What models for resistors and caps du you all use ??

Transistors I get models from philips and ON homepages, are there any better ?

Thanks again

Still working on the graf

  Reply With Quote
Old 3rd October 2002, 05:39 AM   #7
mirlo is offline mirlo  United States
diyAudio Member
Join Date: Jul 2002
Location: San Diego
Default Maybe try APLAC?

APLAC is a circuit simulator that has harmonic balance and periodic steady state simulations.


Warning: I've never tried it, so I can't vouch for it being easy to set up, but they do have a free student version.

http://rf.rfglobalnet.com/software_m...are/15/678.htm or jump through the registration hoops on www.aplac.com's webpage.

[I don't know how crippled the student version is though.] I imagine APLAC is a fairly good simulator though -- it looks like it is maybe the simulator of choice for Nokia's RF ASIC designers.

Both of those simulation techniques should provide accurate THD [ and IMD ] estimates, but you may still have to do some kind of post-processing after the harmonics are calculated to sum them all up.

-- mirlo
  Reply With Quote
Old 3rd October 2002, 11:01 AM   #8
diyAudio Member
JensRasmussen's Avatar
Join Date: Jul 2002
Location: Denmark - Jutland
Send a message via ICQ to JensRasmussen Send a message via MSN to JensRasmussen
Default Progress

Hi all

Well I got P-spice to make a THD calc., but only at one freq.

How do I get it to make a graf ?

Thanks again

  Reply With Quote
Old 16th October 2002, 06:56 AM   #9
Account Disabled
Join Date: May 2002
go for multisim proffesional or power professional...
  Reply With Quote
Old 16th October 2002, 09:16 AM   #10
diyAudio Member
Join Date: Feb 2002
Location: europ,germany
hi Jens,
you have to switch on the transient Button and then in the Probe Data the trace switch to Fourier and then the x- axis to the wanted Frequency.
Hope this helps
  Reply With Quote


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
Help with LT Spice Bonsai Solid State 9 5th September 2008 12:32 AM
New to SPICE WithTarragon Pass Labs 2 6th June 2008 06:32 PM
Free Spice Or Cheap Spice Simulator-Where To Start? kelticwizard Everything Else 29 15th February 2007 01:38 AM
looking for spice models bocka Software Tools 16 23rd November 2003 02:00 PM
1- 800- Go- Spice EternaLightWith Software Tools 9 21st May 2003 03:51 AM

New To Site? Need Help?

All times are GMT. The time now is 11:48 PM.

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

Content Relevant URLs by vBSEO 3.3.2