• 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 12525
  • 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
  • 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
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to ShawnLogan

    It would really help to see the DFT of the signal you're trying to compute the THD for, and what arguments you are giving to the thd function - to clarify what you're expecting to get. I have an alternative THD function that I wrote many years ago and I'm trying to understand whether that might be more suitable (it allows you to specify which harmonic is the fundamental and uses the result of a DFT as its input).

    Andrew

    • 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
  • NewScreenName
    NewScreenName over 2 years ago in reply to Andrew Beckett
    Andrew Beckett said:

    It would really help to see the DFT of the signal you're trying to compute the THD for, and what arguments you are giving to the thd function - to clarify what you're expecting to get. I have an alternative THD function that I wrote many years ago and I'm trying to understand whether that might be more suitable (it allows you to specify which harmonic is the fundamental and uses the result of a DFT as its input).

    Andrew

    Here you have the DFT and the parameters given, THD computed here is given by considering the 5MHz tone as signal. So what I tried to do was to compute totalharmpower/dcpower, which would be correct only if totalharmpower included all spectrum components a part from dc (which is what I hoped, but I verified isn't).

    All the other parameters remain the same, 14 hamonics is chosen to tell the calculator to consider all the spectrum as distorsion components.

    Let me know if more information is required.

    Thank you.

    • 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
  • 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
>

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