0% found this document useful (0 votes)
43 views38 pages

Transmitter Simulink Study

This document provides an overview of a communications system transmitter simulation using Simulink. It describes the key components of a transmitter - bit to symbol mapping, constellation mapping, pulse shaping, and upconversion. It outlines the steps to set up a basic Simulink model of a transmitter, including adding an input source block to provide binary data, connecting it to a scope block to view the output, and adjusting the block parameters. The objective is to understand the purpose and operation of each transmitter component through interactive simulation.

Uploaded by

Lucky Asr Awais
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)
43 views38 pages

Transmitter Simulink Study

This document provides an overview of a communications system transmitter simulation using Simulink. It describes the key components of a transmitter - bit to symbol mapping, constellation mapping, pulse shaping, and upconversion. It outlines the steps to set up a basic Simulink model of a transmitter, including adding an input source block to provide binary data, connecting it to a scope block to view the output, and adjusting the block parameters. The objective is to understand the purpose and operation of each transmitter component through interactive simulation.

Uploaded by

Lucky Asr Awais
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/ 38

Protected: Transmitter

Simulink Study
Transmitter Simulink Study

Objective

In this lab you will learn how a basic single-link communications system
operates. This lab focuses on high-level simulation of the transmitter with
Simulink, to give you a feel for what operations are required and what signals
are involved. After this lab, you should understand the operation and purpose
of

 Bit to symbol mapping


 Constellation diagrams
 Pulse shaping filters
 Up conversion

Pre-lab

For the pre-lab, just read through this lab outline so that you have an idea of
what you will be doing. Especially make sure you understand the background
section.

Background

The figure below depicts a basic block diagram of a communications system:


The purpose of a general communications link is to transmit signals from one
place to another. If the input signals are analog, such as audio speech, they
must be first converted to a digital signal with an A/D converter. To ensure
reliable and secure transmission of the signals, digital signals are encoded
using the coding block. The modulation block converts these signals to a form
suited for the channel (wireless, telephone lines, optical fiber, etc.). At the
receiver, the demodulation block converts the signals back to a digital form,
after which the binary information can be decoded and converted back to
analog.

This semester, we will focus on the modulation and demodulation blocks,


which I believe will best reinforce your understanding of DSP programming
and communications theory. To keep the lab simple, we will study and
implement “uncoded” transmission/reception, which means that the
encoding/decoding blocks are trivial pass-throughs. Also, we assume that
input and output information is in digital form, so that not much time need be
spent on the A/D and D/A blocks.

Transmitter

For this lab, we are concerned with understanding the purpose and operation
of the transmitter, whose job is to take an input binary stream and convert this
to a form suitable for transmission through a physical channel. The figure
below depicts the basic blocks that are involved. For simplicity, phasor domain
(complex baseband) processing is assumed. Each of the operations will now
be explained in detail
Symbol Mapping

With sufficient signal-to-noise ratio (SNR), we can typically transmit more than
two different signals through a communications channel and detect which
signal was sent on the other side. For this reason, groups of multiple bits are
mapped to symbols, where for a group of N bits we require 2N symbols
denoted sk, which are usually just represented as integers.

Constellation (I/Q) Mapping

Each type of communications channel has a range of “nice frequencies”


where propagation characteristics are good. Also, we may want to support
multiple users and services on the same channel by dividing users in different
frequency bands (called frequency division multiplexing). For this reason,
information is usually transmitted by modulating a carrier (sine wave) at some
prescribed frequency. For most channels and systems, information can be
conveyed using both the phase and amplitude of the signal. A convenient way
to exploit these two dimensions is to represent transmitted signals in the
complex plane in terms of the I=in-phase (real part) and Q=quadrature
(imaginary part) components.

The I/Q mapping block takes each symbol sk and maps it to a corresponding
complex baseband value Ck in the complex plane. These values are usually
chosen to be as different (or far apart) as possible so that at the receiver we
can discern as clearly as possible what was transmitted. A nice way to
represent the mapping of symbols to complex baseband I/Q values is with
a constellation diagram. The figure below depicts a few different constellations
ranging from BPSK (that has only 2 symbols) to 16QAM (16 symbols).
Pulse-Shaping

If we simply transmit Ck as rectangular pulses (like what would be present in a


digital circuit), we obtain a sinc-like spectrum, which is fairly wide (decays
slowly with increasing frequency). For applications like wireless, where the
bandwidth must be limited, a sinc spectrum is very undesirable. Instead, we
can map each symbol to a pulse with a desired shape (and more confined
spectrum) and transmit the superposition of these pulses in time.

