• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Mixed-Signal Design
  3. spectrumMeasurement for a DC signal

Stats

  • Locked Locked
  • Replies 18
  • Subscribers 67
  • Views 12539
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

spectrumMeasurement for a DC signal

NewScreenName
NewScreenName over 2 years ago

Hi,

I have a signal which is DC and some switching activity which disturbs it, therefore I would like to get its THD. The numbers I get using the thd function from the calculator are not right, and according to my understanding this is due to the fact that it will assume the signal is the highest amplitude of the spectrum, and also ignore the DC.

This means that because my signal is the DC, it will actually consider the highest harmonic to be the signal, and the power at its multiples the harmonics.

I tried to solve by calculating with spectrumMeasurement measure types totalharmpower/dcpower, but again I think totalharmpower is still only considering the power of the harmonics of what it assumes to be the signal.

Could not find a function which calculates the power in all frequencies, is there a quick way to automate this measurement? Maybe I am missing the correct calculator function?

Thank you

Best regards

  • Cancel
Parents
  • ShawnLogan
    ShawnLogan over 2 years ago

    Dear NewScreenName,

    NewScreenName said:
    Could not find a function which calculates the power in all frequencies, is there a quick way to automate this measurement? Maybe I am missing the correct calculator function?

    I may not fully appreciate exactly what you are attempting to compute and hence my suggestion may not be appropriate. 

    If I understand, as shown in Figure 1, you have a simulation that produces a DC term of interest and ideally the only component in the spectrum. However, additional frequency components (f1, f2,...fn) are introduced by switching activity. You would like to determine the total power of all these additional frequency components.

    If my understanding is correct, there are two possible means to determine the total power exclusive of the DC term. 

    1. Assuming your simulation results are clipped so there are no significant transient settling effects and the analysis region encompasses all the significant tonal frequencies associated with your "switching activity", I think the easiest method is in the time domain:

    a. Compute the average of your output waveform, say signal "vout":

    vout_dc = average("/vout")

    b. Subtract the average value of vout from the signal vout and determine its rms value:

    v_spurious_rms = rms(("/vout" - vout_dc)

    c. The resulting signal power, exclusive of the DC term, is then given by:

    v_spurious_rms^2

    2. If this is not to your liking, the alternative is to compute the power spectral density (calculator function psd()), and integrate it over the frequency range containing all the frequency spurs. However, this method does require some care when choosing the appropriate simulation parameters (simulation interval for analysis, number of time points, and strobe time) to assure your computed power spectral density is accurate. When done properly, it will provide the same answer as method [1].

    Shawn

    Figure 1

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • NewScreenName
    NewScreenName over 2 years ago in reply to ShawnLogan

    Dear Shawn,

    Thank you for your suggestions, in lack of a specific function ready made those seem good alternatives

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to NewScreenName

    Dear NewScreenName,

    In viewing your results and realizing you are using the Spectrum Assistant, I feel as if I should add a few more comments regarding its use in your specific application.

    My understanding is the Spectrum Assistant was developed to assist in characterizing the performance of an ADC or DAC where the input/output signals are tonal in nature. Hence, many of the GUI inputs are geared towards common ADC and DAC tonal specifications. In your case, it does not appear to me that you are characterizing either of those. As a result, some of the parameters in the GUI may not be exactly what you were expecting. I've outlined my comments on each of the parameters and the values you entered. I also made the assumption you were trying to compute the total power exclusive of the DC term and computed its value from the Spectral Assistant data. I hope my comments are clear enough to make some sense to you. I still think using the temporal data and average value to compute the rms value may be the easiest method to use as an Assembler output.

    Shawn

    newscreeenname_spectrum_assistant_computation_072023.pdf

    • Cancel
    • Vote Up +2 Vote Down
    • Cancel
  • NewScreenName
    NewScreenName over 2 years ago in reply to ShawnLogan

    Dear Shawn,

    This is another possible way to calculate the result I was looking for, thank you for the further suggestion and very detailed explanation!

    I just have a question about your method: according to what I see the FFT is displaying the amplitude of the tone, not its rms amplitude, therefore when you compute the total power by just summing the squares of the tones 10^(A1/10)+10^(A2/10)+... shouldn't then the result be multiplied by a factor of 1/sqrt(2) ?

    Thank you

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to NewScreenName

    Dear NewScreenName,

    I was very happy to read you were able to understand my comments!

    NewScreenName said:
    I just have a question about your method: according to what I see the FFT is displaying the amplitude of the tone, not its rms amplitude, t

    Very good NewScreenName! You are absolutely correct - the Cadence dft() function does not compute the rms value, but rather the amplitude. I show this and explain why their function does not report the rms value starting on page 38 and through page 49 of the note at URL:

    (To avoid the spam filter, copy the following 3 and paste them together as a single URL)

    www.

    dropbox.com/

    s/lxjvo8ys6ci5m3x/test_sinusoid_rnoise_snr_study_061522v1p1.pdf?dl=0

    NewScreenName said:
    therefore when you compute the total power by just summing the squares of the tones 10^(A1/10)+10^(A2/10)+... shouldn't then the result be multiplied by a factor of 1/sqrt(2) ?

    Yes. In fact, on the second page where I compute the total power exclusive of DC , you might note I did not use the 1 V amplitude of the reference level of the Spectral Assistant (0) to compute the 5 MHz signal power. I used a value of 0.707 V - which is the rms value (see below) of its 1 V amplitude in order that the total power exclusive of DC be an rms value.

    I hope this clarifies the issue!

    Shawn

    • Cancel
    • Vote Up +2 Vote Down
    • Cancel
Reply
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to NewScreenName

    Dear NewScreenName,

    I was very happy to read you were able to understand my comments!

    NewScreenName said:
    I just have a question about your method: according to what I see the FFT is displaying the amplitude of the tone, not its rms amplitude, t

    Very good NewScreenName! You are absolutely correct - the Cadence dft() function does not compute the rms value, but rather the amplitude. I show this and explain why their function does not report the rms value starting on page 38 and through page 49 of the note at URL:

    (To avoid the spam filter, copy the following 3 and paste them together as a single URL)

    www.

    dropbox.com/

    s/lxjvo8ys6ci5m3x/test_sinusoid_rnoise_snr_study_061522v1p1.pdf?dl=0

    NewScreenName said:
    therefore when you compute the total power by just summing the squares of the tones 10^(A1/10)+10^(A2/10)+... shouldn't then the result be multiplied by a factor of 1/sqrt(2) ?

    Yes. In fact, on the second page where I compute the total power exclusive of DC , you might note I did not use the 1 V amplitude of the reference level of the Spectral Assistant (0) to compute the 5 MHz signal power. I used a value of 0.707 V - which is the rms value (see below) of its 1 V amplitude in order that the total power exclusive of DC be an rms value.

    I hope this clarifies the issue!

    Shawn

    • Cancel
    • Vote Up +2 Vote Down
    • Cancel
Children
  • NewScreenName
    NewScreenName over 2 years ago in reply to ShawnLogan

    Dear Shawn

    All clear, and thank you for sharing your thoughts!

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to NewScreenName

    Dear NewScreenName,

    NewScreenName said:
    All clear,

    Great! I am happy to read that you understand - good luck! I am confident you will be successful!

    Shawn

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to ShawnLogan

    I think my alternative implementation would also work. I just updated it because it didn't use the newer function template mechanism in the calculator; now you can use the "fx" button in the function panel or + button in the expression builder in ADE to add abThd:

    /* abThd.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Jul 26, 2001 
    Modified   Jul 24, 2023 
    By         A.D.Beckett
    
    Given a frequency spectrum - e.g the results of
    a fourier analysis, or a fft output, calculate the 
    total harmonic distortion.
    
    Updated in 2023 to add new calculator template. To add to the 
    calculator use the "fx" button in the calculator function panel 
    or the "+" button in the ADE Expression Builder.
    
    You can also just call abThd() directly if the code has been
    loaded.
    
    To use the special function, use the browser to find the results of the
    fourier analysis, and left click to put the expression in the calculator
    input.  Alternatively do a dft and put that in the calculator input. Then
    choose the Custom Functions in the Function Panel, pick abThd, specify
    the harmonic number for the fundamental, and then OK - the resulting
    expression will evaluate to the THD without the DC offset problem which
    was in 4.4.5, and will also work with fourier analysis output.
    
    ***************************************************
    
    SCCS Info: @(#) abThd.il 07/24/23.11:54:34 1.2
    
    */
    
    /***************************************************************
    *                                                              *
    *                      (abThd ft [harm])                       *
    *                                                              *
    *        Given a frequency spectrum (output of fourier         *
    *        analysis or fft), calculate the Total Harmonic        *
    * Distortion. The fundamental harmonic may be specified - this *
    *     defaults to 1. Note that this is the harmonic of the     *
    *      fourier fundamental frequency - which for a dft is      *
    *                       1/period_of_dft.                       *
    *                                                              *
    ***************************************************************/
    
    (defun abThd (ft @optional (harm 1) "gx")
      (let (xList fund (sum 0.0))
           ;-----------------------------------------------------------------
           ; Ensure the harmonic number is legal
           ;-----------------------------------------------------------------
           (setq harm (if (lessp harm 0) 1 harm))
           (setq ft (mag ft))
           ;-----------------------------------------------------------------
           ; Find the frequencies of the harmonics
           ;-----------------------------------------------------------------
           (setq xList (domList ft))
           ;-----------------------------------------------------------------
           ; Ignore everything before the specified harmonic number
           ;-----------------------------------------------------------------
           (setq xList (nthcdr harm xList))
           ;-----------------------------------------------------------------
           ; Fundamental
           ;-----------------------------------------------------------------
           (setq fund (value ft (car xList)))
           ;-----------------------------------------------------------------
           ; Sum up the rest (effectively add up the powers)
           ;-----------------------------------------------------------------
           (foreach x (cdr xList)
                    (setq sum (plus sum (pow (value ft x) 2)))
                    )
           ;-----------------------------------------------------------------
           ; Calculate the thd
           ;-----------------------------------------------------------------
           (quotient (times 100.0 (sqrt sum)) fund)
           )
      )
    
    ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ocnmRegGUIBuilder(
     '(nil
      function abThd
      name abThd
      description "THD function starting from spectrum"
      category ("Custom Functions")
      analysis (nil
          general (nil
            args (ft harm )
              signals (nil
                    ft (nil
                          prompt "Spectrum"
                          tooltip "DFT output or fourier analysis results"
                          )
               )
              params(nil
                     harm (nil
                           prompt "Harmonic"
                           tooltip "Harmonic for denominator"
                           guiRowHint 1
                           type string
                           default "1"
                           required nil
                     )
              )
            inputrange t
          )
      )
      outputs(result)
     )
    )

    Then you can pass the dft() results as the first argument (Spectrum) and then harmonic 0. This will do an RMS sum of harmonics 1 to n from the DFT output and then divide by the DC value and give the result as a percentage.

    Maybe that will help!

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • brs2020
    brs2020 over 2 years ago in reply to ShawnLogan

    ShawnLogan - I went through the document above where you explain that the dft gives the amplitude instead of the rms. The explanation was the dft multiplies the bins by sqrt(2). I think this is true for non-zero bins. For the zeroth bin, there is no multiplication by sqrt(2) if I understand it correctly. i.e. to find the DC power we would need X[0]^2, for other bins we need X[n]^2/2 for n=1,2,... Can you confirm

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to brs2020

    Dear brs2020,

    brs2020 said:
    The explanation was the dft multiplies the bins by sqrt(2). I think this is true for non-zero bins. For the zeroth bin, there is no multiplication by sqrt(2) if I understand it correctly. i.e. to find the DC power we would need X[0]^2, for other bins we need X[n]^2/2 for n=1,2,... Can you confirm

    That is correct. The DC amplitude is not subject to any multiplication. This is actually a general result when determining the single-sideband spectrum for a DFT (or FFT) from its conventional two sided spectrum. For real signals, the amplitudes of the corresponding positive and negative frequency are complex conjugates. Hence, the equivalent power for the single-sideband spectrum may be found by multiplying the positive frequency powers by 2. Since the DC term is neither positive nor negative, it is not multiplied by 2.

    I hope my explanation makes sense brs2020!

    Shawn

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • brs2020
    brs2020 over 2 years ago in reply to ShawnLogan

    Dear Shawn,

    Thanks for your reply. I think you mean single-sided spectrum when you say single-sideband spectrum. Your reply makes sense, for real signal the power of the single-sided spectrum is obtained by taking the power of the positive frequencies of the double sided spectrum and multiplying by 2. 

    The cadence dft function behaves somewhat unconventionally in my opinion. For example, if you have a signal x(t) = Ao + Ao*sin(2*pi*fo*t), i.e. a signal with a DC term. A single-sided spectrum using FFT function on Matlab (or also likely Octave) would result in 6dB difference between the DC term and the term at fo. This makes sense the DC power = Ao^2 and the power at fo=Ao^2/2. However, if we were to plot the FFT using the Cadence dft function, the DC term would be at the same level as the term at fo. This indicates that the cadence dft function, when getting the single-sided spectrum internally multiples the positive frequency bins by 4 instead of 2, but leaves the DC term as is. 

    Put differently, referring to the screenshot below from your document, I wonder if the sum of squares of the dft() function produces a value slightly different from twice the expected value, since the X(0) term is not treated the same way as other |X(n)| n=1,2,.... i.e. when you consider a signal of the form x(t) described above, the sum of the dft terms divided by 2 will likely not match the ideal value you would expect theoretically. Do you agree?

     

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to brs2020

    Dear brs2020,

    brs2020 said:
    I think you mean single-sided spectrum when you say single-sideband spectrum.

    Thank you for correcting me - yes I intended to write single-sided spectrum and typed single-sideband spectrum. Sorry for that confusing error on my part!

    brs2020 said:
    The cadence dft function behaves somewhat unconventionally in my opinion.

    I agree and reported this discrepancy to Cadence in an SR. Both the Octave and Matlab implementations of the FFT make use of the FFTW algorithm. FFTW is a well known and proven algorithm originally developed at MIT with source code in C and FORTRAN available on-line. Details of the algorithm and benchmarks are described by the original authors in a 2005 paper at www.fftw.org/fftw-paper-ieee.pdf which is also available from their site www. fftw.org.

    My only thought as to why Cadence chose to deviate from this algorithm is that it wanted the magnitude of its tonal spectral peaks to correspond to the amplitude and not the rms value of the tones. However, I have no further insight as I never received a Cadence response to the SR nor the supporting documentation I provided to them. I believe their choice is confusing when attempting to use their DFT result in an integration to compute signal power (i.e., make use of Parseval's theorem).

    brs2020 said:
    Put differently, referring to the screenshot below from your document, I wonder if the sum of squares of the dft() function produces a value slightly different from twice the expected value, since the X(0) term is not treated the same way as other |X(n)| n=1,2,.... i.e. when you consider a signal of the form x(t) described above, the sum of the dft terms divided by 2 will likely not match the ideal value you would expect theoretically. Do you agree?

    In short, I also agree, but do not have any available dft() results for a signal with a significant DC term to validate the hypothesis. As I note in a response to the original forum question:

    "Yes. In fact, on the second page where I compute the total power exclusive of DC , you might note I did not use the 1 V amplitude of the reference level of the Spectral Assistant (0) to compute the 5 MHz signal power. I used a value of 0.707 V - which is the rms value (see below) of its 1 V amplitude in order that the total power exclusive of DC be an rms value."

    A good discussion and thank you for asking the question!

    Shawn

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to brs2020

    Dear bus2020,

    I wrote a response, but it was flagged as spam as I included non-Cadence links (albeit I made an attempt to disguise them). Hopefully, it will be released in order that you may review it.

    Shawn

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • brs2020
    brs2020 over 2 years ago in reply to ShawnLogan

    Thanks Shawn, appreciate your comments.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to brs2020

    I don't have the time at the moment to dive through all the details of this conversation other than to note that the dft function is actually using FFTW under the hood (a change was made a number of years ago to move from an internally-developed FFT function to use FFTW instead - this then allowed non-power of 2 numbers of samples). Of course that doesn't mean that there isn't some difference in scaling - I can't comment on that without spending more time.

    I didn't find any case from you Shawn on this - so hard to know what the outcome was.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information