Lab Report
CME
Digital Signal Processing
November 16, 2023
Group Report written by Semester Day of experiment
1 Sadanand Gavde 3 11.10.2023
Philip Arthur
Participants: Philip Arthur, Sadanand M. Gavde
Experiments: Exp. 1 (Matlab Kickoff) ✓ Exp. 2 (FIR, IIR Filter Design) Exp. 3 (ECG)
Supervisor: Prof. Dr.-Ing. Christian Reich
Summary:
In this report, the design, analysis and discussion of results of Finite Impulse Response (FIR) and Infinite
Impulse Response (IIR) filters are presented. Section one describes a lowpass filter design based on the
Fourier approximation followed by the modified approximation methods of the lowpass filter design in
section two. The IIR filter design for various filter types is presented in section 3 together with the
corresponding observations and conclusion in section 4.
1 FIR Low-pass filter: Fourier Approximation
A Finite Impulse Response (FIR) low-pass filter is a type of digital filter characterized by a finite duration
impulse response. In this design, the filter’s output is a weighted sum of past input samples, with the weights
determined by the filter coefficients. For a low-pass FIR filter, the objective is to attenuate higher-frequency
components of the input signal while allowing lower-frequency components to pass through. The filter
achieves this by adjusting the weights of the input samples in a way that emphasizes the desired frequency
range. FIR filters offer linear phase response, making them suitable for applications where phase distortion
is critical, such as in audio processing. The flexibility of FIR filters in terms of magnitude and phase response
design makes them widely used in various signal-processing applications.
Case 1
Filter order = 16
Response Type : Lowpass
Window: Rectangular
Figure 1: Impulse response of FIR low-pass filter.
Fig.1 describes the Impulse response of the filter. The impulse response is typically symmetrical, with the
largest peak at the center and smaller peaks on either side. The width of the impulse response determines the
2
cutoff frequency of the filter. A wider impulse response indicates a lower cutoff frequency, while a narrower
impulse response indicates a higher cutoff frequency.
Figure 2: Amplitude Response of Low pass filter
Fig.2 describes the Amplitude Response of the filter in db. A passband and a stopband typically char-
acterize the magnitude response of an FIR low-pass filter. When a rectangular window is used to design an
FIR low-pass filter, the cutoff frequency is crucial in determining the filter’s characteristics and performance.
The cutoff frequency defines the boundary between the passband and stopband of the filter. Frequencies
below the cutoff frequency can pass through with minimal attenuation, while frequencies above the cutoff
frequency are significantly attenuated. The filter is designed with 9.6KHz as its cutoff frequency.
Figure 3: Phase response of Low pass filter.
Fig.3 describes the phase response of the filter. An ideal low-pass filter has a linear phase response,
which means that all frequencies are shifted by the same amount. However, real-world FIR low-pass filters
3
typically have a non-linear phase response due to the windowing function used to design the filter.
The phase response of the FIR low-pass filter in the image shows a slight non-linearity at the edges of
the passband. This non-linearity is due to the rectangular window used to design the filter.
Figure 4: Group Delay of the Low pass filter.
Fig.4 describes the Group delay of the filter. Group delay is a measure of how much the filter delays
different frequency components of the input signal. It is calculated as the negative derivative of the phase
response. An ideal low-pass filter has a constant group delay, which means that all frequencies are delayed
by the same amount. However, real-world FIR low-pass filters typically have a non-constant group delay
due to the windowing function used to design the filter. The group delay of the FIR low-pass filter in the
image shows a slight variation across the passband. This variation is due to the rectangular window used to
design the filter.
4
Figure 5: Pole zero diagram of the Low pass filter.
Fig.5 describes the Pole Zero diagram of the filter. The pole-zero diagram of an FIR low-pass filter is a
plot of the filter’s poles and zeros in the complex plane. The poles are the roots of the denominator of the
filter’s transfer function, while the zeros are the roots of the numerator. In the case of an FIR low-pass filter,
all of the poles lie inside the unit circle in the complex plane. This is because the filter’s impulse response
is finite, which means that the filter’s output dies out after a finite number of samples. The zeros of an FIR
low-pass filter can be located anywhere in the complex plane. However, they are typically placed so that
they cancel out the poles at frequencies above the cutoff frequency of the filter. This helps to create a sharp
transition band between the passband and stopband of the filter.
Case 2
Filter order = 32
Response Type : Lowpass
Window: Rectangular
5
Figure 6: Amplitude Response of Low pass filter for N=32.
2 FIR Low-pass filter: Modified Fourier Approximation
Case
Response type: Low-pass
Design Method: Window
Window: Bartlett, Hamming, Kaiser(Beta: 2.5, 7.5)
Figure 7: Amplitude response using Bartlett Window
6
Figure 8: Amplitude response using Hamming Window.
Figure 9: Amplitude response using Kaiser Window with Beta = 2.5
Figure 10: Amplitude response using Kaiser Window with Beta = 7.5
Observations
1. On comparing the Rectangular window Amplitude response with the Bartlett window Amplitude response,
it can be observed that in the case of rectangular window response, there is a sharp transition between the
7
passband and stopband. Also, due to this significant ripples are introduced in stopband.
2. Hamming windows taper more smoothly to zero at the edges of the filter length resulting in a wider
transition band compared to the rectangular window.
3. Kaiser window allows adjustable transition bandwidth and ripple but sidelobes are also introduced. The
beta parameter in the Kaiser window is a crucial factor that influences the shape and characteristics of the
window’s frequency response. As the value of beta increases, the transition band of the filter becomes wider,
leading to a smoother transition from the passband to the stopband. Lower values of beta result in higher
sidelobe levels, while higher values of beta lead to lower sidelobe levels
2.1 Lowpass Chebychev Filter
Case 1
Response Type: Lowpass
Design method: Equiripple
Filter order: 32
Algorithm: Remez-Exchange-Algorithm (Equiripple)
Figure 11: Amplitude response of the Chebychev Lowppass filter from 0 Hz to F/2.
2.2 Bandpass Chebychev Filter
Case 2
Response Type: Bandpass
Design Method: Equiripple
Filter Order: 32
8
Algorithm: Remez-Exchange-Algorithm (narrow bandpass filter)
Lower stopband area: as ≤ −60 dB for 0 ≤ f ≤ 0.7 · fc
Passband area: −0.5 dB ≤ aD ≤ 0.5 dB for 0.9 · fc ≤ f ≤ 1.1 · fc
Upper stopband area: as ≤ −40 dB for 1.3 · fc ≤ f ≤ F/2
Figure 12: Amplitude response of the Chebychev Butterworth filter.
2.3 Effect of fixed point (finite) representation of filter coefficients on the Cheby-
chev bandpass filter
Case 3:
Response Type: Bandpass
Design Method: Equiripple
Lower stopband area: as ≤ −60 dB for 0 ≤ f ≤ 0.7 · fc
Passband area: −0.5 dB ≤ aD ≤ 0.5 dB for 0.9 · fc ≤ f ≤ 1.1 · fc
Upper stopband area: as ≤ −40 dB for 1.3 · fc ≤ f ≤ F/2
Filter arithmetic: Fixed-point
Numerator word length: 8
9
Figure 13: Magnitude response of the Chebychev bandpass filter with quantized filter coefficients.
Observations:
From Fig.15, the lower stopband, upper stopband and transition edge areas are the most sensitive to the
quantized coefficients. This is due to the fact that the quantization errors are more significant in areas where
the amplitude response varies rapidly (i.e., stopbands). However, since the passband has small magnitude
response ripples, it is less affected by the quantization errors of the filter coefficients.
2.4 Hilbert filter design
Case 1
Figure 14: Amplitude response of the Hilbert filter.
10
Figure 15: Phase response of the Hilbert filter.
case 2
Figure 16: Phase response of the Hilbert filter using Remez Exchange algorithm.
11
Figure 17: Phase response of the Hilbert filter using Remez Exchange algorithm.
Observations
The reason for this discrepancy lies in the practical implementation of Hilbert filters. While the theoretical
ideal of a Hilbert filter is to introduce a constant phase shift of -90 degrees across all frequencies, real-world
implementations often exhibit a linearly increasing phase response as a result of various factors such as the
finite length and variations in the group delay of the filter.
12
3 Infinite Impulse Response (IIR) Filter Design
Infinite Impulse Response (IIR) filters are characterized by the fact that they have an impulse response of
infinite length (Infinite Impulse Response). The structure has at least one feedback path. Due to the existing
feedback, the stability condition in these systems is not met from the outset, but only for suitable coefficients
in the feedback paths. The recursive nature of IIR filters results in more efficient implementations compared
to Finite Impulse Response (FIR) filters. In this section, the lowpass Butterworth, Chebyshev type I, type
II as well as the lowpass and bandpass Elliptic filters are designed and results discussed.
3.1 IIR Filter with Lowpass Characteristics (implemented in direct structure)
Response type: Lowpass
Sampling frequency: 48 kHz
Cut-off frequency: 9.975 kHz
Case 1: Butterworth filter
Figure 18: Magnitude and phase response of lowpass Butterworth filter.
13
Figure 19: Pole-Zero plot of the lowpass Butterworth filter.
Case 2: Chebyshev type I filter
Figure 20: Magnitude and phase response of lowpass Chebyshev type I filter.
14
Figure 21: Pole-Zero plot of the lowpass Chebyshev type I filter.
Case 3: Chebyshev type II filter
Figure 22: Magnitude and phase response of lowpass Chebyshev type II filter.
15
Figure 23: Pole-Zero plot of the lowpass Chebyshev type II filter.
Case 3: Elliptic filter
Figure 24: Magnitude and phase response of lowpass Elliptic filter.
16
Figure 25: Pole-Zero plot of the lowpass Elliptic filter.
Discussion and comparison of results
Comparing the magnitude response of the filters presented above, the following are observed;
1. The Butterworth filter has a maximally flat passband response with no ripples in the passband and
stopband. However, it has a very slow roll-off in the stopband with a wide transition band.
2. In the Chebyshev type I filter, there are equiripples in the passband, but faster roll-off in the stopband
compared to the Butterworth filter.
3. In the type II Chebyshev filter, there are no ripples in the passband but instead equiripple in the
stopband. It also has a faster roll-off in the passband compared to Butterworth.
4. The Elliptic filter has ripples in both passband and stopband areas. However, it provides the steepest
roll-off among the four filter types.
Comparing the phase response of the filters, the following are observed;
1. The Butterworth filter has linear phase response in both the passband and stopband areas.
2. In the type I Chebyshev filter, there is a non-linear phase response due to the passband ripples.
3. The Chebyshev type II filter has a more linear phase response in the passband compared to the type
I filter due to no ripples in the passband. Meanwhile, the stopband has phase jumps due to the
equiripples in the stopband.
4. The Elliptic filter has a non-linear phase response in both the passband and stopband due to the
equiripples in both bands.
17
Considering the pole-zero plots, the following are deduced;
1. In the Butterworth filter, all poles are located inside and on the right half plane of the unit circle at
equal distances. There is one zero that lie on the left-half of the unit circle.
2. The type I Chebyshev filter has all poles located inside and on the right-half plane of the unit circle
with unequal distances. There is also one zero that lie on the left-half of the unit circle.
3. In the Chebyshev type II filter, poles inside the unit circle are found both in the left and right-half of
the plane with equal distance. Meanwhile, the zeros are located along the unit circle on the left-half
of the plane but not at equal distances.
4. Finally, the Elliptic filter has non-equidistant poles aligned in the right-half of the plane while the
corresponding zeros are aligned along the left-half of the unit circle.
3.2 IIR Filter with Bandpass Characteristic
The design of an Elliptic bandpass filter with the specifications below is presented in this section.
Passband attenuation: 0.5 dB
Stopband attenuation: 30 dB
fdu = fm - 1 kHz
fdo = fm + 1 kHz
In addition, the transition band areas of the filter must be less than 500 Hz.
Figure 26: Magnitude and phase response of the minimum order Elliptic bandpass filter.
18
From Fig. 26, the minimum order required to meet the filter specifications is 8.
Figure 27: Pole-Zero plot of the minimum order (order 8) Elliptic bandpass filter.
Figure 28: Magnitude and phase response of a 20th order Elliptic filter.
19
Figure 29: Zoom-in view of magnitude response of the 20th order Elliptic filter.
Figure 30: Pole-Zero plot of the 20th order Elliptic bandpass filter.
Discussion and comparison of results
Considering the magnitude and phase response of the minimum order (order 8) and high order (order 20)
Elliptic filters, the following are observed;
20
1. The high order filter has a steeper roll-off in both the passbands and stopbands compared to the low
order filter.
2. It is also observed that, the 20th order filter has a higher attenuation in the stopband around -60 dB
compared to the 8th order filter around -40 dB.
3. Additionally, the transition band of the 20th order filter is more narrower compared to that of the 8th
order filter.
4. In both filters, the phase response is non-linear due to their equiripple behaviour. However, the high
order filter has a sharper roll-off in the phase response compared to the 8th order filter.
From the pole-zero plots above of the minimum order filter and the high order filter, the following deductions
are made;
1. There are fewer number of poles and zeros in the pole-zero plot of the 8th order filter compare to the
higher order filter.
2. Also, the distribution of the poles in the 20th order filter is more dense and closer to the edge of the
unit circle than the 8th order filter whose poles are quite separated and little away from the edge of
the unit circle.
Moreover, it can be noticed that the order of an IIR filter required to meet the same filter specifications
as in an an FIR filter is generally lower. This is evident by example, comparing the filter order of the
FIR bandpass filter in the figures above the IIR bandpass filter in the figures presented. The filter order
required to satisfy the passband and stopband ripples in the FIR filter is 51 while that of the IIR filter is 20.
This means IIR filters generally have minimal implementation structures that leads to lower computational
complexity compared to FIR filters.
21
4 Conclusion
In this report, different kinds of FIR and IIR filters have been designed and analyzed using the filter de-
signer tool in Matlab. In the FIR filter design, both Fourier and modified approximation methods with
different window algorithms have been used to design different lowpass and bandpass filters. Generally,
different window methods provide different characteristics in the the stopband and passband. Additionally,
the Hilbert filter with order 10 is designed with calculated filter coefficients using the Remez-Exchange algo-
rithm. Similarly, the IIR filters with lowpass characteristic (implemented in direct structure) have also been
presented for Butterworth, Chebyshev type I, Chebyshev type II and Elliptic filters. Meanwhile, IIR filters
with bandpass characteristics have also been designed and analyzed. From these analysis, it is noticed that
the order of an IIR filter required to meet the same filter specifications as in an FIR filter is generally lower.
This means IIR filters generally have minimal implementation structures that leads to lower computational
complexity compared to FIR filters.
22
5 Appendix - Matlab code for 20th order Elliptic bandpass filter
function Hd = E l l i p t i c _ b a n d p a s s _ o r d e r 2 0
% E L L I P T I C _ B A N D P A S S _ O R D E R 2 0 Returns a discrete - time filter object .
% MATLAB Code
% Generated by MATLAB ( R ) 9.14 and DSP System Toolbox 9.16.
% Generated on : 16 - Nov -2023 20:33:02
% Elliptic Bandpass filter designed using FDESIGN . BANDPASS .
% All frequency values are in Hz .
Fs = 48000; % Sampling Frequency
N = 20; % Order
Fpass1 = 8975; % First Passband Frequency
Fpass2 = 10975; % Second Passband Frequency
Apass = 0.5; % Passband Ripple ( dB )
Astop = 30; % Stopband Attenuation ( dB )
% Construct an FDESIGN object and call its ELLIP method .
h = fdesign . bandpass ( 'N , Fp1 , Fp2 , Ast1 , Ap , Ast2 ' , N , Fpass1 , Fpass2 , ...
Astop , Apass , Astop , Fs ) ;
Hd = design (h , ' ellip ') ;
% Desired points
Omega_du = 2* pi * Fpass1 / Fs ; % Angle for z1 = exp ( j * Omega_du ) ;
Omega_do = 2* pi * Fpass2 / Fs ; % Angle for z2 = exp ( j * Omega_do ) ;
% Calculate the polar coordinates of the points
rdu = 1; % Radius for the point z = e ^( j * _du )
rdo = 1; % Radius for the point z = e ^( j * _do )
23
zplane ( Hd ) ; % pole / zero diagram plot function
hold on ; % we want to plot more into the diagram
% Transform polar coordinates to Cartesian coordinates
[ xdu , ydu ] = pol2cart ( Omega_du , rdu ) ;
[ xdo , ydo ] = pol2cart ( Omega_do , rdo ) ;
% Plot the points with the stem function
stem ( xdu , ydu , ' LineStyle ' , ' none ' , ' Color ' , ' red ' , ' Marker ' , '* ') ;
stem ( xdo , ydo , ' LineStyle ' , ' none ' , ' Color ' , ' blue ' , ' Marker ' , 's ') ;
% Add lines from the origin to the points
line ([0 , xdu ] , [0 , ydu ] , ' Color ' , ' red ') ;
line ([0 , xdo ] , [0 , ydo ] , ' Color ' , ' blue ') ;
hold off ;
% [ EOF ]
24