0% found this document useful (0 votes)
77 views23 pages

Cristian Vargas ECE 3101L Lab Report #3

Lab Report for a Signals and Systems course

Uploaded by

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

Cristian Vargas ECE 3101L Lab Report #3

Lab Report for a Signals and Systems course

Uploaded by

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

Vargas 1

ECE 3101L

Prof. Andrew Pagnon

Lab Report #3

Filter Design

November 21, 2024

Cristian Vargas

(Lab Partner: Aaron Tran)


Vargas 2

Table of Contents:

Executive Summary………………………………………………………………………………3

Theory/Background………………………………………………………………………………4

 Transfer Function and Z Transform………………………….……….…….……………4


 Z Domain……………………………………….………………………………..………6
 Frequency Response Graph………………...……………………...…………………….9
 White Noise……………………………………………………………………………..12
 Sampling Rate…………………………………………………………………………..13

Lab/Data Anlysis…………………………………………………………….…………………15

 Pole-Zero Diagrams w/ Magnitude and Phase Response………………………………15


 FIR Filters…………………….……………………………………………………..…18
 IIR Filters…………………………....…………………………………………………20

Error Analysis……………………………………………………………………………………23
Vargas 3

Executive Summary:

This report delves into the design and analysis of Finite Impulse Response (FIR) and Infinite
Impulse Response (IIR) filters, emphasizing their interpretation in the z-domain and the
significance of their transfer functions. It highlights the distinct characteristics of FIR filters,
such as inherent stability, and the computational efficiency of IIR filters due to their recursive
structures. Experimental data collected during the lab is used to validate theoretical concepts,
showcasing the impact of poles and zeros on filter behavior.
Vargas 4

Theory Background:

Transfer Function (FIR & IIR) and Z Transform

Transfer functions are functions which are often used to describe the characteristics of a
filter, often including terms called poles and zeroes which influences the type of filter may be
(High Pass, Low Pass, Band Pass, etc.). Using a very general expression, we can characterize the
output of some filtered signal as:

N−1 M
y ( n )= ∑ b i x (n−i)−∑ a k y (n−k )
i=0 k=1

In this expression the x (n) terms represent the input signal and the y (n) terms represent
the output signal, or the recursive terms which are fed back into the filter. A filter where a k =0 for
all instances of k is what is considered a Finite Impulse Response (FIR) filter. These filters can
be characterized as only having zeros and no poles, as poles are determined by the feedback
signal of the filer, as we will see later.

Filters which have non-zero terms for a k are known as Infinite Impulse Response (IIR)
filters, as they will perpetually have a signal being fed back into the filter, allowing for an infinite
number of terms. Due to this property, IIR filters tend to be unstable, meaning that they can
achieve states where a signal does not stop being amplified and can be catastrophic for the
system it is working with.
Vargas 5

The main mathematical method which is used in order to analyze the frequency response
of filters and their difference equations is the Z Transform. The Z Transform is defined as:


X ( z )= ∑ x ( n ) z−n
n=−∞

We will be using the Discrete Time Fourier Transform (DTFT), which is effectively a Z
Transform which is adapted to be mapped on a unit circle including a complex plane. The DTFT
is defined as:


X ( e jω )= X ( z ) ( where z=e jω ) = ∑ x ( n ) e− jωn
n=−∞

Using our definition for the Z Transform however, we can re-write the original difference
equation which was used to characterize the input and output signals of the filter. By taking Z
Transforms on the left and right side, we can rewrite the equation as:

N −1 M
Y ( z )= ∑ bi z−1 X ( z )−∑ ak z−1 Y ( z )
i=0 k=1

Now, solving for the ratio of the output and the input signals, also known as the Transfer

(
Function, H ( z )=
X (z))
Y ( z)
we gather the expression:
Vargas 6

N −1

∑ bi z−1
i=0
H ( z )= M
1+ ∑ ak z
−1

k=1

This can also be adapted to reflect that of the DFTF, allowing us to interpret it on the
complex unit circle:

