Recent Question/Assignment
Assignment 1: Signals & Spectra, Filtering, and Amplitude Modulation
Due date: 5 pm, Friday, 7th May 2016
General Information: Each task consists of:
1. A set of tutorial/exam type problems, which you will need to solve with pen and paper.
2. A set of simulation tasks in MATLAB related to the specific questions.
This document and all required files are available for downloading from the learn online course web page.
Important Information: Kindly use the function ft.m and myfilter.p provided the course web page for computing the Fourier transform (MATLAB tasks only). You can find it under the section about MATLAB.
Final Report and Evaluation Your report should consist of:
• Solutions to the problems (including mathematical derivations).
• A working copy of the MATLAB code.
• All the plots generated in MATLAB, with appropriate title description. (You can add the titles to the plots in the report document after copying them to your document, if that is easier).
Evaluation will be based on the components above. Hand-written solutions to the problems are to be scanned into a pdf file, to which you will attach the plots and the MATLAB code.
Note: Hand-written answers/mathematical derivations will be accepted only if done neatly and clearly. You may scan them and submit electronically.
Task 1: Signal and Spectrum
Consider a filter with the following frequency response:
for some td 0 and f0 0.
1. Show that the impulse response of the filter is
2. Let f0 = 103 (Hz), td = 2/f0.
(a) Plot |H(f)| for f ? [-5f0,5f0] with K = 1,3,10 on the same figure.
(b) Plot h(t) with t ? [0,2td] with K = 1,3,10 on the same figure.
(c) Comment on the functionality of the filter. Comment on the design tradeoff in choosing K. Explain why the filter cannot be exactly realized in practice.
3. Describe how you translate the filter in time and frequency domains to obtain a bandpass filter (with the same bandwidth) at center frequency fb. Plot the magnitude of the transfer function |Hb(f)| and the impulse response hb(t) of the bandpass filter with f0 = 103,fb =
. Use a time resolution of seconds per
sample.
A causal filter can be implemented with the following impulse response:
(
h(t), 0 = t = 2td
himp(t) =
0, otherwise.
For your convenience, you can use the filter function myfilter described below (obtained by downloading the file myfilter.p into your working folder)
% [tout, sigout]=myfilter(sigin, t, f0, fb, K, td) % truncated impulse response of the filter in Task 1.
% fb: center frequency.
If fb=0, low pass filter with bandwidth f0; if fb f0,bandpass filter with bandwith 2 f 0.
% K: the order of the filter (see Task 1)
%td: delay (see Task 1)
%sigin: input signal
% t: vector of time instants corresponding to the input samples (the function assumes uniform sampling)
% sigout: filtered signal
%tout: vector of time instants corresponding to the output samples.
Task 2: AM modulation
Consider the following block diagram
x (t)
1 + µx(t)Bandpass filter xc(t)
Figure 1: AM modulator with switching circuit
Assume that x(t) is a band limited signal satisfying |x(t)| = 1 with bandwidth W. The switch can turn ‘on’ and ‘off’ with 50% duty cycle and frequency fc W such that x1(t) = x(t) when the switch is ‘on’, and x1(t) = 0 when the switch is ‘off’.
1. Sketch the spectrum X1(f) of x1(t) (you can assume that X(f) has the M-shape in this question)
Hint: x1(t) is the product of 1+µx(t) and a 50% duty cycle rectangle wave a(t) illustrated in Figure 2. The function a(t) can be written as a combination of sin waves using Fourier series.
Figure 2: Rectangular wave
2. Assume that the (non-truncated) bandpass filter in Task 1 is used. Choose the center frequency fb and the cutoff frequency f0 of the filter such that xc(t) is an AM signal of x(t). Explain your design choice.
AM Modulation with Matlab
Use Matlab to perform AM modulation. At the first stage, perform AM modulation using a multiplier. At the second stage perform AM modulation using a switching circuit. Compare and contrast the two modulating techniques. The AM signal has the following characteristics:
• Message: where
• Carrier frequency: fc = 10kHz.
• Modulation index: µ = 0.75.
Use the time resolution of seconds per sample. Perform the following steps:
1. Generate the message xm(t) for t ? [0,4/f1].
2. Generate the AM signal of xc1(t) by multiplying the dc-shifted message with a cosin carrier at frequency fc. Plot the message and the AM signal on the same figure.
3. Generate the AM signal using the switching circuit in Figure 1:
(a) Generate and plot the signal x1(t) at the output of the switch.
(b) Determine the filter bandwidth f0 and the center of the bandpass filter fb for the filter in Task 1. Use the filter to generate the AM signal xc(t). As a guide, choose
K = 3 and td = 4/f0.
Hint: The frequency response of the filter himp(t) is slightly different than that in Task 1 due to the truncation. Use the script ft.m to study Himp(f) and choose f0. Some error margin is desireabe. The filter may give some gain to the signal, which you can safely ignore.
(c) Plot and compare xc(t) with xc1(t). Explain the discrepancies.
(d) Now set f0 = 5kHz and K = 1 and repeat steps (b) and (c). Explain why the AM signal is distorted. Why the resulting signal is not desirable for transmission?
Task 3: Receiver simulation in Matlab
This task is primarily coding and making plots in matlab. You will first need to download the file A1signals.mat from the course website. Place it on your Matlab path and load its contents into the Matlab workspace via
load A1signals
Superheterodyne Receiver
1. The workspace will have a variable called xc1. This is a signal vector. The sampling frequency with which the vector was generated is the value of the variable fs which should also be in the workspace. Use ft.m to compute the spectrum of this signal and plot the positive–frequency half.
2. The carrier frequencies of each component in the signal are in the workspace variable vector cfreq. From inspection of the spectrum, determine the modulation types being used. Make a table of the carrier frequencies (in kHz) and their associated modulation.
3. Write a script or function to perform superheterodyne detection of a component. The requirements for each section of the receiver are as follows.
• RF section: Given the carrier frequency fc of the component of interest, implement a broad–bandwidth filter in the time domain to pass the frequencies in the region of fc. You must specify a suitable bandwidth for this filter. Justify your choice.
• IF section: The properties of the IF stage are fixed: In this case the intermediate frequency fI = 100 kHz and the total bandwidth of the filter is 50 kHz. Downmix the RF output to this frequency via multiplication with a cosine of appropriate frequency and then apply the IF filter.
• baseband section: Downmix the output of the IF section to baseband and recover the component at baseband.
To perform bandpass or lowpass filtering at any stage please use the filter specified in the first part of this assignment.
4. With your script/function, extract each one of the modulated components in turn by supplying the carrier frequency. Make a plot of the baseband spectrum of each component, and title each plot with the carrier frequency used to extract the signal.
Homodyne Detection
The receiver’s carrier may lose synchrony with the transmitter for various reasons: imperfections in local oscillators, Doppler shift of frequency due to relative motion, etc. In practice the transmitter phase is tracked at the receiver. However it is possible to use the transmitter’s carrier directly.
1. the variable xc2 is another signal vector which contains two AM signals. This too was generated with sample frequency of fs. Compute the spectrum of this signal and plot the positive frequencies to see the components.
2. We expect the carrier frequency of the lower–frequency component to be 140 kHz. Downmix this component directly to baseband by multiplication with a cosine of this frequency, then apply a lowpass filter. Plot the spectrum. What feature of the spectrum suggests that our receiver’s carrier wave was not the same as the transmitter’s?
3. Attempt to extract the carrier from the transmitted signal with a bandpass filter, centred at the expected carrier frequency, with a total bandwidth of 10 kHz. Now repeat the downmix and lowpass filter operations on the xc2 signal, but using the extracted carrier wave instead of the cosine. Compute the spectrum via ft.m and scale this with respect to its maximum before plotting. On the same axis plot the scaled spectrum of the original baseband signal (which is supplied in variable xbb).
4. Repeat the above and generate plots of scaled spectra but using extraction filter bandwidths of 25 kHz and 50 kHz. Explain the difference from the previous spectrum.
5. xc2 contains a second component at 200 kHz. Downmodulate this second component by downmixing directly to baseband with a cosine of appropriate frequency and then lowpass filtering. Plot its spectrum.
6. Re-do the downmodulation, this time using a carrier extracted from the transmitted signal. Use an extraction filter of very low bandwidth. Plot its spectrum.
7. Suggest why the extracted–carrier has recovered the signal better than the cosine. Can the cosine be modified to improve recovery? Try it and plot the spectrum of the result.
Matlab hints
• A vector of sample times can be generated from fs like this:
tv = 0:1 /fs:(length(xc1)-1)/fs;
• The supplied ft.m routine computes a vector of frequencies fv:
[fv,S] = ft(tv,s);
• To see detail in plots of spectra you may need to use semilogy instead of plot.
Better still, convert to dB before plotting:
SdB = 10*log10(abs(S).ˆ2); plot(fc, SdB)
• After plotting, you can limit the display to a range of frequencies or times:
set(gca,’xlim’,range)
– Use range = [0 max(fv)] to see the positive frequencies only.
– Use range = [-B B] to see a range of 2B Hz centred at 0.
– Use range = [ti, ti+T] for a T–second interval in time domain plots.
• You can also limit the y axis to a region of interest.
set(gca,’ylim’,[ymin ymax])
– This is useful to inhibit negligible values in dB plots:
plot(fv, SdB);
set(gca,’ylim’,[-80 0]+ max(SdB));
• To scale a spectrum relative to its maximum, do either:
S1 = S./max(abs(S));
S1dB = SdB - max(SdB);