help-gnucap
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gnucap] Models and distortion


From: Al Davis
Subject: Re: [Help-gnucap] Models and distortion
Date: Thu, 2 Dec 2004 14:40:02 -0500
User-agent: KMail/1.7.1

On Tuesday 30 November 2004 06:59 pm, Mark Aitchison wrote:
> I am going to need to analyse circuits for distortion (where
> the distortion will be very low), and I appreciate that
> simulations are never going to be as accurate as building the
> circuit, but how good should gnucap be with predicting
> distortion in bipolar and jfet circuits? (When compared with
> other cirecuit emulators, and with real life?).  I presume it
> is going to depend a lot on the quality of the transistor
> models - how good are the ones gnucap can use, in general?

Gnucap is probably a little better than Spice for distortion, 
for several reasons.

Probably you would get the best results from a harmonic balance 
simulator, which gnucap isn't, and Spice isn't either.  I am 
not aware of any free mature comprehensive harmonic balance 
simulators.  I am aware of some that implement the HB 
algorithm, but are not complete enough to be useful in this 
case.  Its on the to-do list, but not likely for a while unless 
some help and funding becomes available,

Unfortunately, it doesn't have the equivalent of the Spice 
".disto" command.  I have not found it to be particularly 
useful in my work.  The .disto command uses a series 
approximation to estimate distortion.  It makes the assumption 
that the operating point is approximated by a polynomial curve, 
and the distortion can be obtained by the higher order terms of 
the polynomial.  As I recall, it gives a reasonable 
approximation of low order distortion on small signals, but is 
useless for high order distortion or large signals.  Again. 
gnucap doesn't do this.  It is not a high priority, mainly 
because the distortion issues I have dealt with are mostly with 
large signals.

That leaves transient analysis based methods, meaning the 
".fourier" command.  This command does a transient analysis, 
then extracts frequency information by Fourier transform.  The 
gnucap approach is superior to Spice in two significant ways.  
First, it is more flexible.  It lets you specify the number 
"start, stop, step" in a more sensible way, then automatically 
figures out the transient parameters necessary to compute that.  

Spice is limited to 9 harmonics, which makes it only really 
useful for simple harmonic distortion of a sine wave.  Some 
commercial Spices have post-processors that can do more.  If 
you want gnucap to do that, just specify the fundamental 
frequency,

When measuring distortion, you usually need to set the 
tolerances (reltol, abstol, vntol) tighter than you would 
otherwise, because any errors here will show as increased 
distortion.  This applies to all simulators.  As an example, if 
you set reltol to .01, which is sufficient for many other 
applications, you intoduce about 1% distortion, nominally.

There is a significant difference between gnucap and Spice in 
how it determines time stepping.  The method used in gnucap 
often results in more time steps than Spice, but lower residual 
distortion.  Gnucap forces a real calculation at every Fourier 
point.  Spice does not, and determines them by interpolation.  
To see the impact of this, do a fourier analysis of a sine 
wave.  Gnucap usually shows a residual of about -300 dB.  I 
have seen Spice simulations that showed only -25 dB when there 
was no distortion in the circuit.

Another feature that might help is the "skip" parameter.  With 
this, you can request over-sampling.  For example, the command 
".fourier 10 100k 10 skip 4" will give you a Fourier analysis 
with 10 Hz resolution, up to 100 kHz, with 4x oversampling.  
That means it will sample at 800 kHz.  The low frequency and 
resolution of 10 means that it must run for .1 second.  As you 
can imagine, this means 80000 samples, which will take a while 
to run.

Actually, since it always does a radix 2 FFT, it will do more 
samples than that.  You will really get 131,072 samples, still 
running .1 seconds, at a sample rate of 1310720 Hz.

I think this is the best you can do with a time-stepping type 
algorithm.  I have found that oversampling is rarely necessary, 
but sometimes helps.


The other issue is the models.  Gnucap models are the same as 
Spice models.  If this is important, you might want to find 
some better models, and validate them from a distortion 
viewpoint.  It has been my strategy to not put a lot of effort 
into models, but rather into modeling tools.  Better modeling 
tools will eventually result in better models.

If you compare two simulators using the same models you should 
get the same results.  If you don't, probably the one 
indicating lower distortion is better, and the one showing 
higher distortion has problems not related to the model.

Try it.  See what you get.  Then tighten tolerances.  If results 
don't change you might have your result, you may have hit 
limits of the model.  If results do change, you are still 
seeing artifacts of the algorithms.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]