N−1

∑ bi e− jωi
H ( e jω )= i=0
M
1+∑ a k e
− jωk

k=1

What we can gather from the derived expressions for the Transfer Function, is that the
zero terms are represented in the numerator, and the pole terms are represented in the
denominator of the Transfer Function. Although it may seem trivial, this supports our
understanding of FIR and IIR filters as when the numerator is equal to zero, the signal is simply
zero, showing that the FIR filters are always stable. However, when the denominator of the
Transfer Function is equal to zero, this can cause the output signal to reach effectively infinity,
which is problematic.

From the above expressions we can write the expression where the numerator and
denominator are comprised of factors of general polynomial expressions:

b0∗(z polynomial of zeros)


H ( z )=
(z polynomial of poles)

In this form of the Transfer Function, b 0 represents a constant term which scales the
height of the transfer function such that the maximum gain is 1. The terms in the numerator and
denominator determine the location of each pole or zero in terms of the Z Domain coordinate
system. This will be expanded upon in the next section.

An example of a transfer function which follows this format is as follows:

b0∗zero terms
TF=
poleterms
= ( 0.05 )∗
z+ 1
z −0.9 ( )
This transfer function will be further explained in the next section.
Vargas 7

Z-Domain

In order to decompose the above example Transfer Function, we must define the Z-
Domain and how points can be characterized on the unit circle. First we must refer to the
foundational mathematical property of Euler’s Identity. According to Euler’s Identity we know
that:

r e =r ( cos ( ω ) + jsin ( ω ) ) where z=e


jω jω

The importance of this mathematical definition is utilized in how the Z-Domain is


comprised of both a real and an imaginary axis. As depicted in the below image, the x-axis is the
real axis, and the y-axis is the imaginary axis. This relates to Euler’s Identity as the real
components of the Z-Domain are the real component of each Z term (rcos (ω)) and the imaginary
components of the Z-Domain are the imaginary component of each Z term (rjsin (ω)). Notice
how the independent variable of the Z term is the frequency of some input signal. This shows
how the transfer function develops discrete output values for every possible frequency which is
passed through.

Zeross will often fall on the unit circle, as having a zero term in the numerator of the
transfer function is not problematic as stated before. Using the unit circle however, we can
visualize the issues which arise with having pole terms on the unit circle in particular. As the
various frequencies are being sent through the filter, it would be problematic to have a zero term
in the denominator of the Transfer Function as this would create effectively an infinite gain and
Vargas 8

be destructive to the signal. This is why poles are often placed inside of the Z-Domain unit circle,
as this would allow a small, but non-zero term to still alter the slope of the Transfer Function.

In the following experiments, we will be testing how the specific location of the zeros
and pole directly influence the characteristics of the transfer function. The angle distribution of
each of the poles/zeros along with the radii of each pole will alter the shape of each of the filters.

Considering the Transfer Function which was stated earlier we could depict the Z-
Domain unit circle of the filter looking like:

Note how the pole is depicted by an X and the zero is depicted by a circle. When
designing filters on the Z-Domain, we will often interpret the bandwidth of the frequencies
passed through the filter as being from 0 to π . This is because the range of discrete frequencies
which are passed through the filter, known as the Nyquist Range, span from the DC signal
(characterized by a frequency of 0) to half the sampling rate. This is based on the fundamental
sampling theorem derived by Nyquist:

f s ≥2∗B w

This is crucial as we transition to the Frequency Response Graphs for each of the
Transfer Functions.

Another crucial aspect to consider when designing filters in the Z-Domain is the
symmetry which exists for each of the zeroes and/or poles. When placing zeroes or poles, we
will often reflect them across the real axis such that there is a negative imaginary compliment to
Vargas 9

each term. This is done so that the transfer is comprised solely of positive terms as doing this
causes the product of complex conjugates, thus removing any imaginary terms in the transfer
function. For example:

In this Z-Domain graph, we can see that there exists two zero terms, both of which reflect
each other across the real axis (x-axis). By including the zero below the real axis, the transfer
function can now be simplified to an expression which does not include an imaginary
component:

( ) (
( e jω − j ) ( e jω + j )
) ( )
2 jω 2
e −1 z −1
b0 =b 0 2 jω
=b 0 2
( e jω+ 0.9 ) ( e jω −0.9 ) e −0.81 z −0.81

This also doesn’t affect our understanding of the Frequency Response Graphs, as we will
soon see, they only characterize the Transfer Function over the course of the input bandwidth,
and not the complete sampling frequency.

Frequency Response Graphs:

Since we can consider the sampling rate to be twice that of the bandwidth, we can
determine the bandwidth of the signal passed to simply be half of the sampling frequency. And
since a full rotation around the Z-Domain represents the entire sampling frequency, we often
determine our poles and zeros from 0 to π .
Vargas 10

Using a prior example of a transfer function, we can make a Gain vs Angle graph,
spanning from 0 to π radians. This graph depicts the response of the Transfer Function relative to
each of the frequencies that are passed into it. Using this tool, we can determine predictable
characteristics of the filters, allowing us to denote whether a filter is a Low Pass, High Pass,
Band Pass, Band Stop, etc.

For example, if given the following Transfer Function we can determine the Z-Domain
and Frequency Response Graph:

H ( z )=b 0 ( zz−1
+0.9 )

First we can denote that there lies a zero term at the z=1 point on the Z-Domain unit
circle and also a pole at the z=−0.9 point on the Z-Domain unit circle. The Z-Domain unit circle
would look like:
Vargas 11

We can use this to determine the Frequency Response graph by interpreting these plots
with respect to the 0 to π frequency bandwidth of the Frequency Response graph. We know that
the high point of the Frequency Response graph will be near the pole as this is when the gain of
the transfer function is at its highest (when the denominator of the TF is the smallest). This point
will be at the π radians location on the Frequency Response Graph. The zero term is at the 0
radians measurement on the Z-Domain unit circle, thus we can place the zero value at the 0
radians location on the x-axis of the Frequency Response Graph. Seeing that the lowest term is at
the origin, and the highest term is at the bandwidth of the input signal (bandwidth = π ) we can
draw a curve to properly depict the frequency response. From our generated graph, we can
denote that this transfer function depicts that of a High Pass Filter.

This is a very simple Transfer Function however, with only one pole and one zero.
Transfer Functions which include various zeros can have more interesting curves, since the
function contains various zero points, the frequency response may resemble more of a bouncing
graph.
Vargas 12

Considering the above Frequency Response Graph, we can gather that the Transfer
π
Function has zero terms at every instance of 45 degrees or radians up to the bandwidth of the
4
input signal. Due to the four include zero terms, we see a bouncing characteristic of the graph,
which steadily reduces in height as the frequency reaches the high end of the signals bandwidth.
This Frequency Response Graph can be more nuanced to depict accurately due to the various
peak values which occur between the zeros. The peaks which occur can have their heights
calculated by simply testing frequency values which fall between each of the zeroes, however
this may cause unintended effects when filtering various signals.

White Noise:

White noise can be used as a tool in order to experimentally understand the


characteristics of any transfer function. As by definition, white noise is a signal which is equally
comprised of every frequency in some general bandwidth, we should be able to pass it through
any signal in theory and generate some type of curve in order to graphically show the curves of
any filter.

In the above image, we see a graph depicting a blue and red signal, with the y-axis
depicting the amplitude of the signal, and the x-axis depicting the frequency bandwidth. We can
denote the blue signal as white noise as it is effectively a steady line which runs horizontally
across the graph, showing it is a signal which is comprised of every frequency in the bandwidth,
with each frequency having roughly equal magnitude. The red signal however, parallels the blue
signal until roughly the 100 Hz point where the signal begins to dip significantly. The red signal
Vargas 13

is the output signal of some filter which is being fed the white noise. From the graph we can
determine that the filter is a low pass filter which has a corner frequency around the 100 Hz
frequency. This graph is a representation of how we will be experimentally depicting the transfer
function of our filters using a randomized method in MATLAB similar to that of a white noise
signal.