Pulse-shaping is accomplished by converting the symbol stream to a train of


pulses that are 1 sample wide and separated by the desired symbol period.
By passing this pulse train through a filter that has the desired frequency
response of our pulse, we obtain a set of shifted and superimposed pulses
that are weighted by the desired I/Q values of the symbols. The resulting
spectrum typically is much more confined than square pulses, but conveys the
same information.

Up-conversion

Since we often do not transmit signals at baseband, we need to shift the


resulting complex baseband waveform C[n] to a higher frequency, which is
accomplished by the final multiplication block. Note here that since we use the
sample number n in the exponential, f is a discrete carrier frequency on the
range from 0 to 0.5. All practical channels support only real signals, so the
final block takes the real part of the complex signal before physical
transmission.

Real Processing

Although the complex baseband (phasor) representation of signals is often


more compact, it is usually computationally more efficient to only perform DSP
operations on real-valued quantities. For this reason, for actual
implementation, we would likely implement the transmit chain using the form
below:
Note that this is mathematically identical to the previous complex case, but is
more efficient to implement.

Receiver

Although not drawn here, you should keep in mind that although the signal is
now well-suited for transmission through the channel, the receiver will now
need to undo all of these operations. But, if you understand the transmitter
well enough, you can imagine what the receiver will need to do.

Procedure

To complete this lab, you need access to a computer with MATLAB and
Simulink. Simulink will allow us to incrementally construct the transmitter,
where we can probe signals along the way. I hope this will help you
understand how the whole transmitter works and what the signals inside are
supposed to look like. This intuition will be invaluable when you are doing later
labs to know whether things are operating correctly or not!

Starting and Navigating Simulink

Simulink is a graphical environment for constructing and simulating block


diagrams, which makes it well suited for understanding the communications
system to be developed in this lab. Although Simulink can simulate both
continuous and discrete systems, we will focus on the discrete case, since
DSP operates in this regime. For this reason, the sample time should always
be 1, meaning that time units are in samples, frequency is discrete frequency
(cycles per sample), etc.

For this particular lab, you will need to unzip the custom DSP blocks
in dsp_lab.zip to your /MATLABxxx/toolbox/matlab directory, which should
create a new directory there called dsp_lab.

You can start Simulink by simply typing simulink in the MATLAB command
window. Then choose “Simulink -> Blank Model” as showed in the picture
below:

A blank window will appear where you can build your model. Click
“Library”, you should see a menu that gives you a palette of blocks that can
be used to construct and simulate block diagrams. There is also a “DSP
Blocks” category which is a set of blocks that have been developed to simplify
these labs. Depend on different operating system, there may be a message
show to ask you to “fix the problem to transfer old version files into new
version file, please click the message to fix the problem by choosing “keep
the old version” option.
Starting Simple

First, in the palette go to DSP Blocks->Sources/Sinks and drag an Input


Stream block to your design. Your design should look like

The input stream block reads binary data from a MATLAB data file that has a
single vector called data containing 0s and 1s. As you can see, the Simulink
blocks often have useful information printed on them. Here you can see that
the block will read data from a file called data.mat, that the bit period is 10
(samples), and that the output width (how many bits are presented at the
output per period) is 1.
To change the parameters of the block, double click on it, and you should see
the following menu. Modify the parameters as shown.

Next, grab the file rand.mat and place it in the same directory as you saved
your model (.mdl) file. This file just contains 10000 random bits. Note that you
need to change the working directory of MATLAB to be your project directory,
or you will probably get errors.

In order to see something, we need to connect a sink to the source block, so


grab the block Simulink->Sinks->Scope and place this in your design.
Connect the scope to the output of your source by dragging between the two
terminals. Alternately, you can select the source block, and then while
pressing [CTRL], click on the destination block. Your design should look
something like the picture below:
To see the scope, double click on it, and a scope display window will open:

To modify the parameters of the scope, click on the the little icon as depicted
above. The important parameter in the “General” tab is the Decimation or
Sample Time. For most of the lab, we will do discrete simulations, so leave
this as Decimation of 1 sample. Note here you can increase the number of
axes (or number of inputs to the oscilloscope) when multiple signals must be
plotted. The time range allows you to set how many samples are shown at
once. For “Data History” we will uncheck the box “Limit Data Points” so that all
samples are stored. For very long simulations, you may need to limit the
samples, however.

