DSPRelated.com

Simple but Effective Spectrum Averaging

Neil RobertsonNeil Robertson January 2, 20264 comments

In this article, I provide a Matlab function that performs exponential PSD averaging, using first-order infinite impulse response (IIR) filtering to continuously average the PSD bins. This approach works well for computing the spectrum of a long-duration signal over time, because the spectrum is constantly updated as new PSD’s are computed. Conveniently, the time constant of the PSD averaging is determined by the single adjustable parameter α. I also provide a Matlab function for conventional (unweighted) PSD averaging. Neither function requires any canned code other than the Fast Fourier Transform (FFT), although I do use the Matlab hann window function for convenience.


The First-Order IIR Filter -- More than Meets the Eye

Neil RobertsonNeil Robertson November 16, 20257 comments

While we might be inclined to disdain the simple first-order infinite impulse response (IIR) filter, it is not so simple that we can’t learn something from it. Studying it can teach DSP math skills, and it is a very useful filter in its own right. In this article, we’ll examine the time response of the filter, compare the first-order IIR filter to the FIR moving average filter, use it to smooth a noisy signal, compute the functional form of the impulse response, and find the frequency response.


A Matlab Function for FIR Half-Band Filter Design

Neil RobertsonNeil Robertson July 6, 20259 comments

FIR Half-band filters are not difficult to design. In an earlier post [1], I showed how to design them using the window method. Here, I provide a short Matlab function halfband_synth that uses the Parks-McClellan algorithm (Matlab function firpm [2]) to synthesize half-band filters. Compared to the window method, this method uses fewer taps to achieve a given performance.


The Discrete Fourier Transform of Symmetric Sequences

Neil RobertsonNeil Robertson December 8, 2024

Symmetric sequences arise often in digital signal processing. Examples include symmetric pulses, window functions, and the coefficients of most finite-impulse response (FIR) filters, not to mention the cosine function. Examining symmetric sequences can give us some insights into the Discrete Fourier Transform (DFT). An even-symmetric sequence is centered at n = 0 and xeven(n) = xeven(-n). The DFT of xeven(n) is real. Most often, signals we encounter start at n = 0, so they are not strictly speaking even-symmetric. We’ll look at the relationship between the DFT’s of such sequences and those of true even-symmetric sequences.


Learn to Use the Discrete Fourier Transform

Neil RobertsonNeil Robertson September 28, 2024

Discrete-time sequences arise in many ways: a sequence could be a signal captured by an analog-to-digital converter; a series of measurements; a signal generated by a digital modulator; or simply the coefficients of a digital filter. We may wish to know the frequency spectrum of any of these sequences. The most-used tool to accomplish this is the Discrete Fourier Transform (DFT), which computes the discrete frequency spectrum of a discrete-time sequence. The DFT is easily calculated using software, but applying it successfully can be challenging. This article provides Matlab examples of some techniques you can use to obtain useful DFT’s.


Model a Sigma-Delta DAC Plus RC Filter

Neil RobertsonNeil Robertson March 16, 20246 comments

Sigma-delta digital-to-analog converters (SD DAC’s) are often used for discrete-time signals with sample rate much higher than their bandwidth. For the simplest case, the DAC output is a single bit, so the only interface hardware required is a standard digital output buffer. Because of the high sample rate relative to signal bandwidth, a very simple DAC reconstruction filter suffices, often just a one-pole RC lowpass. In this article, I present a simple Matlab function that models the combination of a basic SD DAC and one-pole RC filter. This model allows easy evaluation of the overall performance for a given input signal and choice of sample rate, R, and C.


DAC Zero-Order Hold Models

Neil RobertsonNeil Robertson January 21, 20242 comments

This article provides two simple time-domain models of a DAC’s zero-order hold. These models will allow us to find time and frequency domain approximations of DAC outputs, and simulate analog filtering of those outputs. Developing the models is also a good way to learn about the DAC ZOH function.


Decimators Using Cascaded Multiplierless Half-band Filters

Neil RobertsonNeil Robertson November 19, 2023

In my last post, I provided coefficients for several multiplierless half-band FIR filters. In the comment section, Rick Lyons mentioned that such filters would be useful in a multi-stage decimator. For such an application, any subsequent multipliers save on resources, since they operate at a fraction of the maximum sample frequency. We’ll examine the frequency response and aliasing of a multiplierless decimate-by-8 cascade in this article, and we’ll also discuss an interpolator cascade using the same half-band filters.


Multiplierless Half-band Filters and Hilbert Transformers

Neil RobertsonNeil Robertson October 7, 20238 comments

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.


Interpolator Design: Get the Stopbands Right

Neil RobertsonNeil Robertson July 6, 20236 comments

In this article, I present a simple approach for designing interpolators that takes the guesswork out of determining the stopbands.


Design IIR Butterworth Filters Using 12 Lines of Code

Neil RobertsonNeil Robertson December 10, 201711 comments

