EE445S: Real Time DSP Lab Tasks Lab 5: Pulse Amplitude

advertisement
EE445S: Real Time DSP Lab Tasks
Lab 5: Pulse Amplitude Modulation (PAM)
Objective:

This lab deals with implementation of a baseband pulse amplitude modulation (PAM) system, used
for digital data transmission.
Lab slides:

All the slides referred in this document are from the recitation slides by Prof. Tretter uploaded in
the
course
website
http://users.ece.utexas.edu/~bevans/courses/realtime/lectures/laboratory/c6748/lab5/index.html.
Block diagram:

Please refer to Slide 11-2 for the master block diagram of the system. In this lab, we will be
focusing on the series to parallel converter block, the mapping (bits to symbols) block, transmit
filter block and the symbol clock recovery block.
Task 1: Generation of pseudo – random four – level symbols (Code Composer)









In this lab, we will be using the same files as used with polling method of sine wave generation.
You create the project in the similar way, and add the relevant files, header files, and libraries as
mentioned in Lab 2.
In this task, we will generate 2 random bits and generate a symbol out of it. This symbol will have
4 levels: 3000, 1000, -1000 and -3000. The difference between 2 levels is 2000. (2d = 2000 -> d
=1000).
Modify the scrambler code you created in Lab 4. This time, we will be using the polynomial 1 +
D18 + D23. The input to the scrambler will be “0”. The initial state of the scrambler is 5.
Now, the symbols are generated using grey-code. This way, an error in one bit (due to noise in the
channel) will only cause it to translate to the next state always, thus minimizing the error.
Now, write a symbol mapping function which takes 2 bits (b0, b1) and generates a symbol an
using the grey coding scheme.
Simplified, the equation for generating the symbols comes down to an = (-1)b0 (1+2*b1)*d where
d = 1000. (2d is the difference between levels of symbols).
Using pow method to obtain the power of 2 numbers is inefficient. Instead simple if – constructs
will work and is more efficient.
Within isr.c, create an infinite loop. Within this loop, call scrambler two times. This will generate 2
bits. Following this, call the symbol mapping function. Thus, each time the loop runs, one symbol is
generated.
Lab Report: Output the two bits and the symbol generated on a table. Repeat this for 15
symbols.
Task 2: Simulation of block diagram (Matlab)


This task is intended to get you a feel of the system before you try it on the DSP itself.
Follow this program flow in Matlab:
Symbol mapping
o
o
Using the commands round and rand, generate 200 random bits. We will be using this
instead of simulating the scrambler, which we know works and has been tested in Lab 4.
Generate 100 symbols from this (using the same logic as Task 1).
Raised cosine filtering
o
Now, we will be designing the baseband pulse shaping filter. The purpose of this filter is
two – fold: Interpolation and elimination of Inter – Symbol Interference (ISI). Usually, this
filter is split between the transmitter and the receiver as a cascade of two SQRT of raised
Karthik Raghavan;Debarati Kundu, Debarati Kundu
Page 1
2/17/2016
EE445S: Real Time DSP Lab Tasks
o
o
o
o
o
o
Lab 5: Pulse Amplitude Modulation (PAM)
cosine filters. Instead, we will lump both of these filters into one raised cosine filter (called
normal raised cosine filter).
You will use the commands rcosflt and rcosine. rcosine is used to obtain the numerator
and denominator filter coefficients. rcosflt is used for the filtering operation itself. Here are
the filter specifications.

Input symbol rate: 3000 Hz (fsym, Fd in Matlab)

Output sample rate: 48 kHz (fs, Fs in Matlab)

Type of filter: fir/normal

Alpha (the excess bandwidth factor): 1 (, r in Matlab)