Finally, we need to set some global parameters for the simulation. Go to the
menu item Simulation->Configuration Parameters.... You will see a
window open up with lots of options. Just set the parameters to the values
shown below:
We are indicating that it is a discrete-time simulation and we want to run for
100 samples. Note that there is also a field where you can change the number
of samples at the top of your model window. Finally simulate the design by

clicking the icon or going to Simulate->Start. You should see the output

as shown below, which just shows that you are getting your random bits, with
one new bit per 10 sample period!

Before leaving this section, save your simple design (maybe as simple1.mdl).

BPSK Symbols
We will start with BPSK modulation, since it only requires us to consider the
in-phase (I) component. Save your simple design under a new name (say
bpsk1.mdl), before modifying the design.

For BPSK, the binary bits 0 and 1 map trivially to s0 and s1 which then need to
map to I values of -1 and 1, respectively. For this we need a couple more
blocks from the DSP Blockslibrary: a bit to symbol mapper and a lookup table.
Modify your design so it looks like the diagram below:

For this case, the symbol mapper block doesn’t really do anything, since it just
maps bit 0 to symbol index 0, and bit 1 to symbol index 1, but this is the same
as just using the bit value. In general, however, the symbol mapper takes a
vector of N bits at its input and maps them to the indices 0 to 2N-1 (LSB first),
which will be useful for larger constellations.

Double click on the look-up table block and you will see the single
parameter Table, which is a vector that contains the outputs you need to
generate for each of the symbols. For example, a value of [-1 -0.5 0.5 1]
would map 0 to -1, 1 to -0.5, 2 to 0.5, and 3 to 1. For BPSK we just need 0
and 1 to map to -1 and 1, so set Table to [-1 1].

Now resimulate, and you should see something like the following:
When you’re done, save your design.

Rectangular Pulses and PSD

Next, let’s look at the power spectral density (PSD) of the BPSK signal we are
generating. For a simple communications system, we might consider just
sending rectangular pulses like this without any pulse shaping. Let’s see what
the PSD looks like.

Save your design under the name bpsk2.mdl for this next segment. Add the
PSD graph from the DSP Blocks->Sources/Sinks menu, remove the scope,
and connect the PSD graph in its place.

The PSD graph operates by taking FFTs of slices of the input stream and
averaging these results, to generally yield a smooth plot showing the
spectrum of the signals. If you double click on the block, you will see a
number of parameters. The not-so-obvious ones are as follows:

PARAMETER MEANING
Length of Buffer Size of the buffer that stores the samples that are operated on by the FFT.

The size of the FFT that is computed. Can be bigger or smaller than the buffer length. If it

Number of points is smaller, FFTs are computed on segments of the buffer and the results are averaged. If

for fft the FFT size is bigger than the buffer, the buffer is zero padded and a single FFT is

computed.

This controls how many new samples need to come in before a new plot is generated. This
Plot after how
also controls the degree of power averaging, because for each plot, the results are averaged
many samples
with the existing spectrum.