Sampling Rate:

When designing filters, it is also important to understand the correlation between the
sampling rate and the characteristics of the filter. Filters should always be used relative to the
sampling frequency by which they were designed to filter, as the locations in which poles and
zeros are placed could not be effective in filtering the specific signals that you may want to be
filtering. For example, if we are attempting to design a filter made intentionally for cellular
communication which deals with sampling frequencies from 20Hz to 20kHz, we may want to
only keep the sampled signals which fall under the 7kHz frequency. For this we may design a
Low Pass Filter in order to keep only the most important signals. The Frequency Response
Graph may look something like this:

Notice how the 7kHz frequency is the beginning of our stop band for the Low Pass Filter.
This is largely because the filter was designed to have a zero value around the 7kHz frequency,
more specifically however, with 20kHz being the bandwidth (40kHz being the sampling rate) of
sampled signals. This is important however, because if we were to then increase the sampling
rate of the input signal and pass it through the same filter, we could actually make the filter
Vargas 14

effectively trivial and even ruin our requested signal. Notice the location of the 7kHz signal
when we increase the bandwidth of the sampled frequency to 480kHz:

Considering the relative location of the 7kHz signal with the new sampling rate. Since the
sampling rate is now twelve times the original sampling rate, the frequency which we originally
intended to be the beginning of the band stop region has now moved too far left and is no where
near the corner frequency of the filter. This is an example of over sampling a digital signals when
using digital filters.
Vargas 15

Lab:

Pole-Zero Diagrams w/ Magnitude, Phase Response, and Convergence

Filter with Two Zeroes and Poles Near the Unit Circle:

In order to understand the effects of Transfer Functions, we must begin by analyzing the
various responses of the digital filters through the use of the Z-Domain plot, the Magnitude
Response, Phase Response, and various different sampling frequencies in the time domain. For
this example, the transfer function was:

TF=b 0∗
( ( z−0.9)(z +0.9) )
(z +1)(z−1)

First, considering the Z-Domain plot (top left plot), we notice that there are two zeros,
one on either end of the bandwidth spectrum (running from 0 to π). This along with poles placed
π −π
at radians and radians shows that the peak magnitude of the transfer function should occur
2 2
towards the middle frequencies of the bandwidth. Moving to the next plot (top middle plot), we
see that our analysis of the Z-Domain is indeed accurate, as the two ends of the bandwidth do
indeed have the attenuated portions of the function, and the middle portion consisting of the
highest values in the transfer function. From this alone, we can conclude that this filter is a Band
Pass Filter, with the specific band being that of half the bandwidth.

Next, looking at the phase response plot (top right plot), we can see that the plot reduces
as the frequency approaches the bandwidth frequency. The rate of the phase response however is
Vargas 16

not constant, as we can see the rate at which the phase response drops accelerate towards the
middle band of the frequency sweep then returns to a similar rate as during the first third of the
bandwidth. This could be because of the characteristics of the filter being a band pass filter. The
phase response experiences the most rapid change during the peak of the transfer function.

Finally, considering the bottom three graphs, they represent the time domain response of
the filter using a simple cosine wave with various sampling frequencies. Considering the left plot
(bottom left plot), we can see that the original cosine wave is being sampled at the highest
sampling frequency of the three plots, and that the plot shows major attenuation of the signal, but
still maintains the oscillation of the input signal. The other two plots show that as the sampling
frequency is reduced for the input signal, there seems to be more distortion in the output signal.
This is especially true of the far right plot which has the most distortion of the three. The output
signal supports the assumption that the filter is a bandpass filter.

Filter with Various Zeros and Poles at Origin:

Now Considering this filter, we can determine a transfer function by simply looking at
the Z-Domain plot:

( ( (
( z− j ) ( z + j )( z−1 ) z − √ − j √ ))( z−( √22 + j √22 ))( z−( −2√ 2 − j √22 ))( z−(−2√2 + j √22 ))
)
2 2
2 2
TF=b 0∗ 7
z

