0% found this document useful (0 votes)
174 views

Digital Filter Design

This document discusses digital filter design. It begins by explaining what a digital filter is and why they are used. Digital filters are programs that perform numerical calculations on sampled signal values. They are commonly embedded in chips and have advantages over analog filters like being programmable, flexible, stable, and versatile. The document then covers various aspects of digital filter design such as filter types (FIR and IIR), design methods like windowing and transformations from analog prototypes, and considerations like stability and linear phase. It provides examples of designing low-pass filters using different techniques like windowing, impulse invariance, and bilinear transformation. MATLAB commands for prototyping common filter types are also presented.

Uploaded by

Asmaa Mosbeh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
174 views

Digital Filter Design

This document discusses digital filter design. It begins by explaining what a digital filter is and why they are used. Digital filters are programs that perform numerical calculations on sampled signal values. They are commonly embedded in chips and have advantages over analog filters like being programmable, flexible, stable, and versatile. The document then covers various aspects of digital filter design such as filter types (FIR and IIR), design methods like windowing and transformations from analog prototypes, and considerations like stability and linear phase. It provides examples of designing low-pass filters using different techniques like windowing, impulse invariance, and bilinear transformation. MATLAB commands for prototyping common filter types are also presented.

Uploaded by

Asmaa Mosbeh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Digital Filter Design

Prepared by:
Asmaa Mosbeh

Under supervision of:


Dr Nabil Sabor
What ..?
• A program Instructions (software) running on the processor (PC or
DSP chip) to perform numerical calculations on sampled values of the
signal.
Why..?
• Embedded in a chip.
• Programmable.
• Flexible (easily changed without affecting hardware).
• More stable (not suffer from time and temperature).
• Less complex (roll-off).
• More versatile (adapt to changes in signal).
• Digital systems.
How..?
• Consider the rational system function

• In filter design, we seek to find the system coefficients, i.e. M, N, ak and bk,
such that the corresponding frequency response

• provides a good approximation to a desired response Hd(ω), i.e.


• The resulting system H(z) must be stable and causal, which imposes strict
constraints on the possible values of ak.
• Additionally, a linear phase requirement for H(z) may be desirable in
certain applications, which further restrict the system parameters.

• FIR ("finite impulse response") or IIR ("infinite impulse response").


• Basic design principle:
•If GLP is essential ⇒ FIR
•If not ⇒ IIR usually preferable (can meet specifications with lower
complexity)
• Typical low-pass specifications

The parameters are:

• [0,ωp ] = pass-band
• [ωs ,π] = stop-band
• δω = ωs − ωp = width of transition band.
• δ1 = pass-band ripple. Often expressed in dB via 20log10(1+δ1 ).
• δ2 = stop-band ripple. Usually expressed in dB as 20log10(δ2 ).
Design of FIR filters
• The general FIR system that is

• Digital FIR filters cannot be derived from analog filters, rational analog
filters cannot have a finite impulse response.

• Stability is not an issue since FIR filters are always stable;


• Considerable emphasis is usually given to the issue of linear phase
Linear-phase filters
• A general FIR filter does not have a linear phase response but
this property is satisfied when

• There are 4 types of FIR GLP filters:


Filter Design by Windowing
• Simplest way of designing FIR filters
• Method is all discrete-time no continuous-time involved
• Start with ideal frequency response

• Choose ideal frequency response as desired response


• Most ideal impulse responses are of infinite length
• The easiest way to obtain a causal FIR filter from ideal is
• More generally

Where
Properties of Windows
• Prefer windows that concentrate around DC in frequency
Less smearing, closer approximation
• Prefer window that has minimal span in time
Less coefficient in designed filter, computationally efficient
• So we want concentration in time and in frequency
Contradictory requirements
• Example: Rectangular window
•U
Conflicting Ideal Requirements
• Use windows with no abrupt discontinuity in their time domain response
and consequently low side-lobes in their frequency response.

• In this case, the reduced ripple comes at the expense of a wider transition
region but this However, this can be compensated for by increasing the
length of the filter.

• Windows with no abrupt discontinuity can be used to reduce Gibbs


oscillations (e.g. Hanning, Hamming, Blackman).
We see clearly that a wider transition region (wider main-lobe) is compensated by
much lower side-lobes and thus less ripples.
Kaiser Window
• Parameterized equation forming a set of windows
Parameter to change main-lob width and side-lob area trade-off
Kaiser Window Parameters

• Given the peak approximation error or in dB as


• and transition band width
• The shape parameter B should be

• The filter order M is determined approximately by


Example
• Design a type I low-pass filter according to the specification
The band-edge frequency of the ideal response if the midpoint between ωs
and ωp
ωc = (ωs + ωp)/2 = (0.2π+0.3π)/2 = 0.25π

• FIR Design by Optimization