Truncation limit: 4 symbol periods (delay in Matlab)
The explanation for these terms is given on Slide 11 – 12. Briefly, I will try to explain what
these terms mean here.
Since the filter is also used for interpolation, the ratio of the output rate (fs) to the input
rate (fsym) gives an idea of the number of samples per symbol. In this case, there are
48kHz / 3000 Hz = 16 samples per symbol. This means, there are 16 samples used to
interpolate the space between any 2 symbols. Thus, the digital data is transmitted as
“analog” data.
The truncation limit tells the number of symbol periods the time domain sinc waveform
needs to extend. The larger this number gets, the closer to ideal the filter gets at the
expense of more number of taps (more complexity).
The alpha factor is explained in slide 11 – 12. Basically, an  resembles an ideal low
pass filter. This maps to a sinc of infinite length in the time domain. As increases
towards 1, the impulse response becomes shorter at the expense of increased bandwidth
in the frequency domain.
Now, filter the symbols you generated using the above filter.
Eye diagram
o
o
o
We will look at the output as an “eye diagram”. This represents the transitions between
adjacent symbols. It also gives an idea of the ISI that is present and how the filter may
help get rid of ISI so that each level can be thresholded accurately at the symbol period
intervals at the receiver to recover the original data.
We will use the command eyediagram in Matlab to plot the eye diagram of the data. We
will be plotting 2 symbol periods at a time which means 16*2 = 32 samples at a time.
Once 32 samples are plotted, the plot wraps around and starts plotting over the trace
already present. This way, we get an idea as to how clean the transitions are between
levels and how easy it is to threshold the data at the symbol period intervals. The optional
“period” parameter is used to set the X axis and must be set to 2 symbol periods.
Lab Report: Output of the eye diagram.
Task 3: Simulation of block diagram (Matlab) (Contd.)


Repeat Task 2 for = 0.125.
Lab Report: Output of the eye diagram.
Task 4: Simulation of block diagram (Matlab) (Contd.)
Magnitude response


Obtain the filter coefficients of the filters you designed in Task 2 and Task 3 using the rcosine
command. Now using freqz and plot commands, plot the magnitude response of both these filters
on top of each other.
Lab Report: Plot of magnitude responses overlaid on top of each other.
Impulse response
Karthik Raghavan;Debarati Kundu, Debarati Kundu
Page 2
2/17/2016
EE445S: Real Time DSP Lab Tasks


Lab 5: Pulse Amplitude Modulation (PAM)
Now, feed an impulse through the filters you designed in Task 2 and Task 3 and plot the output
you get. This is the impulse response of the filter.
Lab Report: Plot of impulse responses overlaid on top of each other.
Understanding the plots

Lab Report:
What are the major differences between the two filters with respect to their
A) Magnitude responses
B) Impulse responses

Lab Report:
A) What is the width of the impulse response for the =0.125 case?
B) How would you obtain this number theoretically? (Hint: Look at the fsym and truncation
limit you set).
Task 5: Raised cosine filter implementation using a filter bank (rascos.exe)






Now, we will commence the implementation of the PAM block diagram on the DSP. The first step is
to obtain the filter coefficients for use in the DSP for the raised cosine filter.
In Tasks 2-4, you should have noticed that the designed filters had 129 taps and since this is an
interpolation filter, a lot of the multiplies are done with zeros.
An alternative method is to use a bank of filters. The bank of filters acts in parallel with the
incoming symbols and generate the output samples. Since the output is composed of 16 samples
per input symbol, we have 16 filters working in parallel, each responsible for one of the 16 points
that interpolate two adjacent symbols. Please refer to Slide 11-17 for a block diagram to visualize
the filter bank system.
Download the raised cosine program rascosx64.exe from the lab 5 Web page at
http://users.ece.utexas.edu/~bevans/courses/realtime/lectures/laboratory/c6748/lab5/index.html.
This program is used to obtain the filter coefficients for the bank of filters.
Design the filter with the following specifications:
o Give a name for the impulse response file [t, g(t)].
o Give a name for the subfilters file. This is the filter coefficients for each of the 16 filters
that go in parallel. Each filter is 8 taps wide (because the truncation width is 4, the
number of taps is 4 * 2 = 8. The multiplication factor of 2 arises because of the fact that
the impulse response is 4 symbols periods on either side from the mid point).
o Give a name for the amplitude response file.
o Enter the symbol rate: 3000 Hz
o Enter the value for M: Samples / baud is the same as samples / symbol = 16.
o Enter the truncation limit L: +/- 4 bauds which is the same as +/- 4 symbol periods.
o Enter the value for alpha: 1
This should give you three different files. The impulse response vs. time, the magnitude response
vs. frequency and filter coefficients for each filter of the bank.
Task 6: Raised cosine filter implementation using a filter bank (rascos.exe) (Contd.)





Repeat Task 5 for alpha = 0.125. Again, you should have three different files.
Now, import the magnitude response data from Tasks 5 and 6 into Matlab.
Lab Report: Plot the magnitude responses separately.
Now, import the impulse response data from Tasks 5 and 6 into Matlab.
Lab Report: Plot the impulse responses overlaid on top of each other.
Task 7: DSP implementation (Code Composer)


Modify the code you have developed in Task 1.
Copy and paste the filter coefficients from Task 5. They should be able to be used as it is.
Karthik Raghavan;Debarati Kundu, Debarati Kundu
Page 3
2/17/2016
EE445S: Real Time DSP Lab Tasks