( )
2 4
( z +1)(z−1)(z +1)
TF=b 0∗
z7
Vargas 17

We can see that the transfer function we derived does indeed match the parameters of the
Z-Domain unit circle. According to the Z-Domain unit circle, we can conclude that there should

be zeros at the origin and every 45 degrees until radian or 135 degrees. Looking at the
4
Magnitude Response Graph we can conclude that assertion is indeed true as we can see the
bouncing of each zero term being at a quarter, half, and three quarters of the bandwidth. Due to
there being no zero term at the π position, this is where the maximum of the Magnitude Response
is determined to be. Based on this shape, we can conclude that this filter is a High Pass Filter.

Due to the various other zero and pole terms which are included in this filter, the phase
response of this filter is very different compared to the previous Band Pass Filter. The phase
response of this filter shows a spiked pattern, reflecting the location of each of the zero terms.
The phase response reaches a peak of each spike at each zero term. Finally, by looking at the
time domain plots of the filter output in the bottom three plots, we can see that the filter
effectively attenuates the signal when the sampling rate is increased. This could be due to over
sampling the input signal and causing more of the input to be filtered.
Vargas 18

FIR Filters (Poles @ Origin with Changing Zero Locations)

For this portion of the lab, we will be testing to see the affects that various FIR Filters
have on white noise and on real audio signal. As we can see below, there are various filters which
were implemented with poles all at the origin and zero terms in various locations on the unit
circle. The filters include zeros at 30 degrees, 45 degrees, 90 degrees, 120 degrees, and 150
degrees.

The type of filter for each angle of zero term is as follows:

Angle (degrees) Type of Filter


30 High Pass
45 High Pass
90 Band Stop
120 Low Pass
150 Low Pass

Now, we can test our understanding of each of the filters by passing the white noise
signal into the filter. As we pass the white noise signal, the output signal of the filter should
reflect the magnitude response of each filter. In this portion, we will intentionally ignoring the
time domain response of the filter as we are more concerned with the magnitude response with
respect to each frequency passed and not necessarily the signal at any discrete time.
Vargas 19

Passing White Noise Through Digital Filter (Fs = 8000):

As we can see from the above plots, each of the magnitude response plots are directly
reflected in the plots on the bottom right. It is important to note that the magnitude response of
the white noise signal being passed into the filter represent the complete unit circle instead of just
the 0 to π bandwidth shown on the left plots. This is why the 30 degree High Pass filter has a
magnitude response graph which shows the 0 to π transfer function reflected spanning the π to 2π
portion of the response. This is most likely due to the output signal of the filter representing both
the bandwidth magnitude response and an alias of the magnitude response. From the above data
we can confirm that passing white noise through a filter will indeed produce an accurate
depiction of the transfer function’s magnitude response. We can also see that the signal is
sampled at 8kHz, which is why the frequency response graph reflects over the 4kHz frequency.

Passing Practical Audio Samples Through Digital Filter (Fs = 8000):

Now that we have tested a white noise signal through the filter, let us now consider the
effects that the filter would have on real audio signals. The two filters I have decided to test are
the 30 degree (High Pass) and the 120 degree (Low Pass) zero filters.
Vargas 20

Looking at the time domain response first of the Tibetan Bells audio file we can see that
much of the signal is attenuated. This is most likely due to how the audio file is largely
comprised of very low frequencies over the 4kHz bandwidth, with all the signal beyond the 4kHz
frequency being aliases of the 0 to π frequency range. This same observation is also reflected in
the Al Gore audio file, as Gore’s voice is largely comprised of low-end and mid-ranged
frequencies. We can see as his voice is passed through the filter, the only portion of the signal
which is not completely attenuated is the higher end of the 0 to π bandwidth. The 4kHz to 8kHz
portion of the plot reflects that of the 0Hz to 4kHz due to aliasing, just like in the Tibetan Bells
audio file.

