Applied Signal Processing,
Laboratory Project:
INVERSE FILTERING
Magnus Lundberg, Patrik Bohlin, Tomas McKelvey
September, 2004
1 Administrative details
To be able to log in on the computers in the lab, you need to register your group. This is
done on the course web page (http://www.s2.chalmers.se/undergraduate/courses/ess145/).
Each lab position has two computers. To use the computers you need to login. A sepa-
rate account exists for each computer. The computers are named according to the yellow
tags above the computers, e.g. platsxx where xx is a number. Note that computers plats
1 username plats01. The password to the computers are platsxxs2 where xx is the same
number as above.
To save files between sessions we recommend to use the scp.exe utility (secure copy)
to connect to your student account and transfer files. Alternatively you can use the
Map network drive utility under Windows to connect to your student account. If you
need extra instructions on how to connect to your student account contact your student
account administrator (e.g. Medic Helpesk). If you have a usb-memorystick you can use
it since the usb port is easily accessible on the front of the computers in the lab.
2 Introduction
In many practical scenarios including digital communications and image restoration,
we measure a desired signal that has been passed through a linear filter. In order to
1
simplify further processing or to improve the appearance it is often desirable to restore
the original signal as much as possible. When using a linear filter, this operation is often
called inverse filtering or equalization. In this lab we are to design an acoustic signaling
system, transferring text messaging between two computers. The acoustic channel acts
as a filter and the main task of this lab is to invert the channel in order to transmit as
many bits per second as possible through the channel.
3 System Description
As this lab is not part of a communications course it will not be assumed that you have
any particular knowledge regarding communication system design. Those who are inter-
ested in how the underlying system works and how receivers are designed, are encouraged
to take the digital communications course. Only discrete-time communication system
are considered. We both transmit and receive discrete-time signals. The information
carrying bits are incorporated into the transmitted sequence. In our basic system each
sample represents two bits. To send 00, 10, 01, and 11 we transmit a sample that is
-1, -1/3, 1/3 and 1, respectively. If we for instance want to transmit the bit-sequence
0100110110, we would submit the sequence, s[k] = {−1/3, −1, 1, −1/3, 1/3}. In order
to control the number of bits per second that we transmit(the so called throughput), we
can adjust the number of samples per second that is transmitted and received.
The acoustic channel acts as a linear filter and distorts the signal. This effect carries
over to our sampled discrete-time communication system. Our transmitted sequence will
be filtered by a discrete-time Linear and Time-Invariant system with impulse response
h[k]. Further, we will also receive some noise, n[k], caused by external disturbances and
non-perfectness of the underlying system. In conclusion we receive a signal, r[k], that
can be modeled as
r[k] = s[k] ∗ h[k] + n[k]. (1)
Here ∗ denotes convolution. Our discrete-time communication system can also be seen
schematically in Figure 1.
s[k] r[k]
h[k] +
n[k]
Figure 1: Discrete-time communication model
To secure reliable communication, an inverse filter that reverses the distortion of the
channel is desirable. Ideally, we would like to design an inverting filter with impulse
response f [k] such that
r[k] ∗ f [k] ≈ s[k] (2)
2
For low signaling rates (samples per second), the impulse response h[k] will be quite short
and relatively easy to invert, while if we increase the transmission rate, the channel will
become longer, and more difficult to invert.
4 A Least-Squares Inverse Filtering Approach
We assume that the channel impulse response, h[k] is known and has L filter taps
h[k], k = 0, 1, ..., L − 1. You will be provided with a Matlab function(receive 04.m
that estimates this for you. Further, it is assumed that we want to design an inverting
filter of length M . For simplicity, we disregard the noise, n[k], and only try to invert
the convolution. In a sense the task is to find a filter with impulse response f [k] such
that s[k] ∗ h[k] ∗ f [k] ≈ s[k]. In general, increased performance can often be achieved if
we allow ourselves to restore a delayed version of the desired signal. In our application,
this only implies that the information will arrive with a delay of a few samples instead
of instantly. We get the following equivalent requirements on the impulse response f [k]:
s[k] ∗ h[k] ∗ f [k] ≈ s[k − k0 ] (3)
By defining the overall filter response, q[k], as q[k] = h[k] ∗ f [k], we obtain the equivalent
requirement
q[k] = h[k] ∗ f [k] ≈ δ[k − k0 ]. (4)
As indicated, f [k] should render a q[k] = δ[k − k0 ]. Unfortunately this is not possible to
achieve. Assuming that the channel h[k] has L taps and that the filter we are to design
have M taps, the overall filter response q[k] will have M +L−1 samples that are different
from zero. As the filter has M filter taps it is only possible, by choosing these taps, to
force the M samples of q[k] to be exactly that of δ[k − k0 ], while the other L − 1 samples
can become large. As an alternative we want to find an f [k] such that q[k] becomes “as
close” to δ[k − k0 ] as possible. A common approach is to use the Euclidean distance.
The distance between q[k] and δ[k − k0 ] is defined as (q[k] − δ[k − k0 ])2 . In order to
P
find the best inverting filter, we find the f [k] that make q[k] be as close to δ[k − k 0 ] as
possible, i.e., we find the least-squares inverting filter, fls [k], as:
∞
X
fls [k] = arg min (h[k] ∗ f [k] − δ[k − k0 ])2 . (5)
f
k=−∞
As q[k] will only have M + L − 1 samples that differ from zero then (5) becomes,
MX
+L−2
fls [k] = arg min (h[k] ∗ f [k] − δ[k − k0 ])2 . (6)
f
k=0
We will later derive an alternative formulation, using linear algebra, in order to find f ls .
3
5 Tasks
Exercise 1: In this first exercise you will familiarize yourselves with the communica-
tion system. At your disposal you have four supplied Matlab functions, send 04.m,
receive 04.m, code.m and decode.m. To find out more about these functions use the
help command. One computer will act as the transmitter, using the code and send 04
command, and one computer is used to receive 04 and decode the message. In order
to have a reasonable signal level the system first needs to be calibrated. A graph appears
when the command receive 04 which shows the amplitude of the received signal (top
graph) and the demodulated baseband signal (bottom graph). The signal level is OK if
the peak-values of the top graph is a little less than 1. You can adjust the level both on the
sending computer by changing the volume control of the external speaker amplifier or on
the receiver side by changing the microphone gain using the properties of the Windows
XP audio controller.
Use the supplied functions and try to send a short message over the acoustic channel.
When first trying out the system, choose a low signaling rate (a low number of samples
per second), around 30 should be OK. What does the channel look like? Can we obtain
the submitted discrete-time sequence directly?
As the number of bits per sample is fixed, in order to increase the throughput we will
have to increase the signaling rate. At higher rates it is necessary to equalize the channel
to avoid errors. To implement a function that generates the least-squares inverting filter
we will go through a few smaller steps. First we want to describe the convolution as
a matrix multiplication. For notation, we consider all signals to be stored as column
vectors. The convolution is given by
∞
X M
X −1
q[k] = h[k − l]f [l] = h[k − l]f [l], (7)
l=−∞ l=0
where the last equality stems from the fact that f [l] = 0 for l < 0 and l > M −1. Further
the convolution only have M + L − 1 samples that differ from zero, q[0], q[1], ..., q[M +
L − 2]. We get
M
X −1
q[0] = h[−l]f [l] (8)
l=0
M
X −1
q[1] = h[1 − l]f [l]
l=0
..
.
M
X −1
q[M + L − 2] = h[(M + L − 2) − l]f [l]
l=0
4
It is now possible to describe the convolution as a matrix multiplication, such that
q[0] f [0]
q[1}
f [1]
q= .. =H · .. = h ∗ f. (9)
. .
q[M + L − 2] f [M − 1]
Here the matrix H involves samples of the impulse response h and is of size M +L−1×M .
Exercise 2: Write a Matlab function H=convmat(h,M) that produces a matrix H such
that H·f=conv(h,f). Here M is the length of f and · means matrix multiplication.
Please make sure that the signals h and f representing q[k], k = 0, 1, ..., L − 1 and
f [k], k = 0, 1, ..., M − 1 are stored as column vectors.
Now recall from (4) that the ideal overall response, [q[0], q[1], ..., q[M + L − 2]] T =
[0, ..., 0, 1, 0, ..., ]T . Here the one is placed at the k0 + 1’th position (a one in the first
position implies no delay). Thus to solve for f we have
0
.
..
0
H ·f =
1
(10)
0
..
.
0
Here H is of size (M + L − 1 × M ), f is of size (M × 1), and the vector on the right hand
side representing the shifted delta function is of size (M + L − 1) × 1. We see that this
is an over-determined system of linear equations. Hence, as mentioned before, it is not
possible to find an f such the equality in (10) is fulfilled. Instead we find the solution
that minimize the error in the least squares sense. It can be shown that the solution is
given by
0
.
..
0
T −1 T
fls = (H H) H 1
(11)
0
..
.
0
Even though the solution is analytically given by (11), a numerically more robust solution
can be find by using the mldivide command.
Exercise 3: Write a Matlab function f=lsimp(h,M,k0), that produces the impulse
response of the least-squares inverting filter. The function should have the channel, h,
5
the number filter taps M , and the number of delays k0 as inputs. Hint: help mldivide
will give you help on how to solve an over-determined system of linear equations in
matlab.
Exercise 4: Now incorporate your inverse filter in the receiver structure. The channel
h[k] will be available to you through the receive 04.m function. Try to optimize the
overall throughput of the communication system while maintaining transmission quality.
This is achieved by adjusting the number of samples per second, the length of the inverting
filter, M , and the number of delays k0 . Try to understand the reasons to the limitations
of the the system. How can the quality of the communication system be measured? Try
to define a reasonable quantitative measure and use it.
Exercise 5 (Optional): In general we are not restricted to transmit two bits(four levels)
per sample. In the send 04.m and receive 04.m commands it is possible to adjust the
number of bits per samples, see the help files. Try to optimize the overall performance
of the communication system by adjusting the number bits per sample, the number of
samples per second, the number of delays k0 and choice of equalizer. Note that the
number of levels increases exponentially with number of bits per sample. As the number
of levels increase, the system gets more sensitive to errors and imperfect equalization.
For hints on how to write an acceptable lab report, look at the note published on the
course web page (under the Lab project section) on this subject.