Spectral Analysis - Cadence Crash Course #9
Welcome back to the ninth video in this series on working with Cadence! Last time, we explored how to use the calculator and combine it with parametric sweeps. In this video, we’re diving into a technique that allows us to assess the linearity of our circuits. But first, let’s have a brief recap of how harmonic distortion works.
When designing an amplifier, our goal is to produce an output signal that matches the input signal multiplied by a specific constant factor. We can express this relationship with a small equation:
Output Signal (y) | Gain (a1) | Input Signal (x) |
---|---|---|
y | a1 | x |
In this equation, a1 is the gain of the amplifier. In practice, the output signal may contain a DC offset, which we can model by adding a constant term a0 to the equation. Fortunately, it's usually easy to filter that out with a capacitor, leaving us with the modified equation:
y = a0 + a1 * x
However, since we use nonlinear components like transistors, achieving a perfectly linear relationship isn't possible. The actual transfer function will be nonlinear. We can approximate this nonlinearity using a Taylor expansion, which adds polynomial terms to our equation. By including a second and third-order term with their own factors (a2 and a3), we can better represent this non-linear function.
Now, if we assume x is a cosine wave at a single frequency f₀, let’s examine the output relation:
- a0: Has no impact, as there is no relation between y and x.
- First-order term (a1 * x): Yields a cosine wave at frequency f₀ with amplitude a1.
- Second-order term: Generates frequency components at double the frequency and DC.
- Third-order term: Produces components at f₀ and three times f₀.
In summary, non-linearity in our amplifier circuit creates new frequency components at multiples of the input frequency, a phenomenon known as harmonic distortion. The nth-order polynomial term contributes a component at n times the input frequency.
The best method to investigate the degree of distortion in our output signal is by injecting a pure sine wave at the input, conducting a transient simulation to obtain the output signal, and then performing a Fourier transform to interpret the frequency representation of the output signal, focusing on the distortion peaks.
Fast Fourier Transform (FFT) Setup
To set up a simulation providing useful frequency domain information, it’s crucial to choose the number of signal samples for computing the FFT carefully. We should select a number of samples that is a power of 2 (e.g., 512, 1024, 2048). This approach optimally utilizes the speed of the Fast Fourier Transform.
More samples yield finer resolution in the frequency domain, but it also means our transient simulation will take longer to run. For our case, let's select 1024 samples (210). Next, we determine the input frequency, setting it at 75 kilohertz.
The sampling frequency must be significantly higher than the input frequency to ensure we sample both the signal and its dominant higher-order harmonics at least twice per period, thanks to the sampling theorem. For example, to capture the third-order harmonic of 75 kilohertz (which is 225 kilohertz), we need a sampling frequency exceeding 450 kilohertz. To be safe, let's opt for a sampling rate of 1 megahertz.
However, if we perform an FFT on a 75 kilohertz signal with 1024 samples at a rate of 1 megahertz, we will achieve a spectrum that looks smeared. This occurrence, known as spectral leakage, arises from selecting an input frequency that does not fit an integer number of periods within our record length.
To resolve this, we can adhere to the constraint that the ratio between the input frequency (fi) and the sampling frequency (fs) is equal to m over 2n, where both m and n are integers. By carefully choosing m, we ensure the input signal fits an integer number of times within the record.
Avoiding Spectral Leakage
If we find ourselves in a situation where we cannot prevent truncation errors at the record edges, an alternative is to multiply the signal by a window function that drives the signal to zero at the beginning and end of the record. Though this mitigates spectral leakage, it modifies the signal spectrum in the frequency domain.
We must also ensure m is relatively prime with the value 2n to avoid overlapping distortion components in our spectrum. For example, if we design for an input frequency of 75 kilohertz, we find m=79 and compute an input frequency of approximately 77.1484375 kilohertz, avoiding spectral leakage and overlapping peaks.
Setting up Cadence for Frequency Domain Analysis
Let’s apply our frequency and sampling setups in Cadence:
- Change the parameters of the input voltage source:
- Set the DC voltage to 600 million volts.
- Set the amplitude to 50 millivolts.
- Set the frequency to our calculated value of approximately 77.1484375 kilohertz.
- Run a check and save to ensure the netlist is updated.
- Enable transient simulation and set the stop time to exceed the record length (e.g., 2000 microseconds).
- Set the stroke period equal to the sampling frequency (1 megahertz) in the simulation output options.
Next, plot both input and output waveforms, then run the simulation. We obtain a plot displaying both waveforms. Selecting the input waveform, navigate to Measurements > Spectrum and set the stop time starting from 100 microseconds onward.
This practice ensures the system has settled before analyzing. Setting the window type to rectangular, we are ready to plot the spectrum. The output indicates a clean signal with minimal spectral components, as expected from a pure sine wave.
We can repeat the spectrum analysis for our output signal, observing significant harmonic distortion. Various numerical quantities can be calculated from the spectrum to quantify the distortion levels, such as:
- Signal to Noise and Distortion Ratio
- Signal to Noise Ratio
- Spurious Free Dynamic Range
- Total Harmonic Distortion
Finally, we can streamline our workflow by right-clicking on the spectrum and selecting Send to ADE, allowing us to automate future plots without re-entering settings.
With that, you should now have a solid foundation for obtaining frequency spectra in your simulations, helping to understand distortion effects in your circuits. In our next video, we’ll discuss how to visualize simulation results from Cadence in a more sophisticated tool like MATLAB. See you then!
More Articles
Earthquakes 101 | National Geographic
National Geographic
CANSLIM Investing Strategy: This "M" Factor is CRITICAL to Avoid Big Losses (M in CANSLIM)
TraderLion
CANSLIM Investing Strategy: This "I" Factor Predicts HUGE Stock Gains (I in CANSLIM)
TraderLion
CANSLIM Investing Strategy: How to Spot Next BIG STOCKS using this Strategy (L in CANSLIM)
TraderLion
CANSLIM Investing Strategy: Use Supply & Demand to Find the Next 1000% Gainer (S in CANSLIM)
TraderLion
CANSLIM Investing Strategy: All 1000% Gain Stocks Have This in Common (N in CANSLIM)
TraderLion