Build a working lowpass IIR Butterworth filter from first principles in just 12 lines of Matlab using Neil Robertson's butter_synth.m. The post walks through the analog prototype poles, frequency pre-warping, bilinear transform pole mapping, adding N zeros at z = -1, and gain normalization so the result matches Matlab's built-in butter function. It's a compact, hands-on guide with clear formulas and code.


Use Matlab Function pwelch to Find Power Spectral Density -- or Do It Yourself

Neil RobertsonNeil Robertson January 13, 201938 comments

Neil Robertson walks through using Matlab's pwelch and shows how to implement PSD estimation yourself with fft. The post uses concrete examples and complete m-files to demonstrate window selection, converting pxx (W/Hz) to W/bin, Welch DFT averaging, and a worked C/N0 calculation. Readers get practical, runnable recipes for accurate spectrum units, variance reduction with averaging, and peak-power extraction.


Design IIR Filters Using Cascaded Biquads

Neil RobertsonNeil Robertson February 11, 201828 comments

High-order IIR filters are numerically sensitive, especially at low cutoff frequencies. This article shows how to implement a Butterworth lowpass as a cascade of second-order biquads, deriving the per-section coefficient formulas and giving a Matlab biquad_synth example. It explains computing denominator coefficients from pole pairs, using b = [1 2 1] with K = sum(a)/4 for unity DC gain, and highlights reduced quantization sensitivity.


Digital PLL's -- Part 1

Neil RobertsonNeil Robertson June 7, 201626 comments

A hands-on introduction to time-domain digital phase-locked loops, Neil Robertson builds a simple DPLL model in MATLAB and walks through the NCO, phase detector, and PI loop filter implementations. The post uses phase-in-cycles arithmetic to show how the phase accumulator, detector wrapping, and loop filter interact, and it contrasts linear steady-state behavior with the nonlinear acquisition seen when initial frequency error is large. Part 2 will cover frequency-domain tuning of the loop gains.


Design IIR Bandpass Filters

Neil RobertsonNeil Robertson January 6, 201811 comments

Designing Butterworth IIR bandpass filters is easier than it looks when you start from a lowpass prototype. This post walks through the s-domain lowpass-to-bandpass transform, bilinear digital mapping, and the bp_synth.m Matlab implementation that produces scaled numerator and denominator coefficients. Practical pole-zero intuition and Matlab examples help you verify magnitude and group-delay behavior for real sampling rates and bandwidths.


Simplest Calculation of Half-band Filter Coefficients

Neil RobertsonNeil Robertson November 20, 20179 comments

Half-band FIR filters put the cutoff at one-quarter of the sampling rate, and nearly half their coefficients are exactly zero, which makes them highly efficient for decimation-by-2 and interpolation-by-2. This post shows the straightforward window-method derivation of half-band coefficients from the ideal sinc impulse response, providing a clear, hands-on explanation for engineers learning filter design. It also points to equiripple options such as Matlab's firhalfband and a later Parks-McClellan implementation.


Interpolation Basics

Neil RobertsonNeil Robertson August 20, 201917 comments

Neil Robertson demonstrates interpolation by an integer factor using a frequency-domain approach, showing how zero-insertion followed by an FIR low-pass filter reconstructs a higher-rate signal. The article walks through spectra, passband and stopband selection, and a 41-tap Parks-McClellan filter example applied to a Chebyshev-window test signal. Matlab code and percent-error plots are included so engineers can reproduce and evaluate the method.


Plotting Discrete-Time Signals

Neil RobertsonNeil Robertson September 15, 20195 comments

Neil Robertson demonstrates a practical interpolate-by-8 FIR approach to make sampled signals look like their continuous-time counterparts when plotted. The post explains a 121-tap filter designed for signals up to 0.4*fs, shows Matlab examples for a sinusoid and a filtered pulse, and highlights the transient and design trade-offs so you can reproduce clean plots with the supplied interp_by_8.m code.


Second Order Discrete-Time System Demonstration

Neil RobertsonNeil Robertson April 1, 20202 comments

Want a hands-on way to see how continuous second-order dynamics appear in discrete time? Neil Robertson converts a canonical H(s) to H(z), shows z-plane pole mapping for different damping ratios, and walks through impulse-invariance scaling and zero placement. The post includes a MATLAB function so_demo.m that computes numerator and denominator coefficients, plots poles, and compares impulse and frequency responses so you can experiment with sampling effects.


Phase or Frequency Shifter Using a Hilbert Transformer

Neil RobertsonNeil Robertson March 25, 201821 comments

A Hilbert transformer converts a real input into an analytic I+jQ pair, enabling phase shifts and frequency shifts while keeping real inputs and outputs. This article shows Matlab implementations (31-tap FIR with Hamming or Blackman windows), derives y = I cosθ - Q sinθ for phase and frequency shifting, and highlights practical limits from finite taps and coefficient/NCO quantization.