IIR Bandpass Filters Using Cascaded Biquads
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...
Demonstrating the Periodic Spectrum of a Sampled Signal Using the DFT
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)
Compute the Frequency Response of a Multistage Decimator
Figure 1a shows the block diagram of a decimation-by-8 filter, consisting of a low-pass finite impulse response (FIR) filter followed by downsampling by 8 [1]. A more efficient version is shown in Figure 1b, which uses three cascaded decimate-by-two filters. This implementation has the advantages that only FIR 1 is sampled at the highest sample rate, and the total number of filter taps is lower.
The frequency response of the single-stage decimator before downsampling is just...
Use Matlab Function pwelch to Find Power Spectral Density – or Do It Yourself
In my last post, we saw that finding the spectrum of a signal requires several steps beyond computing the discrete Fourier transform (DFT)[1]. These include windowing the signal, taking the magnitude-squared of the DFT, and computing the vector of frequencies. The Matlab function pwelch [2] performs all these steps, and it also has the option to use DFT averaging to compute the so-called Welch power spectral density estimate [3,4].
In this article, I’ll present some...
Evaluate Window Functions for the Discrete Fourier Transform
The Discrete Fourier Transform (DFT) operates on a finite length time sequence to compute its spectrum. For a continuous signal like a sinewave, you need to capture a segment of the signal in order to perform the DFT. Usually, you also need to apply a window function to the captured signal before taking the DFT [1 - 3]. There are many different window functions and each produces a different approximation of the spectrum. In this post, we’ll present Matlab code that...
Design a DAC sinx/x Corrector
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...
Digital PLL’s, Part 3 – Phase Lock an NCO to an External Clock
Sometimes you may need to phase-lock a numerically controlled oscillator (NCO) to an external clock that is not related to the system clocks of your ASIC or FPGA. This situation is shown in Figure 1. Assuming your system has an analog-to-digital converter (ADC) available, you can sync to the external clock using the scheme shown in Figure 2. This time-domain PLL model is similar to the one presented in Part 1 of this series on digital PLL’s [1]. In that PLL, we...
ADC Clock Jitter Model, Part 2 – Random Jitter
In Part 1, I presented a Matlab function to model an ADC with jitter on the sample clock, and applied it to examples with deterministic jitter. Now we’ll investigate an ADC with random clock jitter, by using a filtered or unfiltered Gaussian sequence as the jitter source. What we are calling jitter can also be called time jitter, phase jitter, or phase noise. It’s all the same phenomenon. Typically, we call it jitter when we have a time-domain representation,...
ADC Clock Jitter Model, Part 1 – Deterministic Jitter
Analog to digital converters (ADC’s) have several imperfections that affect communications signals, including thermal noise, differential nonlinearity, and sample clock jitter [1, 2]. As shown in Figure 1, the ADC has a sample/hold function that is clocked by a sample clock. Jitter on the sample clock causes the sampling instants to vary from the ideal sample time. This transfers the jitter from the sample clock to the input signal.
In this article, I present a Matlab...
Phase or Frequency Shifter Using a Hilbert Transformer
In this article, we’ll describe how to use a Hilbert transformer to make a phase shifter or frequency shifter. In either case, the input is a real signal and the output is a real signal. We’ll use some simple Matlab code to simulate these systems. After that, we’ll go into a little more detail on Hilbert transformer theory and design.
Phase ShifterA conceptual diagram of a phase shifter is shown in Figure 1, where the bold lines indicate complex...
Compute Modulation Error Ratio (MER) for QAM
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...
Modeling Anti-Alias Filters
Digitizing a signal using an Analog to Digital Converter (ADC) usually requires an anti-alias filter, as shown in Figure 1a. In this post, we’ll develop models of lowpass Butterworth and Chebyshev anti-alias filters, and compute the time domain and frequency domain output of the ADC for an example input signal. We’ll also model aliasing of Gaussian noise. I hope the examples make the textbook explanations of aliasing seem a little more real. Of course, modeling of...
Simple Discrete-Time Modeling of Lossy LC Filters
There are many software applications that allow modeling LC filters in the frequency domain. But sometimes it is useful to have a time domain model, such as when you need to analyze a mixed analog and DSP system. For example, the system in Figure 1 includes an LC filter as well as a DSP portion. The LC filter could be an anti-alias filter, a channel filter, or some other LC network. For a design using undersampling, the filter would be bandpass [1]. By modeling...
Demonstrating the Periodic Spectrum of a Sampled Signal Using the DFT
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)
ADC Clock Jitter Model, Part 2 – Random Jitter
In Part 1, I presented a Matlab function to model an ADC with jitter on the sample clock, and applied it to examples with deterministic jitter. Now we’ll investigate an ADC with random clock jitter, by using a filtered or unfiltered Gaussian sequence as the jitter source. What we are calling jitter can also be called time jitter, phase jitter, or phase noise. It’s all the same phenomenon. Typically, we call it jitter when we have a time-domain representation,...
Multiplierless Half-band Filters and Hilbert Transformers
This article provides coefficients of multiplierless Finite Impulse Response 7-tap, 11-tap, and 15-tap half-band filters and Hilbert Transformers. Since Hilbert transformer coefficients are simply related to half-band coefficients, multiplierless Hilbert transformers are easily derived from multiplierless half-bands.
Filter a Rectangular Pulse with no Ringing
To filter a rectangular pulse without any ringing, there is only one requirement on the filter coefficients: they must all be positive. However, if we want the leading and trailing edge of the pulse to be symmetrical, then the coefficients must be symmetrical. What we are describing is basically a window function.
Consider a rectangular pulse 32 samples long with fs = 1 kHz. Here is the Matlab code to generate the pulse:
N= 64; fs= 1000; % Hz sample...Third-Order Distortion of a Digitally-Modulated Signal
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=...
Learn About Transmission Lines Using a Discrete-Time Model
We don’t often think about signal transmission lines, but we use them every day. Familiar examples are coaxial cable, Ethernet cable, and Universal Serial Bus (USB). Like it or not, high-speed clock and signal traces on printed-circuit boards are also transmission lines.
While modeling transmission lines is in general a complex undertaking, it is surprisingly simple to model a lossless, uniform line with resistive terminations by using a discrete-time approach. A...
Design IIR Band-Reject Filters
In this post, I show how to design IIR Butterworth band-reject filters, and provide two Matlab functions for band-reject filter synthesis. Earlier posts covered IIR Butterworth lowpass [1] and bandpass [2] filters. Here, the function br_synth1.m designs band-reject filters based on null frequency and upper -3 dB frequency, while br_synth2.m designs them based on lower and upper -3 dB frequencies. I’ll discuss the differences between the two approaches later in this...
The Discrete Fourier Transform as a Frequency Response
The discrete frequency response H(k) of a Finite Impulse Response (FIR) filter is the Discrete Fourier Transform (DFT) of its impulse response h(n) [1]. So, if we can find H(k) by whatever method, it should be identical to the DFT of h(n). In this article, we’ll find H(k) by using complex exponentials, and we’ll see that it is indeed identical to the DFT of h(n).
Consider the four-tap FIR filter in Figure 1, where each block labeled Ts represents a delay of one...
Model Signal Impairments at Complex Baseband
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
Modeling Anti-Alias Filters
Digitizing a signal using an Analog to Digital Converter (ADC) usually requires an anti-alias filter, as shown in Figure 1a. In this post, we’ll develop models of lowpass Butterworth and Chebyshev anti-alias filters, and compute the time domain and frequency domain output of the ADC for an example input signal. We’ll also model aliasing of Gaussian noise. I hope the examples make the textbook explanations of aliasing seem a little more real. Of course, modeling of...
Add the Hilbert Transformer to Your DSP Toolkit, Part 1
In some previous articles, I made use of the Hilbert transformer, but did not explain its theory in any detail. In this article, I’ll dig a little deeper into how the Hilbert Transformer works. Understanding the Hilbert Transformer involves a modest amount of mathematics, but the payoff in useful applications is worth it.
As we’ll learn, a Hilbert Transformer is just a particular type of Finite Impulse Response (FIR) filter. In Part 1 of this article, I’ll...
Third-Order Distortion of a Digitally-Modulated Signal
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=...
Design Square-Root Nyquist Filters
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].
BackgroundSingle-carrier modulation, such as QAM, uses filters to limit the bandwidth of the signal. Figure 1 shows a simplified QAM system block...
Setting Carrier to Noise Ratio in Simulations
When simulating digital receivers, we often want to check performance with added Gaussian noise. In this article, I’ll derive the simple equations for the rms noise level needed to produce a desired carrier to noise ratio (CNR or C/N). I also provide a short Matlab function to generate a noise vector of the desired level for a given signal vector.
Definition of C/NThe Carrier to noise ratio is defined as the ratio of average signal power to noise power for a modulated...
Coefficients of Cascaded Discrete-Time Systems
In this article, we’ll show how to compute the coefficients that result when you cascade discrete-time systems. With the coefficients in hand, it’s then easy to compute the time or frequency response. The computation presented here can also be used to find coefficients of mixed discrete-time and continuous-time systems, by using a discrete time model of the continuous-time portion [1].
This article is available in PDF format for...
A Direct Digital Synthesizer with Arbitrary Modulus
Suppose you have a system with a 10 MHz sample clock, and you want to generate a sampled sinewave at any frequency below 5 MHz on 500 kHz spacing; i.e., 0.5, 1.0, 1.5, … MHz. In other words, f = k*fs/20, where k is an integer and fs is sample frequency. This article shows how to do this using a simple Direct Digital Synthesizer (DDS) with a look-up table that is at most 20 entries long. We’ll also demonstrate a Quadrature-output DDS. A note on...
Find Aliased ADC or DAC Harmonics (with animation)
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...