I have found that I get a reasonably smooth curve with the following
parameters:
We need many more samples to generate a decent PSD, so increase the
maximum simulation time to something like 10000, and then simulate your
model. (Note: the maximum simulation time can be changed in Simulation-

>Configuration Parameters or by changing the number next to the icon.

When interpreting your PSD, recall that we have one symbol per 10 samples,
or a discrete symbol frequency of 0.1. Efficient modulation can convey this
information using a discrete (one-sided) bandwidth around 0.05. Look at your
plot. How efficient does the modulation look?

Spectrally-Efficient Pulse Shaping

Now let’s try introducing pulse shaping to see if this improves our spectral
shape. Save your previous design and then save under a new file
called bpsk3.mdl (I will stop reminding you to do this, but it is always good
practice!). You will need the pulse train block from the DSP Blocks-
>Conversions library and the RC Filter block from the DSP Blocks-
>Filterslibrary. Your design should look like the following one:
The pulse train block samples its input once per period and generates just a
single unit impulse (be sure T is set to your symbol period of 10!). Feeding this
into the pulse-shaping filter then generates a series of pulses. We will use the
raised cosine (RC) filter in this lab which is used extensively in
communications systems, where the name raised cosine refers to the shape
of the roll-off in the frequency domain (as plotted on the block).

A key parameter of the filter is the roll-off beta that controls the bandwidth of
the filter. Setting beta=0 results in a frequency response that is an ideal
square shape in the frequency domain. Although this would give the most
efficient use of spectrum, the time response (sinc) of the filter is very wide,
requiring many filter taps. For beta=1 we have a pure cosine shape in the
frequency domain, which has a short time response, but is also not spectrally
efficient. Beta values in between are often used as a compromise between the
filter length and the spectral efficiency. Try playing with different values
of beta and the number of taps and see what happens to the plotted
response.

After you try a few values, set the parameters as depicted below:
Note that the Hamming Window option refers to whether the time-domain
response is multiplied by the hamming window. This should be used when the
number of filter taps is small compared to the length of the impulse response
of the filter. For now, just enable it.

Now, rerun your simulation and look at the PSD. How does it compare to the
one with rectangular pulses? Note: you may need to increase the dB range to
see the plot better.

Decoding Pulses

You may have noticed on the time waveform shown on the PSD window for
pulse shaping that your transmit waveform now looks modified. To compare
the pulses for rectangular and pulse-shaped waveforms, place a scope
element in your design as shown below. To make the comparison easier, the
extra delay added by the filter (64 samples) is compensated using the delay
block (found under Simulink->Discrete). Also, I had to change the
oscilloscope to have two axes in the parameters to get two inputs.
Run the simulation (you will need to reduce the number of samples to
something like 1000). What do you notice? It should be clear how you would
decode rectangular pulses, such as just sampling them in the middle. How do
you decode the RC pulses without getting errors from to the wavy filter
response?

It turns out that the RC filter is in a class of filters that have a zero inter-
symbol-interference (ISI) property, as long as the waveform is sampled at the
optimal point. This occurs because the RC time waveform has nulls (goes
through zero) at any integer multiple of the symbol period, as depicted below:
Since the response goes to zero at all integer symbol times, it means if we
have multiple pulses that are separated by the sample time, they do not
interfere at these zero points when superimposed. So, unlike the rectangular
pulses that we could sample anywhere with a symbol period, with the RC
pulses, we have to sample these optimal sample points where there is no ISI.

To show that this actually works, lets do a simple experiment where we


“decode” the RC pulses with a sample and hold block. Change your design so
that it looks like this one:

Here, the sampler block was taken from the DSP Blocks->Data
Conversion library. The multiplexer (the solid bar) combines two signals into a
vector signal, which is in theSimulink->Signal Routing library. This is useful
here to make the two signals appear on the same plot (in different colors). The
sampler block just samples the input waveform at regular intervals (in this
case the symbol period) after some initial delay (offset). Here the offset of 64
was chosen since it is know that this is how much delay is imposed by the
filter. After running the simulation, you should see two plots on top, where one
is the incoming waveform, and the other is the sampled (and held) waveform.
The bottom plot shows your original digital stream. If everything is set up right,
this should convince you that perfect decoding of the signal is possible.

Although we can hard code the known delay in the transmitter like this, what
do you think we do at the receiver? The receiver doesn’t know exactly where
these ideal sample points are, so what can it do? We will learn in a later lab
that a synchronization element called a PLL will be used to find and track
these points.

Up-Conversion

As stated before, usually we will not operate at baseband, but need to have
our signal centered about some carrier frequency. Modify your BPSK
transmitter as depicted below:

In a typical digital up-converter, the required carrier frequency requires a


much higher sampling rate than what is required by the baseband processing
blocks (like you have considered so far). Usually, a real up-converter
oversamples (interpolates) the baseband signals at a higher rate before
multiplying by the carrier. For simplicity in our case, we will just change the
sample rate of all the baseband blocks. As you can see I set the symbol
period to 50 samples (also in the filter block!).

The sine wave function was taken from the Simulink->Math


Operations library, and for the frequency use 2*pi*0.1 rad/sample (discrete
frequency is 0.1). For our purposes, choose the time-based sine wave and
for time (t) choose the simulation time.

After re-simulating, you should get something like the following picture:

In the top plot, you see the baseband signal (yellow), the up-converted signal
(purple), and the unmodulated sine wave (blue). As you can see, with BPSK
the signal envelope follows the baseband signal and the phase is either in-
phase with the carrier or 180 degrees out of phase. With other modulations,
other phase relationships with the carrier are also possible.

QPSK Transmitter
Now you are ready to try modifying your design on your own. In this last step,
you need to expand your design to do QPSK modulation by adding a parallel
branch for the quadrature (Q) component. Some hints:

1. You will need to change the input source block to have an output width
of 2, so that you get symbols 0-3.
2. You need to replace the real 1D lookup table with a complex one. For
the table, I recommend using [1 j -1 -j], since this will be easier to check
than the [1+j, -1+j ...] version.
3. There is a block in the math library for splitting a complex value into
real and imaginary parts.
4. Get cos(.) and -sin(.) functions by changing the phase of the sine
generator block.

Once you have it put together, simulate it like you did with the last BPSK
transmitter with a scope. For example, you could have a scope with 3 axes
showing the following information:

1. The up-converted signal multiplied with the cos() carrier, and the
unmodulated cos() carrier.
2. Real part of pulse train (delayed)
3. Imaginary part of pulse train (delayed)

You should be able to tell if the modulated signals look correct by comparing
the phase of your modulated carrier to the unmodulated carrier.

Lab Write Up

For the write-up, provide the following things:

 Explain in one or two paragraphs what you learned about


communications systems that you didn’t know before.
 Show a picture of your final QPSK transmitter. Explain briefly what the
different blocks are for. Explain how you checked that it was working
correctly. A plot of the output showing important signals would be very
helpful.
 Explain why we do pulse-shaping in communications systems, rather
than just sending rectangular pulses.
 Tell why synchronization (e.g. sampling the received signal at the right
place) is critical in a communications system that uses pulse shaping.
 Describe any difficulties you experienced in getting your design to work
and how you fixed these problems. I will be really surprised if
everything worked perfectly!
Protected: Receiver
Simulink Study
Receiver Simulink Study

Objective

Building on your knowledge of the transmitter system, in this lab you will study the
operation of the receiver subsystem using Simulink. Combined with your
transmitter, this will form a complete communications chain. This lab will also
teach you why proper synchronization is a critical component of a practical
communications system. You will become acquainted with the following
operations in the receiver:

——Down conversion
——Matched filtering
——Decision rules
——Carrier and symbol timing recovery (synchronization)

Pre-lab

Again, for the pre-lab, just read through this lab outline so that you have an idea of
what you will be doing. Especially make sure you understand the background
section.

Background
In the last lab, we created a transmitter that took binary information, converted
this to symbols, generated pulses that were weighted by the complex baseband
symbol weights, and up-converted this to a carrier frequency. The receiver must
now “undo” these operations, or downconvert back to baseband, sample at the
appropriate times, and make a decision which symbols were transmitted. The
figure below shows a diagram of a generic receiver chain:

For simplicity, the chain has been drawn using complex signals, and realize that for
real processing, we would just have two branches present for I and Q processing.
The basic operation of the receiver chain is

 Multiply by the conjugate of the carrier to shift the signal back to baseband
(zero center frequency).
 Apply a (matched) filter to remove the image at double the carrier
frequency.
 Sample at the optimal points to obtain estimates of I/Q symbol weights.
 Based on these samples, make a decision which symbol was transmitted.
 Covert symbols back to bits.

Each of blocks is described in more detail below:

Multiply Block

In the transmitter the signal was shifted up to a convenient


transmit frequency suitable for the physical channel. In the
receiver, we need to shift this back to baseband (zero center
frequency), which is accomplished by multiplying by the
conjugate of the carrier used for up-conversion.

For a real input signal, we have identical images at


frequency f and -f. The multiply operation shifts the one at f
to 0, but shifts the other image to -2f, which is removed by
subsequent filtering.

Matched Filter

In a simple communications link, we could just use any low pass filter with a
suitable passband to remove the doubled frequency component from the multiply
operation, yielding an estimate of the baseband signal. In real systems where noise
is present, this filter should be designed to provide optimal signal-to-noise ratio. It
can be shown mathematically that the optimal operation is to use a filter that is
identical to the transmit pulse-shaping filter, hence the name “matched filter.”

We will see later in the lab that we can get a raised cosine response having the
desirable zero-ISI property by using a root raised cosine filter in the transmit and
receive. In this way, the cascaded response is a raised cosine filter and both
transmit and receive have identical (matched) filters.

Sampler

The job of the sample block is to sample the receive waveform at the optimal
points to get an estimate of the original I/Q symbol weights that were generated in
the transmitter. In simulation it is easy to compute the delay required for optimal
sampling. In a real communications system, the sampler block will need to be told
when to sample by the synchronization blocks.

Decision

Due to noise, the I/Q symbol weight estimates will not be exactly what we set in
transmit system. The decision block needs to decide what symbol was most likely
transmitted based on the received I/Q sample. For lower-order modulation, this is
usually just comparing the value to a threshold (like 0).
Symbols to Bits

This operation is just the reverse of what we did in the transmitter. We take a single
symbol and map this to multiple bits.

Carrier Recovery

Unless we run a long cable from the transmitter to receiver having the carrier
frequency, or use some kind of ultra-stable atomic clock, the two carriers at
transmit and receive will not be identical. In wireless RF systems, the offset can
typically be 10s to 100s of kHz, which will create significant error in our receiver
chain.

To remove carrier offset, we can recover the carrier by removing the modulation
from y[n] and locking an oscillator to this signal. Alternatively, we can put a “pilot
tone” in the transmit signal that is an unmodulated carrier whose phase and
frequency are directly related to the modulated transmit signal. By isolating this
carrier, we can easily generate the carrier for the modulated signal as well.

Carrier recovery usually uses a phase-locked loop (PLL) which can be thought of as
a tracking algorithm for sinusoidal signals.

Symbol Timing Recovery

In simulation, we can compute how much delay is in our system and sample at
exactly the right times to recover the transmitted symbols. In a real system, the
symbol clocks will not be exactly the same at transmit and receive. Also, we do not
know how much relative delay there is between transmit and receive.

To obtain the optimal sample points, we can exploit excess bandwidth of the
transmit signal to “see” the optimal sample points in the I/Q waveforms. This can
be done automatically by locking a PLL to the rising and falling edges of these
waveforms. In the lab, you will gain some intuition how this works.
Procedure

To complete this lab, you again need access to a computer with MATLAB and
Simulink. Make sure you have your transmit designs from last time, since we will
use this in this lab as a starting point. You should probably create a new directory
for lab 2 to help you manage things, too.

Creating a Subsystem

Maybe you noticed that once you have added very many blocks to your Simulink
model, that things start to look pretty ugly (complicated). We can better manage
complicated designs by using “subsystems.” In this lab, we will put the whole
transmitter inside a single subsystem block to allow us to concentrate on the
receiver.

Get your final BPSK design for the transmitter from the last lab and save this under
the name bpsk_rx1.mdl. Take the scope out of the design, and instead put the
output ports (found under Ports & Subsystems) as shown below:

You should also give useful names to these output ports. The actual transmit signal
is called “IF” for “intermediate frequency”. This is the signal that your receiver will
need to decode, and which models what would actually be received in a real
communications system. The other “bundle” of signals coming out of the MUX is
just called “debug”, and contains the pulse train, the baseband signal, and the
carrier, which will be useful to check correct operation of the decoding at the
receiver.
To create a subsystem, select all of the transmit blocks (draw a box around them),
right click, and then select “Create Subsystem.” You should now see just one block
with the output ports you specified:

Now you can delete the ports that have been propagated to this higher level design
and connect this to the receiver that you will design next. Note that you can modify
things inside your transmit subsystem by simply double clicking on that block.

Basic BPSK Receiver

Next, create a basic BPSK receiver as depicted below.

Make sure you understand what this chain is doing by comparing it to the receiver
chain explained in the background section!
Notes:

 The sin() block should be the same frequency as in your transmitter. I used
an amplitude of 2 for this block to undo the factor of 1/2 caused by the
downconversion.
 The RECT filter is a new block used here as a low-pass filter to remove the
double frequency component. Since the bandwidth of your transmit signal
is around 1/sample_rate = 1/50 = 0.02, you just need to make sure the upper
cut-off frequency is above this. For parameters, I used f0=0 (low-pass),
f1=0.1, and taps=32.
 The low-pass filter introduces an additional 16 samples of delay, so take
this into account!
 The decision block is implemented with the Fcn block taken from the User
defined functions library.

The decision block needs to take a baseband sample, and decide which symbol
this is closest to. For BPSK, we can just check if the signal is positive or negative,
and assign this to the bits (or symbols) 1 and 0, respectively. For example, we might
do something like

if (input > 0),

output = 1;

else

output = 0;

end

In MATLAB, a TRUE expression evaluates to 1 and a FALSE expression evaluates to


0. So, we can do the decision operation with a compact expression like:

(u(1)>0)*1 + (u(1)<=0)*0

Here, u(1) is the input sample. If it is greater than a threshold of 0, the output is 1. If
it is less than (or equal to) zero, we set the output to zero. Note that the second
term is actually not needed.
Once your BPSK receiver is configured and you undestand basically how it is
supposed to work, try running it for 1000 samples and see if it gives what you think
it should. Make sure you understand all the signals you are seeing!

Matched Filtering

Remember that we will have optimal noise performance if the receive filter is the
same as your transmit filter. Try modifying your BPSK design and use the same
raised cosine filter as in your transmitter. Remember, you will probably have to
change the delay of the signals for sampling / plotting since this filter gives a 64
sample delay.

After making the change, rerun your design. Do you still have the zero ISI property?

Root Raised-Cosine Matched Filter

The usual way to maintain the raised cosine response (and the zero-ISI property) is
to use a root raised cosine filter at the transmit and receive. “Root” means that we
take the square root of the RC response in the frequency domain. This way if we
cascade two root RC filters, we get the RC shape. One problem with the root raised
cosine (RRC) filter is that the time response is much longer than the RC filter. So, to
support the RRC filter you need to do the following:

1. Change the transmit and receive filters to root filters (check the box in the
parameters)
2. Make the filters 512 taps long to support the longer time response
3. Since each filter now creates 256 samples of delay, make changes to any
delay blocks that depend on this.

I would like to point out that in a real system, we would not create such a long filter
(512 taps) for this simple RRC operation. The reason we have to make it so long is
because we are using a fixed (high) sample rate throughout our whole system. A
real system would typically use the high sample rate only for the
upconversion/downconversion parts and then use perhaps 1/10 of the rate for the
baseband processing. In that case, the filter would be more like 64 samples long,
which is more reasonable.

After making the changes, rerun your system. You should see something very
similar to what you had with just one RC filter on the transmit and no matched
filter at the receiver. Also, check to make sure the outputs of the sample block look
correct.

Carrier Recovery

In a practical communications system, the receiver oscillator will not be the same
as the transmit one. To see the effect of carriers that are not the same. Modify your
transmitter so that the sin() block is driven with a modified clock as depicted
below:

You can change the sin() block to use an external time reference by simply
changing a box in its parameters. The clock block is found in the sources library.
Also, I have found using the transport delay gives smoother plots on the
oscilloscope than the discrete delay block, so that is why I used it instead.

Now, run your communications chain and see what happens to your received
symbols. Can you figure out why having a delay does this? What does a delay mean
in terms of the phase of the oscillators?

To make it easy for the receiver to recover the carrier, we will add a pilot tone to
the transmit signal, which is simply an unmodulated component that in this case
has half the frequency of our carrier. The receiver can then isolate this tone and
double the frequency to get the carrier back. Any delay or frequency shift in the
transmit carrier will be completely reflected in the pilot tone, allowing the receiver
to track these differences.
Modify your transmit design as depicted below.

The sine wave (pilot tone) that is added to the output signal should have

 frequency = 2*pi*0.05 (discrete freq=0.05, which is half the frequency of the


modulated carrier)
 amplitude = 0.05
 phase = 0

The amplitude is somewhat arbitrary, but usually we do not want to make it too
high in a real system, since it wastes available transmit power. Since it is very
narrowband, we can make it have fairly low amplitude and use a tight filter to
remove noise.

In the receiver, we need to first isolate the pilot tone using a narrow bandpass
filter. For this, you can again use the RECT filter as depicted below:
For the filter, I have used 80 taps and f0=0.03 and f1=0.07. I chose 80 taps so that
the delay of the filter (40 samples) is an integer multiple of the carrier period (10
samples), making it so we don’t have to adjust the phase output of the PLL.

Now put a scope on the output of the RECT filter as shown and run your chain. Do
you see your carrier at f=0.05? If you can’t really tell, you could also use the PSD
block from before and check this way, since this shows frequency directly.

PLL-based Synchronization

Now, how do we use this carrier signal in our receiver? One idea would be to
amplify the signal and use it directly instead of the sin(). This is not usually done,
for a number of reasons:

1. The amplitude of the pilot signal changes as the channel between transmit
and receive changes.
2. For an I/Q system, we need to also derive a signal that is 90 degrees out of
phase from this.
3. Here the pilot is half the frequency of what we need. How do we double
this? Squaring and filtering?!

A much more flexible way to generate our carrier from this signal is to use a phase-
locked loop (PLL). This is a device that takes a sine wave as input and tracks its
phase using a loop. The PLL generates its own sine wave internally, whose phase is
locked to the incoming signal. The PLL is also free to generate any other clock or
sine wave signals that are needed based on this phase. For example, the PLL can
generate a carrier with double or half the frequency, apply a constant phase shift,
etc.

In a later lab you will learn the details of what is inside a PLL. For now, a block has
already been created for you in the DSP Blocks->Timingmenu. To understand
how the PLL works, create a new empty design and put the PLL block in it with a
source as shown below:
The key parameters are shown on the PLL block in the figure. What it means is that
the PLL is expecting a nominal input frequency of 0.05 and will generate an output
of the same frequency (0.05) locked to the input. The Tl value is the time constant
of the PLL that controls how quickly the PLL should track. This should be many
sinusoidal cycles to make the carrier steady (here I picked 500 samples, which
means 25 periods of the carrier). Try the following things:

1. Make the source frequency 0.05 and run it. How do the input and PLL
output sine wave compare?
2. Change the amplitude of the input source. Does this affect the output of the
PLL?
3. Make the source frequency 0.055 or 0.45. What happens at the output of the
PLL?
4. Try changing the output frequency of the PLL from 0.05 to 0.1 or 0.025. What
do you see at the output? Can you see how this might be useful?

You should now be convinced that the PLL is a versatile block for synchronizing
things in a communications system. We will now use it to do the carrier recovery.
Place the PLL with the shown parameters in your receiver as depicted below:
You can see that the PLL is set to double the frequency of the isolated pilot tone.
The amplitude of 2 is to overcome the factor of 1/2 that occurs from the
downconversion. The output of the PLL now is the carrier that we use for
downconversion. The ideal carrier (the sin() block) is now just used to check if the
PLL is putting out the right signal by feeding it to the scope.

Try running your receiver chain now. First look at the scope at the output of the
PLL. Did the doubling operation work? Then look at the output of the receiver.
Thins should look like they did before. Finally, try putting a delay in your transmit
subsystem or a frequency offset. Things should still work correctly!

Symbol Timing Recovery

The final thing that the communications system has to worry about is sampling the
match-filtered signal at the optimal points. As stated before, in a simulation we can
just tweak these to match by considering all the delays that happen. In a real
system, the clocks will be different, the transmit and receive will be powered on at
different times, the channel will cause delay, etc. How do can we know the delay?!

We will learn more details about symbol timing recovery in a later lab. For now, I
have created a block to hide most of the details from you, which can be found in
the DSP blocks->Timing menu. Place it in your design as shown below, and note
that the lines going down are just for debugging (they go to an oscilloscope):

If you are curious, you can see what is inside by right-clicking on the block and
selecting look under mask. It basically works by multiplying the baseband signal
with a copy of itself shifted by half of the symbol time. This creates a sinusoid that
has a frequency equal to the symbol rate where the zero-crossings of the sinusoid
happen at precisely the optimal sample points. Cool, huh?! The PLL is then used to
generate a sine wave locked to this carrier. The final delay block allows the timing
to be slightly adjusted as needed. Finally, we just check for a positive zero crossing
of the sine wave, which is where we should sample. This block creates a train of
pulses at the optimal sample points.

The other block that is new here is the sampler block with an external enable that
can be found in the DSP Blocks. We need this instead of the periodic sampler,
since we now need to be able to have arbitrary sample points.

You might have noticed that the time constant is much longer for the PLL used for
symbol timing recovery (here I picked 10000 samples). Can you think why this is
needed? Remember we needed many sinusoidal cycles. What do you think we
need to consider here?

Run your design with the symbol timing recovery. You will find it helpful to add the
output of the symbol timing recovery block (the sample pulse train) to your scope
to help you see if it is working. First run it for around 10k samples. Is it tracking yet?
Now try running for a much larger value like 200k. Inspect the waveform near the
end. Does it look right?

Noise

We can’t leave our high-level overview of communication systems without


considering noise. Noise is unwanted changes in our signal due to external sources,
such as other in-band transmitters, or internal sources like thermal amplifier noise.
The noise must be sufficiently small compared to the signal in order to confidently
decode the transmitted signal. Noise level is usually quantified indirectly using the
signal-to-noise ratio (SNR), where values like 10dB or better are normally required.

Add a small amount of noise using the bandlimited noise block (Simulink Sources
menu), as shown:
Make sure you set the sample time to 1, and I have picked a value of 0.001 for the
noise variance. This gives an SNR out of the matched filter around 15dB or so.
Rerun your design and look at the decoding of the symbols. What do you notice
that is different from before? Are the symbols still decoded properly (once the
symbol timing is synchronized that is)?

Try making the noise higher (like 0.01). What happens?

Lab Write Up

For the write-up, provide the following things:

1. Explain briefly how the receiver works. Also, please highlight anything that
was new that you didn’t know before!
2. Explain how we can get a RC response by using root filters at the transmit
and receive. Explain why this is preferable to using just a single (non root)
RC filter somewhere.
3. Explain the need for synchronization in communications systems, and how
this was accomplished in this lab. Also describe what a PLL is and what it
can do. What are carrier and symbol timing recovery for?
4. Give plots showing the output of your communications system for two
cases: (i) with perfect ideal synchronization, and (ii) with the
synchronization blocks. Circle and label points the printout to “prove” to
the TA that it is working.
5. Describe any difficulties you experienced in getting your design to work and
how you fixed these problem

You might also like