This article shows how to implement a Butterworth IIR lowpass filter as a cascade of second-order IIR filters, or biquads.  We’ll derive how to calculate the coefficients of the biquads and do some examples using a Matlab function biquad_synth provided in the Appendix.  Although we’ll be designing Butterworth filters, the approach applies to any all-pole lowpass filter (Chebyshev, Bessel, etc).  As we’ll see, the cascaded-biquad design is less sensitive to coefficient...

## Design IIR Highpass Filters

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

## 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...

## Design IIR Bandpass Filters

In this post, I present a method to design Butterworth IIR bandpass filters.  My previous post [1] covered lowpass IIR filter design, and provided a Matlab function to design them.  Here, we’ll do the same thing for IIR bandpass filters, with a Matlab function bp_synth.m.  Here is an example function call for a bandpass filter based on a 3rd order lowpass prototype:

N= 3; % order of prototype LPF fcenter= 22.5; % Hz center frequency, Hz bw= 5; ...

## Design IIR Butterworth Filters Using 12 Lines of Code

While there are plenty of canned functions to design Butterworth IIR filters [1], it’s instructive and not that complicated to design them from scratch.  You can do it in 12 lines of Matlab code.  In this article, we’ll create a Matlab function butter_synth.m to design lowpass Butterworth filters of any order.  Here is an example function call for a 5th order filter:

N= 5 % Filter order fc= 10; % Hz cutoff freq fs= 100; % Hz sample freq [b,a]=...

## Simplest Calculation of Half-band Filter Coefficients

Half-band filters are lowpass FIR filters with cut-off frequency of one-quarter of sampling frequency fs and odd symmetry about fs/4  [1]*.  And it so happens that almost half of the coefficients are zero.  The passband and stopband bandwiths are equal, making these filters useful for decimation-by-2 and interpolation-by-2.  Since the zero coefficients make them computationally efficient, these filters are ubiquitous in DSP systems.

Here we will compute half-band...

## There's No End to It -- Matlab Code Plots Frequency Response above the Unit Circle

Reference [1] has some 3D plots of frequency response magnitude above the unit circle in the Z-plane.  I liked them enough that I wrote a Matlab function to plot the response of any digital filter this way.  I’m not sure how useful these plots are, but they’re fun to look at. The Matlab code is listed in the Appendix.

This post is available in PDF format for easy...

## Modeling a Continuous-Time System with Matlab

Many of us are familiar with modeling a continuous-time system in the frequency domain using its transfer function H(s) or H(jω).  However, finding the time response can be challenging, and traditionally involves finding the inverse Laplace transform of H(s).  An alternative way to get both time and frequency responses is to transform H(s) to a discrete-time system H(z) using the impulse-invariant transform [1,2].  This method provides an exact match to the continuous-time...

## Canonic Signed Digit (CSD) Representation of Integers

February 18, 2017

In my last post I presented Matlab code to synthesize multiplierless FIR filters using Canonic Signed Digit (CSD) coefficients.  I included a function dec2csd1.m (repeated here in Appendix A) to convert decimal integers to binary CSD values.  Here I want to use that function to illustrate a few properties of CSD numbers.

In a binary signed-digit number system, we allow each binary digit to have one of the three values {0, 1, -1}.  Thus, for example, the binary value 1 1...

## Matlab Code to Synthesize Multiplierless FIR Filters

This article presents Matlab code to synthesize multiplierless Finite Impulse Response (FIR) lowpass filters.

A filter coefficient can be represented as a sum of powers of 2.  For example, if a coefficient = decimal 5 multiplies input x, the output is $y= 2^2*x + 2^0*x$.  The factor of $2^2$ is then implemented with a shift of 2 bits.  This method is not efficient for coefficients having a lot of 1’s, e.g. decimal 31 = 11111.  To reduce the number of non-zero...

## 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...

## Learn About Transmission Lines Using a Discrete-Time Model

January 12, 2022

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

## There's No End to It -- Matlab Code Plots Frequency Response above the Unit Circle

Reference [1] has some 3D plots of frequency response magnitude above the unit circle in the Z-plane.  I liked them enough that I wrote a Matlab function to plot the response of any digital filter this way.  I’m not sure how useful these plots are, but they’re fun to look at. The Matlab code is listed in the Appendix.

This post is available in PDF format for easy...

## 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...

## Interpolator Design: Get the Stopbands Right

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

In this part, I’ll show how to design a Hilbert Transformer using the coefficients of a half-band filter as a starting point, which turns out to be remarkably simple.  I’ll also show how a half-band filter can be synthesized using the Matlab function firpm, which employs the Parks-McClellan algorithm.

A half-band filter is a type of lowpass, even-symmetric FIR filter having an odd number of taps, with the even-numbered taps (except for the main tap) equal to zero.  This...

## Add a Power Marker to a Power Spectral Density (PSD) Plot

February 7, 2021

Perhaps we should call most Power Spectral Density (PSD) calculations relative PSD, because usually we don’t have to worry about absolute power levels.  However, for cases (e.g., measurements or simulations) where we are concerned with absolute power, it would be nice to be able to display it on a PSD plot.  Unfortunately, you can’t read the power directly from the plot.  For example, the plotted spectral peak of a narrowband signal, such as a sinewave, is lower than the...

## Model a Sigma-Delta DAC Plus RC Filter

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.