## Find Aliased ADC or DAC Harmonics (with animation)

January 11, 2021

When a sinewave is applied to a data converter (ADC or DAC), device nonlinearities produce harmonics.  If a harmonic frequency is greater than the Nyquist frequency, the harmonic appears as an alias.  In this case, it is not at once obvious if a given spur is a harmonic, and if so, its order.  In this article, we’ll present Matlab code to simulate the data converter nonlinearities and find the harmonic alias frequencies.  Note that Analog Devices has an online tool for...

## Compute Images/Aliases of CIC Interpolators/Decimators

Cascade-Integrator-Comb (CIC) filters are efficient fixed-point interpolators or decimators.  For these filters, all coefficients are equal to 1, and there are no multipliers.  They are typically used when a large change in sample rate is needed.  This article provides two very simple Matlab functions that can be used to compute the spectral images of CIC interpolators and the aliases of CIC decimators.

1.  CIC Interpolators

Figure 1 shows three interpolate-by-M...

## Design Square-Root Nyquist Filters

July 13, 2020

In his book on multirate signal processing, harris presents a nifty technique for designing square-root Nyquist FIR filters with good stopband attenuation [1].  In this post, I describe the method and provide a Matlab function for designing the filters.  You can find a Matlab function by harris for designing the filters at [2].

Background

Single-carrier modulation, such as QAM, uses filters to limit the bandwidth of the signal.  Figure 1 shows a simplified QAM system block...

## Third-Order Distortion of a Digitally-Modulated Signal

June 9, 2020
Analog designers are always harping about amplifier third-order distortion.  Why?  In this article, we’ll look at why third-order distortion is important, and simulate a QAM signal with third-order distortion.

In the following analysis, we assume that signal phase at the amplifier output is not a function of amplitude.  With this assumption, the output y of a non-ideal amplifier can be written as a power series of the input signal x:

$$y=... ## Second Order Discrete-Time System Demonstration April 1, 20202 comments Discrete-time systems are remarkable: the time response can be computed from mere difference equations, and the coefficients ai, bi of these equations are also the coefficients of H(z). Here, I try to illustrate this remarkableness by converting a continuous-time second-order system to an approximately equivalent discrete-time system. With a discrete-time model, we can then easily compute the time response to any input. But note that the goal here is as much to... ## A Simplified Matlab Function for Power Spectral Density March 3, 20204 comments In an earlier post [1], I showed how to compute power spectral density (PSD) of a discrete-time signal using the Matlab function pwelch [2]. Pwelch is a useful function because it gives the correct output, and it has the option to average multiple Discrete Fourier Transforms (DFTs). However, a typical function call has five arguments, and it can be hard to remember how to set them all and how they default. In this post, I create a simplified PSD function by putting a... ## Fractional Delay FIR Filters February 9, 202014 comments Consider the following Finite Impulse Response (FIR) coefficients: b = [b0 b1 b2 b1 b0] These coefficients form a 5-tap symmetrical FIR filter having constant group delay [1,2] over 0 to fs/2 of: D = (ntaps – 1)/2 = 2 samples For a symmetrical filter with an odd number of taps, the group delay is always an integer number of samples, while for one with an even number of taps, the group delay is always an integer + 0.5 samples. Can we design a filter... ## Model Signal Impairments at Complex Baseband December 11, 20195 comments In this article, we develop complex-baseband models for several signal impairments: interfering carrier, multipath, phase noise, and Gaussian noise. To provide concrete examples, we’ll apply the impairments to a QAM system. The impairment models are Matlab functions that each use at most seven lines of code. Although our example system is QAM, the models can be used for any complex-baseband signal. I used a very simple complex-baseband model of a QAM system in my last ## Compute Modulation Error Ratio (MER) for QAM November 5, 20192 comments This post defines the Modulation Error Ratio (MER) for QAM signals, and shows how to compute it. As we’ll see, in the absence of impairments other than noise, the MER tracks the signal’s Carrier-to-Noise Ratio (over a limited range). A Matlab script at the end of the PDF version of this post computes MER for a simplified QAM-64 system. Figure 1 is a simplified block diagram of a QAM system. The transmitter includes a source of QAM symbols, a root-Nyquist... ## Plotting Discrete-Time Signals September 15, 20195 comments A discrete-time sinusoid can have frequency up to just shy of half the sample frequency. But if you try to plot the sinusoid, the result is not always recognizable. For example, if you plot a 9 Hz sinusoid sampled at 100 Hz, you get the result shown in the top of Figure 1, which looks like a sine. But if you plot a 35 Hz sinusoid sampled at 100 Hz, you get the bottom graph, which does not look like a sine when you connect the dots. We typically want the plot of a... ## The Power Spectrum October 8, 2016 Often, when calculating the spectrum of a sampled signal, we are interested in relative powers, and we don’t care about the absolute accuracy of the y axis. However, when the sampled signal represents an analog signal, we sometimes need an accurate picture of the analog signal’s power in the frequency domain. This post shows how to calculate an accurate power spectrum. Parseval’s theorem [1,2] is a property of the Discrete Fourier Transform (DFT) that... ## Second Order Discrete-Time System Demonstration April 1, 20202 comments Discrete-time systems are remarkable: the time response can be computed from mere difference equations, and the coefficients ai, bi of these equations are also the coefficients of H(z). Here, I try to illustrate this remarkableness by converting a continuous-time second-order system to an approximately equivalent discrete-time system. With a discrete-time model, we can then easily compute the time response to any input. But note that the goal here is as much to... ## Design IIR Highpass Filters February 3, 20182 comments This post is the fourth in a series of tutorials on IIR Butterworth filter design. So far we covered lowpass [1], bandpass [2], and band-reject [3] filters; now we’ll design highpass filters. The general approach, as before, has six steps: Find the poles of a lowpass analog prototype filter with Ωc = 1 rad/s. Given the -3 dB frequency of the digital highpass filter, find the corresponding frequency of the analog highpass filter (pre-warping). Transform the... ## Peak to Average Power Ratio and CCDF May 17, 20164 comments Peak to Average Power Ratio (PAPR) is often used to characterize digitally modulated signals. One example application is setting the level of the signal in a digital modulator. Knowing PAPR allows setting the average power to a level that is just low enough to minimize clipping. However, for a random signal, PAPR is a statistical quantity. We have to ask, what is the probability of a given peak power? Then we can decide where to set the average... ## IIR Bandpass Filters Using Cascaded Biquads April 20, 201911 comments In an earlier post [1], we implemented lowpass IIR filters using a cascade of second-order IIR filters, or biquads. This post provides a Matlab function to do the same for Butterworth bandpass IIR filters. Compared to conventional implementations, bandpass filters based on biquads are less sensitive to coefficient quantization [2]. This becomes important when designing narrowband filters. A biquad section block diagram using the Direct Form II structure [3,4] is... ## Digital PLL's -- Part 2 June 15, 20165 comments In Part 1, we found the time response of a 2nd order PLL with a proportional + integral (lead-lag) loop filter. Now let’s look at this PLL in the Z-domain [1, 2]. We will find that the response is characterized by a loop natural frequency ωn and damping coefficient ζ. Having a Z-domain model of the DPLL will allow us to do three things: Compute the values of loop filter proportional gain KL and integrator gain KI that give the desired loop natural... ## A Simplified Matlab Function for Power Spectral Density March 3, 20204 comments In an earlier post [1], I showed how to compute power spectral density (PSD) of a discrete-time signal using the Matlab function pwelch [2]. Pwelch is a useful function because it gives the correct output, and it has the option to average multiple Discrete Fourier Transforms (DFTs). However, a typical function call has five arguments, and it can be hard to remember how to set them all and how they default. In this post, I create a simplified PSD function by putting a... ## Fractional Delay FIR Filters February 9, 202014 comments Consider the following Finite Impulse Response (FIR) coefficients: b = [b0 b1 b2 b1 b0] These coefficients form a 5-tap symmetrical FIR filter having constant group delay [1,2] over 0 to fs/2 of: D = (ntaps – 1)/2 = 2 samples For a symmetrical filter with an odd number of taps, the group delay is always an integer number of samples, while for one with an even number of taps, the group delay is always an integer + 0.5 samples. Can we design a filter... ## Design a DAC sinx/x Corrector July 22, 20189 comments This post provides a Matlab function that designs linear-phase FIR sinx/x correctors. It includes a table of fixed-point sinx/x corrector coefficients for different DAC frequency ranges. A sinx/x corrector is a digital (or analog) filter used to compensate for the sinx/x roll-off inherent in the digital to analog conversion process. In DSP math, we treat the digital signal applied to the DAC is a sequence of impulses. These are converted by the DAC into contiguous pulses... ## Demonstrating the Periodic Spectrum of a Sampled Signal Using the DFT March 9, 201920 comments One of the basic DSP principles states that a sampled time signal has a periodic spectrum with period equal to the sample rate. The derivation of can be found in textbooks [1,2]. You can also demonstrate this principle numerically using the Discrete Fourier Transform (DFT). The DFT of the sampled signal x(n) is defined as:$$X(k)=\sum_{n=0}^{N-1}x(n)e^{-j2\pi kn/N} \qquad (1)

Where

X(k) = discrete frequency spectrum of time sequence x(n)