P-spice THD

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
AX tech editor
Joined 2002
Paid Member
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
 
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.

Regards

Charles
 
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.
 
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.

Regards,

Jon
 
Speaking of models

Hi

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 :scratch:

\Jens
 
Member
Joined 2002
Paid Member
Maybe try APLAC?

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

http://www.aplac.com/

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_modeling/software/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
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.