Least-Square Method.
Equiripple Design.
Remez method ..etc.
**Recall Our Example:
a least-square method design gives N =
33 (compared to N = 80).
Frequency response of various filters
MATLAB Prototype Filter Design Commands
• [B,A] = BUTTER(N,Wn)
• [B,A] = CHEBY1(N,R,Wn)
• [B,A] = CHEBY2(N,R,Wn)
• [B,A] = ELLIP(N,Rp,Rs,Wn)
– N = filter order
– R = pass band ripple (cheby1) or stop-band ripple (cheby2) in dB. (Rp and Rs respectively for the
elliptic filter)
– Wn = cut-off frequency (normalized)
– [B,A] = filter coefficients.
• C=Fir1(N,Wn,’ftype’) %’ftype’ not needed if it LP filter
For more details please check help tool in MATLAB
• fdatool %in MATLAB command window

➢ In command window, FDAtool will be opened.There you can select FIR or IIR
filter, order of filter and cutoff frequency of a filter (either HPF, LPF or BPF). That
code will automatically generate .m file for you.
Highpass Filter
Design of IIR filters
For H(z) to be the system function of a causal & stable
LTI system, all its poles have to be inside the unit circle (U.C.).

•Design problem

The goal is to find filter parameters N,M,{ak} and {bk} such that H(ω) ∼ Hd (ω) to
some desired degree of accuracy.
•Transformation methods:

There exists a huge literature on analog filter design Ha(Ω). The transformation methods
try to take advantage of this literature in the following way:

1.Map DT specifications Hd(ω) into analog specifications Had(Ω) via proper


transformation;
2. Design analog filter Ha(Ω) that meets the specifications;
3. Map Ha(Ω) back into H(ω) via a proper inverse transformation.
Impulse invariance method: Design steps
1.Given the desired specifications Hd(ω) for the DT filter, find the corresponding
specifications for the analog filter, Had (Ω); For example: case of a low-pass design

2.Design an analog IIR filter Ha(Ω) that meets the desired analog specifications
Had(Ω):
• Choose the filter type (Butterworth, elliptic, etc.)
• Select the filter parameters (filter order N, poles sk, etc.)

3. Transform the analog filter Ha(Ω) into a discrete-time filter H(z)


via time-domain sampling of the impulse response:
Example: Impulse invariance method
Apply the impulse invariance method to an appropriate analog
Butterworth filter in order to design a low-pass digital filter H(z)
that meets these specifications

• Step 1: We set the sampling period to Ts = 1 (i.e. Ω = ω ), so that the desired specifications for the
analog filter are :

• Step 2: design an analog Butterworth filter Hc(Ω) that meets the above specifications. For the
Butterworth family, we have

• Thus, we need to determine the filter order N and the cut-off frequency Ωc so that the above
inequalities are satisfied.
Step 3: The desired digital filter is finally obtained by applying the
impulse invariance method:
Bilinear transformation
Principle: Suppose we are given an analog IIR filter Ha(s). A digital filter H(z) can be obtained by applying the bilinear
transformation (BT), defined as:
Example: Bilinear transformation
Step 1: Set the parameter α to 1. The desired
specifications for the analog filter are similar to
the above except for the band-edge frequencies.
That is
• Step 2: Design a Butterworth filter Ha(Ω) that meets the above specifications.
• Find that the required order of the Butterworth filter is N = 11 (or precisely N≥ 10.15).
• Determine the cut-off frequency Ωc. For example:

• The desired analog Butterworth filter is specified as

• Step 3: Desired digital filter is obtained by applying BT:


% generate signal
fs = 100; % sampling frequency
f = 5; % signal frequency
t = 5; % time duration
n = [0:1/fs:t]; % sample vector
x = cos (2*pi*f*n);
y=rand(1,length (x)); % y= awgn(x,1.5); “it can also generate noise”
z = x+y;
subplot(3,1,1); plot(n,x); title('Sinusoidal signal');
subplot(3,1,2); plot(n,y); title(‘noise');
subplot(3,1,3); plot(n,z); title('signal with noise');

% IIR Butterworth LPF filter Design


M = 40; % order of the filter
Wc = 2*pi*f/fs; % normalized cut-off frequency (as of signal freq)
[b,a] = butter(M,Wc,'low'); % b,a coeff. of IIR butterworth filter
fvtool(b,a); % filter frequency response MATLAB Ex
% filter the signal
x_f_iir = filter(b,a,z);
figure (3); plot(n,x_f_iir); title('Filtered Sinusoidal Signal with IIR');

% FIR Filter Design


N = 40;
d = fir1(N,Wc); % FIR low pass filter
figure (4); freqz(d,1,500); % frequency response of FIR LPF filter

% filter the signal


x_f_fir = filter(d,1,z);
figure (5); plot(n,x_f_fir); title('Filtered Sinusoidal Signal with FIR');
Thanks

You might also like