Design IIR Filters Using Cascaded Biquads

Similar documents
Design IIR Butterworth Filters Using 12 Lines of Code

EE482: Digital Signal Processing Applications

DIGITAL SIGNAL PROCESSING. Chapter 6 IIR Filter Design

Digital Signal Processing Lecture 8 - Filter Design - IIR

Digital Signal Processing IIR Filter Design via Bilinear Transform

IIR digital filter design for low pass filter based on impulse invariance and bilinear transformation methods using butterworth analog filter

Digital Control & Digital Filters. Lectures 21 & 22

Lecture 7 - IIR Filters

DSP Configurations. responded with: thus the system function for this filter would be

DIGITAL SIGNAL PROCESSING UNIT III INFINITE IMPULSE RESPONSE DIGITAL FILTERS. 3.6 Design of Digital Filter using Digital to Digital

ECE4270 Fundamentals of DSP Lecture 20. Fixed-Point Arithmetic in FIR and IIR Filters (part I) Overview of Lecture. Overflow. FIR Digital Filter

Butterworth Filter Properties

Optimum Ordering and Pole-Zero Pairing of the Cascade Form IIR. Digital Filter

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EC2314- DIGITAL SIGNAL PROCESSING UNIT I INTRODUCTION PART A

ECE 410 DIGITAL SIGNAL PROCESSING D. Munson University of Illinois Chapter 12

EE 521: Instrumentation and Measurements

ELEG 305: Digital Signal Processing

Lecture 7 Discrete Systems

ENGN3227 Analogue Electronics. Problem Sets V1.0. Dr. Salman Durrani

Cast of Characters. Some Symbols, Functions, and Variables Used in the Book

Design of Narrow Stopband Recursive Digital Filter

Analysis of Finite Wordlength Effects

The general form for the transform function of a second order filter is that of a biquadratic (or biquad to the cool kids).

An Iir-Filter Example: A Butterworth Filter

Chapter 7: IIR Filter Design Techniques

PS403 - Digital Signal processing

Filter Analysis and Design

Digital Signal Processing

Matched Second Order Digital Filters

UNIT - III PART A. 2. Mention any two techniques for digitizing the transfer function of an analog filter?

Second and Higher-Order Delta-Sigma Modulators

Converting Infinite Impulse Response Filters to Parallel Form

1 1.27z z 2. 1 z H 2

Signals and Systems. Lecture 11 Wednesday 22 nd November 2017 DR TANIA STATHAKI

On the Frequency-Domain Properties of Savitzky-Golay Filters

Lecture 19 IIR Filters

MITOCW watch?v=jtj3v Rx7E

2.161 Signal Processing: Continuous and Discrete Fall 2008

Higher-Order Σ Modulators and the Σ Toolbox

INF3440/INF4440. Design of digital filters

CMPT 889: Lecture 5 Filters

Digital Filters. Linearity and Time Invariance. Linear Time-Invariant (LTI) Filters: CMPT 889: Lecture 5 Filters

Appendix A Butterworth Filtering Transfer Function

Homework Assignment 11

( ) John A. Quinn Lecture. ESE 531: Digital Signal Processing. Lecture Outline. Frequency Response of LTI System. Example: Zero on Real Axis

ECE503: Digital Signal Processing Lecture 5

Vel Tech High Tech Dr.Ranagarajan Dr.Sakunthala Engineering College Department of ECE

Stability Condition in Terms of the Pole Locations

V. IIR Digital Filters

REAL TIME DIGITAL SIGNAL PROCESSING

Discrete Time Systems

EE 225D LECTURE ON DIGITAL FILTERS. University of California Berkeley

SIDDHARTH GROUP OF INSTITUTIONS:: PUTTUR Siddharth Nagar, Narayanavanam Road QUESTION BANK (DESCRIPTIVE)

CHANNEL PROCESSING TWIN DETECTORS CHANNEL PROCESSING TWIN DETECTORS CHANNEL PROCESSING TWIN DETECTORS CHANNEL PROCESSING TWIN DETECTORS

Tunable IIR Digital Filters