Interestingly, we can see an opposite output of the Tibetan Bells signal after being passed
through the Low Pass Filter. As the Tibetan Bells audio file is passed through the Low Pass
Filter, we can see that in the time domain response plot, practically the entire signal has been
passed through the filter, since an overwhelming majority of the frequencies in the Tibetan Bell’s
audio file exist in the low-end frequency range. Similarly, the Gore audio file shows major
attenuation closer to the 4kHz frequency point as the filter passes more of the low-end and mid-
ranged frequencies in his voice.

IIR Filters (Zeros @ Origin with Changing Pole Locations)

Similarly to the FIR Filters, we will be testing various filters with white noise signals and
practical audio samples. First, we will denote the type of filter for each of the Z-Domain plots:
Vargas 21

Angle (Degrees) Pole Radii Type of Filter


30 0.95 Band Pass (π/6)
30 0.7 Band Pass or Low Pass (0 to
π/6)
60 0.95 Band Pass (π/3)
60 0.7 Band Pass (π/4 to 2π/5)
150 0.95 Band Pass (5π/6)
150 0.7 Band Pass (5π/6 to π)

Similarly to the FIR filters, we will mainly be concerned with the magnitude response in
the frequency domain. This will help us understand what portions of the white noise signal are
being passed through each of the filters.

As we can see from the magnitude response of each of the filters, the output of the filter
with the white noise signal as an input generates a practically identical plot of the left magnitude
responses. The only major difference between the response of the white noise signal through the
filter and the magnitude response of the filters. Other than the similarity between the two
depictions of the filters, we also notice the influence that the pole radius has on the
characteristics of the transfer functions. We can see that as the pole is further from the unit
circle, the band in which is passed by the filter gets greatly increased. For example, if we
compare the 30 degree filter considering both the 0.95 and the 0.7 radius magnitude responses,
we can conclude that the 0.95 radius filter has a far thinner band that is passed, while 0.7 has a
much broader/wider band of frequencies which are passed by the filter.
Vargas 22

Now that we have considered the filters and their magnitude response using a white noise
signal being passed through, let us now compare the same practical audio sample with the same
pole angles, but different radius measurements.

Considering the Tibetan Bell’s audio file, we can see that the signal with the 0.95 pole
radius had much more of the input signal attenuated unlike the one with the 0.7 pole radius. This
supports our earlier claim that the pole radius is correlated to the magnitude of signal which is
passed through the filter. Both time domain and the frequency domain responses reflect that there
is far greater signal attenuation with the poles at a 0.95 radius. If we look at the Gore audio file,
we will also come to the same conclusion, we can see that there is far greater signal attenuation
when the pole radius is closer to the unit circle, and far less when the pole is further from the
radius. We can see that both the time domain and the frequency domain plots reflect this trend in
signal attenuation. Something that makes the Gore audio more interesting than the Tibetan Bell’s
audio file however, is that due to the more diverse range of frequencies in the Gore audio file, we
can see a more nuanced trend in the band of frequencies passed by the filter. With the 0.95 pole
radius, the band passed by the filter is much smaller than that of the 0.7 pole radius filter. It is
safe to conclude that there is a direct correlation between pole radius and bandpass region
bandwidth.
Vargas 23

Error Analysis:

In conclusion, we can claim that the findings of the report support our theoretical
understanding of digital filters in the Z-Domain, of our understanding of transfer functions, and
of the defining characteristics of FIR and IIR filters. The largest limitation in our experiments
could very well be the quality of audio signals that we used to conduct our digital filtering
methods on, or in the accuracy of our MATLAB scripts. Since some of the audio files we use to
conduct our experiments on have large levels of distortion due to poor recording methods, it
makes it difficult to properly understand whether some samples of the audio files are meaningful
audio data, or residual noise. Also, since I am still largely learning the MATLAB language, I
very well could have made mistakes in the scripts used to gather lab data. Despite these potential
limitations, we were able to confirm our general knowledge of the Z-Domain and Digital
Filtering methods.

You might also like