The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 22nd, 2024, 1:15pm
Pages: 1 2 
Send Topic Print
thd function in Calculator (Read 14793 times)
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
thd function in Calculator
Apr 29th, 2007, 12:29am
 
Hi, Guys,

The thd function is described in WaveScan User Guide. However, it doesn't define how many harmonics are used to calculate thd function. For example, .FOUR in SPICE sums the 2nd harmonic to the 9th harmonic to calculate thd, .FFT in HSPICE sums the 2nd harmonic to the 10th harmonic to calculate thd.

Any comments are appreciated.


Yawei
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: thd function in Calculator
Reply #1 - Apr 30th, 2007, 5:28am
 
Yawei,

With the thd function, you specify the number of samples to take. This is converted to a power of two (I forget whether it is lower or higher, but it's the same as the dft function). Then it ends up with a waveform internally with a number of harmonics equal to half the power-of-two samples used.

That's how many harmonics are used for the THD calculation (i.e. half the number of samples, provided it is a power of two).

You also specify the frequency of the fundamental, so it doesn't necessarily have to be the first harmonic.

Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: thd function in Calculator
Reply #2 - May 7th, 2007, 10:43pm
 
Andrew,

It is not easy to use if thd function sums all harmonics up to half the number of samples. I am simulating a DAC with a sine wave input. I measure the output current/voltage. Many points are needed to do FFT and calculate THD. Maybe 8192 points are used for 512 sampling cycles. So we see harmonics at multiple sampling frequencies. Then thd function evaluation gives rediculous large value. I think that it is better to sum the first 9 or 10 harmonics.

Thank you.

Yawei
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: thd function in Calculator
Reply #3 - May 8th, 2007, 7:08am
 
I don't see why it should be incorrect to include all the harmonics. Why do you need more samples - remember the number of samples affects the number of harmonics - i.e. the maximum frequency. The frequency resolution is the interval you do the FFT over, so if you don't need those higher frequencies, don't do that number of samples...

Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: thd function in Calculator
Reply #4 - May 9th, 2007, 12:00am
 
Andrew,

When I simulating a DAC for 512 sampling cycles, sure I want to know the dynamic performance like SFDR, THD. I think 512 points is not enough for FFT, because glitch may be lost. I hope there are 16 points or 32 points per sampling cycle are used for FFT. Then totally 8192 points or 16384 points are used for FFT, and the FFT result expands to 8 times or 16 times sampling frequency. Actually I don't care those outside the nyquist band. The harmonics at multiple frequencies are caused by sampling, not the distortion of DAC. right? But they are summed when I use thd function.

By the way, the average function is defined as Returns the average value of a signal. Can I calculate the average value of a signal from time 1 to time 2? The time 1 and time 2 may not be the start time and stop time of a simulation.


Thanks
Yawei
Back to top
 
 
View Profile   IP Logged
sheldon
Community Fellow
*****
Offline



Posts: 751

Re: thd function in Calculator
Reply #5 - May 9th, 2007, 4:52am
 
Yawei,

  The problem is that you are using the wrong tool to evaluate the
frequency response. If you are simulating a DAC and you want to
evaluate the effect of glitch on the response then you should use
the Fourier integral, .four, not the FFT to evaluate the frequency
response. The Fourier integral evalutes the entire waveform while
the FFT only samples the waveform. So the FFT is great for ADCs,
continuous analog --> discrete analog --> digital since the output
waveforms are sampled. However for DACs, the output waveforms
are not suited for the FFT, digital -->continuous analog. The bottom
line is that FFT is inefficient if you are sampling in small enough time
intervals to capture the glitch.  The downside of the Fourier integral
is that it does not support window functions so if you want to use
for Sigma-Delta DACs, you need to write your own window function
Verilog-A module.

BTW, there was alittle bit if discussion of this in a previous thread,

http://www.designers-guide.org/Forum/YaBB.pl?num=1113231964

                                                            Best Regards,

                                                               Sheldon
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: thd function in Calculator
Reply #6 - May 9th, 2007, 9:54pm
 
You can use the clip function to pick a range of the waveform, and then average that, to answer your "average" question...

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: thd function in Calculator
Reply #7 - May 9th, 2007, 11:17pm
 
Andrew Beckett wrote on May 9th, 2007, 9:54pm:
You can use the clip function to pick a range of the waveform, and then average that, to answer your "average" question...

Andrew.


Andrew,

Thank you very much.
Back to top
 
 
View Profile   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: thd function in Calculator
Reply #8 - May 10th, 2007, 12:37am
 
Sheldon,

Quote:
BTW, there was alittle bit if discussion of this in a previous thread,

http://www.designers-guide.org/Forum/YaBB.pl?num=1113231964


I read the previous thread. It seems that a .Fourier analysis cannot be chosen in the ADE. Right? I instantiated the fourier component from analogLib. Is it the same as .Fourier analysis of other SPICE-like tools?

Ken said that he set iteratio large insteading set maxstep. How to set iteratio? What is the default value? I cannot find it using spectre -h.


Thanks
Yawei
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: thd function in Calculator
Reply #9 - May 10th, 2007, 1:38am
 
The fourier analysis is not quite the same as other simulators (see the chapter in the Designer's Guide to SPICE and SPECTRE which talks about it - first few pages can be seen at http://www.designers-guide.org/Books/dg-spice/ch5.pdf).

lteratio is a transient parameter - you need to run a transient analysis as well. So it's on the transient options form (and can be found in spectre -h tran). The default value is dependent on errpreset. It allows you to loosen the truncation error criteria, and this is particularly useful if you want to tighten tolerances and so gain accuracy without necessarily causing more timesteps to be taken. There's a good discussion of this in the above book.

Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
sheldon
Community Fellow
*****
Offline



Posts: 751

Re: thd function in Calculator
Reply #10 - May 10th, 2007, 7:05am
 
Yawei,

  In analogLib is the cell fourier which will instantiate a fourier
analysis component in the schematic and will run a Spectre
fourier analysis after a transient simulation. I would edit the
CDF and add an additional parameter, normharm. Normharm
defines which harmonic to use when normalizing the output
spectrum. The default is to use the first harmonic.

  Just use the normal simulation setup you would typically
use for this simulation. For more information about the
analysis, please see Spectre -h fourier.

                                                      Best Regards,

                                                         Sheldon
Back to top
 
 
View Profile   IP Logged
RobertZ
Community Member
***
Offline

the art of analog

Posts: 55
San Diego, CA
Re: thd function in Calculator
Reply #11 - May 11th, 2007, 1:25am
 
Hi, Yawei,

Does your cycle here mean input singal cycle or DAC clock cycle?

And secondly, I think harmonics at multiple (clock) frequencies are caused by not only sampling (when you do DFT analysis), but also the image of DAC. DAC's output spectrum (without any FFT sampling) itself has inifinity bandwith and infinity of nyquist band replica, but with sinc shaped.

driveforce


ywguo wrote on May 9th, 2007, 12:00am:
Andrew,

When I simulating a DAC for 512 sampling cycles, sure I want to know the dynamic performance like SFDR, THD. I think 512 points is not enough for FFT, because glitch may be lost. I hope there are 16 points or 32 points per sampling cycle are used for FFT. Then totally 8192 points or 16384 points are used for FFT, and the FFT result expands to 8 times or 16 times sampling frequency. Actually I don't care those outside the nyquist band. The harmonics at multiple frequencies are caused by sampling, not the distortion of DAC. right? But they are summed when I use thd function.

By the way, the average function is defined as Returns the average value of a signal. Can I calculate the average value of a signal from time 1 to time 2? The time 1 and time 2 may not be the start time and stop time of a simulation.


Thanks
Yawei

Back to top
 
 

Thanks,
Robert
View Profile   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: thd function in Calculator
Reply #12 - May 12th, 2007, 12:50am
 
Hi, driveforce,

I mean DAC clock cycle.

Sure I agree with you on the harmonics. They are the image of the DAC.


Yawei
Back to top
 
 
View Profile   IP Logged
sheldon
Community Fellow
*****
Offline



Posts: 751

Re: thd function in Calculator
Reply #13 - May 12th, 2007, 8:50am
 
Yawei,

  Built a simple example of the testbench that you seem
to be using to test your DAC. If the output spectrum is
showing tones similar to the tones in attached plot, then
modifying the sampling will eliminate the tones.

                                              Best Regards,

                                                 Sheldon
Back to top
 
 
View Profile   IP Logged
sheldon
Community Fellow
*****
Offline



Posts: 751

Re: thd function in Calculator
Reply #14 - May 12th, 2007, 8:52am
 
Sorry had a problem with the attachment
Back to top
 
View Profile   IP Logged
Pages: 1 2 
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.