Lecture 9 Infinite Impulse Response Filters

Design of IIR filters

INFINITE-IMPULSE RESPONSE DIGITAL FILTERS Classical analog filters and their conversion to digital filters 4. THE BUTTERWORTH ANALOG FILTER

Signals, Instruments, and Systems W5. Introduction to Signal Processing Sampling, Reconstruction, and Filters

Digital Signal Processing Lecture 9 - Design of Digital Filters - FIR

DSP-CIS. Chapter-4: FIR & IIR Filter Design. Marc Moonen

2nd-order filters. EE 230 second-order filters 1

Digital Signal Processing

From Continuous-Time Domain to Microcontroller Code

Preserving the LTI system topology in s- to z-plane transforms

E : Lecture 1 Introduction

Other types of errors due to using a finite no. of bits: Round- off error due to rounding of products

DFT & Fast Fourier Transform PART-A. 7. Calculate the number of multiplications needed in the calculation of DFT and FFT with 64 point sequence.

Optimum Ordering and Pole-Zero Pairing. Optimum Ordering and Pole-Zero Pairing Consider the scaled cascade structure shown below

FILTER DESIGN FOR SIGNAL PROCESSING USING MATLAB AND MATHEMATICAL

Oversampling Converters

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur DEPARTMENT OF INFORMATION TECHNOLOGY. Academic Year

Lecture 10 Filtering: Applied Concepts

Transform Representation of Signals

Lecture 16 FREQUENCY RESPONSE OF SIMPLE CIRCUITS