Lab 5: Pulse Amplitude Modulation (PAM)
Now, go back to Lab 3 (FIR) lab. Implement a circular buffer like you did in Lab 3. Store the
symbol you generate from Task 1 into this circular buffer, in every iteration through the infinite
loop.
Now, we will be implementing the bank of filters. Since all these filters take the same input,
implement a second inner loop which loops through all the filters.
Technically, you should be able to make the same call to “convolve” like you did in Lab 3 (FIR).
Since there are 16 filters, every symbol input will generate 16 outputs. This means if the input
symbol rate is 3000 Hz, then the output sampling rate will be 3000 * 16 = 48000 Hz = 48 kHz.
Make sure you WriteSample from the inner loop and you update the symbols and newest index in
the outer loop. This will maintain the ratio of the output sample rate to input symbol rate at 16:1.
Write the output sample to both channels.
Task 10: Symbol clock recovery: Filter design (Matlab)






Please refer to slide 11-22 for the block diagram for the symbol clock recovery system.
There are 2 different filters in this system: Pre-filter B() and band pass filter H().
We will use 2nd order Butterworth IIR band pass filters with a sampling rate of 48 kHz for both the
filters.
The pre-filter B() has a center frequency of fsym/2 = 3000/2 = 1500 Hz. The 3 dB BW = 150 Hz.
The band pass filter H() has a center frequency of fsym = 3000 Hz. The 3 dB BW = 300 Hz.
Using fdatool, design both these filters and obtain the coefficients for both these filters.
Task 11: Symbol clock recovery: Implementation (Code Composer)







Modify the code you have developed in Task 7.
Pass the PAM output (output from the filter bank, within the inner loop) to the right channel.
This portion of the code is unchanged.
Pass this output to a new function which you will write. Call this function clock_recover.
Within this function, implement the algorithm as shown in slide 11-22 i.e., Pre-filter -> Square ->
Post band – pass filter -> Scale. The scaling is done to ensure that the input and output are in the
same range of values. Please figure out an appropriate scaling level.
For the pre-filter and post band – pass filter IIR filters, please use the code for Lab 3 (IIR Biquad).
Take the output of this function and pass it to the left channel. This is the “recovered” clock.
Do not run the code yet! Task 12 and Task 13 are test tasks to run this code.
Task 12: Symbol clock recovery: Testing (Code Composer)
Dotting Sequence Test





Make sure the audio codec is set to a sampling rate of 48 kHz.
To test the code you wrote in Task 11, first comment the code which calls the scrambler code and
the code that generates the symbol.
Now, generate a “dotting sequence”. This is basically a square wave that is HI for Tsym and LO for
Tsym i.e. an = (-1)n * d where d = 1000 where an is the symbol that is fed into the bank of filters
and n is a running index for the outer loop that goes on forever.
Do not use pow function. Instead, simple if constructs should do.
As mentioned in Task 11, pass the PAM output to the right channel and the recovered clock
output to the left channel. Observe both the channels on the oscilloscope.
Task 13: Symbol clock recovery: Testing (Code Composer) (Contd.)
Scrambler Test



Make sure the audio codec is set to a sampling rate of 48 kHz.
Now, uncomment the code which calls the scrambler code and the code that generates the symbol.
Comment out the “dotting sequence” code from Task 12.
Karthik Raghavan;Debarati Kundu, Debarati Kundu
Page 4
2/17/2016
EE445S: Real Time DSP Lab Tasks


Lab 5: Pulse Amplitude Modulation (PAM)
As mentioned in Task 11, pass the PAM output to the right channel and the recovered clock
output to the left channel. Observe both the channels on the oscilloscope.
Lab Report: Make a note of your observations in this table.
Task
12
13
Pattern
Dotted Sequence
4 – PAM
Tone frequency
Tone amplitude
Task 14: Theoretical error probability (Matlab)




Please perform point 8 on Slide 11-33. This is the error probability for M – level PAM.
Please read the section from slides 11-17 to 11-22 to understand the formulation for Pe.
Please plot all the three graphs on the same plot with appropriate labeling of axes and legends.
You will find the erfc function in Matlab to be useful. There is a relationship between the Q function
and the erfc function. Please refer to Slide 13-25 of the course notes (Lecture 13: Matched
Filtering and Digital PAM).
Please check the Lab Report requirements from the course website to ensure that you have
done everything in the lab in order to answer the lab report questions.
Karthik Raghavan;Debarati Kundu, Debarati Kundu
Page 5
2/17/2016
Download