2. Typical Discrete-Time Systems All-Pass Systems (5.5) 2.2. Minimum-Phase Systems (5.6) 2.3. Generalized Linear-Phase Systems (5.

Notes on L (Optimal) Filters

SEL4223 Digital Signal Processing. Inverse Z-Transform. Musa Mohd Mokji

University of Illinois at Chicago Spring ECE 412 Introduction to Filter Synthesis Homework #4 Solutions

There are two main classes of digital lter FIR (Finite impulse response) and IIR (innite impulse reponse).

EECE 301 Signals & Systems Prof. Mark Fowler

An Fir-Filter Example: Hanning Filter

Up-Sampling (5B) Young Won Lim 11/15/12

butter butter Purpose Syntax Description Digital Domain Analog Domain

Down-Sampling (4B) Young Won Lim 11/15/12

IT DIGITAL SIGNAL PROCESSING (2013 regulation) UNIT-1 SIGNALS AND SYSTEMS PART-A

DISCRETE-TIME SIGNAL PROCESSING

Digital Filter Implementation 1

Speaker: Arthur Williams Chief Scientist Telebyte Inc. Thursday November 20 th 2008 INTRODUCTION TO ACTIVE AND PASSIVE ANALOG

Lecture 3 - Design of Digital Filters

Multimedia Signals and Systems - Audio and Video. Signal, Image, Video Processing Review-Introduction, MP3 and MPEG2

Digital Signal Processing Lecture 10 - Discrete Fourier Transform

All-Pole Recursive Digital Filters Design Based on Ultraspherical Polynomials

Discrete-Time David Johns and Ken Martin University of Toronto

Second-order filters. EE 230 second-order filters 1

Chapter 7: Filter Design 7.1 Practical Filter Terminology

EE 508 Lecture 4. Filter Concepts/Terminology Basic Properties of Electrical Circuits

Signals and Systems. Problem Set: The z-transform and DT Fourier Transform

ELEN E4810: Digital Signal Processing Topic 11: Continuous Signals. 1. Sampling and Reconstruction 2. Quantization

Question Bank. UNIT 1 Part-A

Transcription:

Design IIR Filters Using Cascaded Biquads 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 quantization than a single high-order IIR, particularly for lower cut-off frequencies [1, 2]. In an earlier post on IIR Butterworth lowpass filters [3], I presented the pole-zero form of the Butterworth response H(z) as follows: The N zeros at z = 1 (ω= π or f = f s /2) occur when we transform the lowpass analog poles from the s- domain to z-domain using the bilinear transform. Our goal is to convert H(z) into a cascade of secondorder sections. If we stipulate that N is even, then we can write H(z) as: Each term in equation 2 is biquadratic it has quadratic numerator and denominator. It is not necessary to use a separate gain K for each term; we could also use just a single gain for the whole cascade. The filter is even order, so all poles occur in complex-conjugate pairs. We ll assign a complex-conjugate pole pair to the denominator of each term of equation 2. We can then write each term as: where p* k is the complex conjugate of p k. Expanding the numerator and denominator, we get: where a 1 = -2*real(p k ) and a 2 = p k 2. Dividing numerator and denominator by z 2, we get: We want the gain of each biquad section to equal 1 at ω=0. Letting z= e jω, we have z= 1. Then: 1

so where a = [1 a 1 a 2 ] are the coefficients of the biquad section. Summarizing the coefficient values, we have: b = [1 2 1] a= [1-2*real(p k ) p k 2 ] K A biquad lowpass block diagram using the Direct form II structure [4,5] is shown in Figure 1. We will cascade N/2 biquads to implement an N th order filter (N even). Note that the feed-forward coefficients b have the same value for all N/2 biquads in a filter. This is evident from Equation 3. x(n) K b 0 = 1 y(n) -a 1 b 1 = 2 -a 2 b 2 = 1 Figure 1 Biquad (second-order) lowpass all-pole filter Direct form II 2

Example In this example, we ll use biquad_synth to design a 6 th order Butterworth lowpass filter with -3 db frequency of 15 Hz and f s = 100 Hz. Note biquad_synth uses the bilinear transform with prewarping [3] to transform H(s) to H(z). The filter will consist of three biquads, as shown in Figure 2. biquad_synth computes the denominator (feedback) coefficients a of each biquad. The gains K are computed separately. Note biquad_synth contains code developed in an earlier post on IIR Butterworth filter synthesis [3]. Here is the function call and the function output: N= 6; % filter order fc= 15; % Hz -3 db frequency fs= 100; % Hz sample frequency a= biquad_synth(n,fc,fs) a = 1.0000-0.6599 0.1227 1.0000-0.7478 0.2722 1.0000-0.9720 0.6537 Each row of the matrix a contains the denominator coefficients of a biquad. As we already determined, the numerator coefficients b are the same for all three biquads: b= [1 2 1]; The gains for each biquad are, from equation 4: K1= sum(a(1,:)/4; K2= sum(a(2,:)/4; K3= sum(a(3,:)/4; Now we can compute the frequency response of each biquad. The overall response is their product. [h1,f] = freqz(k1*b,a(1,:),512,fs); [h2,f] = freqz(k2*b,a(2,:),512,fs); [h3,f] = freqz(k3*b,a(3,:),512,fs); h= abs(h1.*h2.*h3); H= 20*log10(abs(h)); The magnitude response of each biquad and the overall response are plotted in Figure 3. The sequence of the biquads doesn t matter in theory; however, placing the biquad with the peaking response (h3) last minimizes the chance of clipping. 3

x(n) K 1 1 K 2 1 K 3 1 y(n) -a 11 2 -a 21 2 -a 31 2 -a 12 1 -a 22 1 -a 32 1 Figure 2. 6 th order lowpass filter using three biquads Figure 3. 6 th order lowpass Butterworth cascaded-biquad response. f c = 15 Hz, f s = 100 Hz. Top: response of each biquad section (blue= h1, green= h2, red= h3). Bottom: overall response 4

Coefficient Quantization As I stated at the beginning, the cascaded-biquad design is less sensitive to coefficient quantization than a single high-order IIR, particularly for lower cut-off frequencies. To illustrate this, we ll first look at how quantizing coefficients effects z-plane pole locations of a 6 th order IIR filter. The following code finds the unquantized poles of the 6 th order Butterworth filter with -3 db frequency f c = 5 Hz. (Note butter [6] is a function in the Matlab signal processing toolbox that synthesizes IIR Butterworth filters). fc= 5; fs= 100; [b,a]= butter(6,2*fc/fs); % Matlab function for Butterworth LP IIR p= roots(a); % poles in z-plane The poles are plotted as the red x s on the left side of Figure 4. We have also plotted the poles for fc= 12 Hz (blue-ish x s). Each set contains 6 poles. If we plot the poles of filters having fc from 1 Hz to 25 Hz in 1 Hz increments, we get the plot on the right, where only the right side of the unit circle is shown. The lower values of f c are on the right, near z = 1. Figure 4. Unquantized poles of 6 th -order Butterworth IIR filter. Left: f c = 5 Hz (red) and 12 Hz (blue). Right: f c = 1 Hz to 25 Hz. 5

Now let s quantize the denominator coefficients and see how this effects the pole locations of Figure 4. Let nbits = the number of bits per unit of coefficient amplitude: nbits= 16; Here is the code to find the quantized poles for a single value of f c : fs= 100; [b,a]= butter(6,2*fc/fs); a_quant= round(a*2^nbits)/2^nbits; p_quant = roots(a_quant); Letting fc vary in 0.5 Hz increments from 0.5 to 25 Hz, we get the poles shown on the left of Figure 5. As you can see, as f c decreases, quantization causes the poles to depart from the desired locations. The right side of Figure 5 shows the effect of 10-bit quantization. Figure 5. Effect of Quantization on poles of 6 th -order Butterworth IIR filter. Left: nbits = 16 Right: nbits = 10 6

We can do the same calculation for the biquads that make up the 6 th order cascaded implementation. For example, here is the code to find the quantized poles of the second biquad for a single value of f c (recall that the matrix a has three rows containing the coefficients of 3 biquads). nbits= 10; a= biquad_synth(6,fc,fs); a2= a(2,:); % 2nd biquad a_quant= round(a2*2^nbits)/2^nbits; p_quant = roots(a_quant); This time, letting fc vary in 0.25 Hz increments from 0.25 to 25 Hz, we get the poles shown in Figure 6, which includes only quadrant 1 of the unit circle. The biquad performs much better than the 6 th order filter, only departing dramatically from the unquantized curve for fc = 0.25 Hz. So we expect better performance from cascading three biquads vs. using a single 6 th -order filter. Figure 6. Effect of Quantization on poles of one biquad, nbits = 10. Now we re finally ready to compare frequency response of a biquad-cascade filter vs. a conventional IIR filter when the denominator coefficients are quantized. The cutoff frequency and quantization level are chosen to stress the conventional filter. We ll leave the numerator coefficients of the conventional filter 7

as floating-point. Interestingly, when implementing the biquad filter we get exact numerator coefficient values for free : since b = [1 2 1], we can implement b 0 and b 2 as no-ops and b 1 as a bit shift. For the biquad filter, we use biquad_synth to find the coefficients for f c = 6.7 Hz: fc=6.7; % Hz -3 db frequency fs= 100; % Hz sample frequency a = biquad_synth(6,fc,fs) % a has 3 rows, one for each biquad a = 1.0000-1.3088 0.4340 1.0000-1.4162 0.5516 1.0000-1.6508 0.8087 For the conventional filter, we again use the Matlab function butter: [b,a]= butter(6,2*fc/fs); a = 1.0000-4.3757 8.1461-8.2269 4.7417-1.4761 0.1936 In each case, we quantize coefficients to 10 bits per unit of coefficient amplitude: nbits= 10; a_quant= round(a*2^nbits)/2^nbits; % quantize denom coeffs First, we ll look at the quantized pole locations. For the conventional filter, the quantized poles are: p_quant= roots(a_quant); For the biquad implementation, the quantized poles are: p1= roots(a_quant(1,:)) ; p2= roots(a_quant(2,:) ; p3= roots(a_quant(3,:) ; p_quant= [p1 p2 p3]; Figure 7 shows the z-plane poles for the floating-point and quantized coefficients. Quantization has little effect on the biquad version, but has a large effect on the conventional filter. Now let s compare the magnitude responses for quantized coefficients. We compute the response of the biquad version in the same way used to obtain Figure 3. Figure 8 shows the magnitude responses. As you would expect from the pole plots, the conventional implementation has poor performance, while the biquad implementation shows no noticeable effect due to quantization. So how low can we go with this N= 6 Butterworth cascaded-biquad filter? As we reduce f c, the quantization of 1024 steps per unit of coefficient amplitude eventually takes a toll. Figure 9 shows the z- plane poles and magnitude response for fc= 1.6 Hz. As you can see, the magnitude response is sagging. If we stay above f c of 2.5 Hz = f s /40, the response error is less than 0.1 db. Besides adding coefficient bits, there are other ways to improve performance of narrow-band IIR filters. See for example the post in reference [7]. 8

db Figure 7. Z-plane pole locations with quantized denominator coefficients. N= 6, f c = 6.7 Hz, f s = 100 Hz. Blue = floating point, Red = 10 bit quantization. Left: biquad implementation Right: conventional implementation. 10 0-10 -20-30 -40-50 0 5 10 15 20 25 Hz Figure 8. Magnitude response with quantized denom coeffs. N= 6, f c = 6.7 Hz, f s = 100 Hz, nbits = 10. Blue = biquad implementation, green= conventional implementation. 9

Figure 9. Z-plane poles and magnitude response of biquad-cascade filter with quantized denominator coefficients. Blue x s = floating-point and red x s = quantized. N= 6, f c = 1.6 Hz, f s = 100 Hz, nbits= 10. 10

References 1. Oppenheim, Alan V. and Shafer, Ronald W., Discrete-Time Signal Processing, Prentice Hall, 1989, sections 6.3.2 and 6.8.1. 2. Lyons, Richard G., Understanding Digital Signal Processing, 2 nd Ed., Pearson, 2004, section 6.8.2 3. Robertson, Neil, Design IIR Butterworth Filters Using 12 Lines of Code, Dec 2017 https://www.dsprelated.com/showarticle/1119.php 4. Sanjit K. Mitra, Digital Signal Processing, 2 nd Ed., McGraw-Hill, 2001, section 6.4.1 5. Digital Biquad Filter, https://en.wikipedia.org/wiki/digital_biquad_filter 6. Mathworks website, butter, https://www.mathworks.com/help/signal/ref/butter.html 7. Lyons, Rick, Improved Narrowband Lowpass IIR Filters, https://www.dsprelated.com/showarticle/120.php Neil Robertson February 11, 2018 Revised 2/19/18 11

Appendix Matlab Function biquad_synth This program is provided as-is without any guarantees or warranty. The author is not responsible for any damage or losses of any kind caused by the use or misuse of the program. % biquad_synth.m 2/10/18 Neil Robertson % Synthesize even-order IIR Butterworth lowpass filter as cascaded biquads. % This function computes the denominator coefficients a of the biquads. % N= filter order (must be even) % fc= -3 db frequency in Hz % fs= sample frequency in Hz % a = matrix of denominator coefficients of biquads. Size = (N/2,3) % each row of a contains the denominator coeffs of a biquad. % There are N/2 rows. % % Note numerator coeffs of each biquad= K*[1 2 1], where K = (1 a1 a2)/4. % function a = biquad_synth(n,fc,fs); if fc>=fs/2; error('fc must be less than fs/2') end if mod(n,2)~=0 error('n must be even') end % I. Find analog filter poles above the real axis (half of total poles) k= 1:N/2; theta= (2*k -1)*pi/(2*N); pa= -sin(theta) j*cos(theta); pa= fliplr(pa); % poles of filter with cutoff = 1 rad/s %reverse sequence of poles put high Q last % II. scale poles in frequency Fc= fs/pi * tan(pi*fc/fs); pa= pa*2*pi*fc; % continuous pre-warped frequency % scale poles by 2*pi*Fc % III. Find coeffs of biquads % poles in the z plane p= (1 pa/(2*fs))./(1 - pa/(2*fs)); % poles by bilinear transform % denominator coeffs for k= 1:N/2; a1= -2*real(p(k)); a2= abs(p(k))^2; a(k,:)= [1 a1 a2]; end %coeffs of biquad k 12