Top Banner
ECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem Set 2 (Solutions are due Mon. 02-06-12) 1 Introduction The goals of this problem set are the continuation of using Matlab to generate and analyze signals of interest for wireless communications. In particular, the FFT is used to charac- terize and analyze filters and various amplitude modulated (AM) signals in terms of their magnitude and phase plots in the frequency domain. 2 Decibels The decibel (dB) is a logarithmic unit used for relative power measurements. A decibel is one tenth of a bel (B), a seldom used quantity named in honor of Alexander Graham Bell, the inventor of the telephone. Let P i and P o be two powers (input power P i and output power P o ) to be compared, e.g., the transmit and receive power in a wireless communication system. The power ratio in dB with respect to P i is then expressed as G dB = 10 log ( P o P i ) dB , where log stands for logarithm to base 10 (log10 in Matlab). Thus, if a transmitter uses P i = 1 W of transmit power and the receiver receives P o = 1 nW, then G dB = 10 log(10 -9 /1) = -90 dB and we say that the signal is attenuated by 90 dB. If an amplifier has a power gain of 2, i.e., P o =2P i , then G dB = 10 log(2) = 3.01 3 dB and we say that the gain is 3 dB. Through Ohm’s law (V = RI or I = V/R and thus P = VI = V 2 /R) the input and output powers P i and P o are related to the input and output voltages V i and V o by P i = V 2 i /R i and P o = V 2 o /R o , where R i and R o are input and output resistances (often 50 Ω for wireless communication equipment). Thus, if R i = R o then G dB can also be expressed in terms of the voltage ratio V o /V i as G dB = 20 log ( V o V i ) dB , where log again stands for logarithm to base 10. Note the factor of 20 instead of 10 which is a consequence of the identity log(x 2 ) = 2 log(x). Thus, if an amplifier has a voltage gain of 2, then V o =2 V i and G dB = 20 log(2) = 6.02 6 dB, i.e., a voltage gain of 2 corresponds to a power gain of 4 or, in decibels, to a gain of 6 dB. Absolute powers are also often expressed in decibels with respect to an absolute reference power P i , e.g., with respect to P i = 1 W (denoted by dBw) or with respect to P i = 1 mW (denoted by dBm). An absolute transmit power of 2 W then corresponds to 3 dBw or 33 dBm. As another example, if a value of 7 dBm is specified for an electronic component to 1
25

ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

May 15, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

ECEN 2420 Wireless Electronics for Communication Spring 201201-30-12 P. Mathys

Problem Set 2 (Solutions are due Mon. 02-06-12)

1 Introduction

The goals of this problem set are the continuation of using Matlab to generate and analyzesignals of interest for wireless communications. In particular, the FFT is used to charac-terize and analyze filters and various amplitude modulated (AM) signals in terms of theirmagnitude and phase plots in the frequency domain.

2 Decibels

The decibel (dB) is a logarithmic unit used for relative power measurements. A decibel isone tenth of a bel (B), a seldom used quantity named in honor of Alexander Graham Bell,the inventor of the telephone. Let Pi and Po be two powers (input power Pi and outputpower Po) to be compared, e.g., the transmit and receive power in a wireless communicationsystem. The power ratio in dB with respect to Pi is then expressed as

GdB = 10 log(Po

Pi

)dB ,

where log stands for logarithm to base 10 (log10 in Matlab). Thus, if a transmitter uses Pi =1 W of transmit power and the receiver receives Po = 1 nW, then GdB = 10 log(10−9/1) =−90 dB and we say that the signal is attenuated by 90 dB. If an amplifier has a power gainof 2, i.e., Po = 2Pi, then GdB = 10 log(2) = 3.01 ≈ 3 dB and we say that the gain is 3 dB.Through Ohm’s law (V = R I or I = V/R and thus P = V I = V 2/R) the input and outputpowers Pi and Po are related to the input and output voltages Vi and Vo by Pi = V 2

i /Ri

and Po = V 2o /Ro, where Ri and Ro are input and output resistances (often 50 Ω for wireless

communication equipment). Thus, if Ri = Ro then GdB can also be expressed in terms ofthe voltage ratio Vo/Vi as

GdB = 20 log(Vo

Vi

)dB ,

where log again stands for logarithm to base 10. Note the factor of 20 instead of 10 whichis a consequence of the identity log(x2) = 2 log(x). Thus, if an amplifier has a voltage gainof 2, then Vo = 2 Vi and GdB = 20 log(2) = 6.02 ≈ 6 dB, i.e., a voltage gain of 2 correspondsto a power gain of 4 or, in decibels, to a gain of 6 dB.

Absolute powers are also often expressed in decibels with respect to an absolute referencepower Pi, e.g., with respect to Pi = 1 W (denoted by dBw) or with respect to Pi = 1 mW(denoted by dBm). An absolute transmit power of 2 W then corresponds to 3 dBw or 33dBm. As another example, if a value of 7 dBm is specified for an electronic component to

1

Page 2: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

function properly, then this corresponds to an absolute power of 5.01 mW that the componentneeds.

3 Fourier Series and FFT in Matlab Revisited

As you recall, the Fourier Series and the Discrete Fourier Transform are defined as follows:

Definition: The Fourier Series (FS) of a periodic continuous time signal x(t) with periodT0 is defined as

Xk =1

T0

∫T0

x(t) e−j2πkt/T0dt , k = 0,±1,±2, . . . ,

where the integration is taken over any interval of length T0. The FS coefficients Xk corre-spond to frequency components (in Hertz) at fk = k/T0. Frequency f1 = 1/T0 is called thefundamental frequency, f2 = 2/T0 is called the 2’nd harmonic, f3 = 3/T0 is called the 3’rdharmonic, etc.

Definition: The Discrete Fourier Transform (DFT) of a DT signal xn, n = 0, 1, . . . , N − 1,that is periodic with period N , is defined as

Xk =N−1∑n=0

xn e−j2πkn/N , k = 0, 1, . . . , N − 1 .

The term FFT (fast Fourier transform) refers to a fast algorithm for computing the DFTfor composite N and, very often, for the case when the blocklength N is a power of 2.

By sampling x(t) with sampling rate Fs = 1/Ts and setting xn = x(nTs), the FS coefficientsXk of x(t) can be approximated by the DFT coefficients Xk (which are easily computed usingthe FFT) as

Xk ≈1

NXk , for k = 0, 1, . . . , N − 1 .

The following Matlab function computes Xk and displays |Xk| for x(t) sampled with rateFs.

FS/FFT Function simpleFS

function simpleFS(xt,Fs)

%simpleFS Plot (approximation to) magnitude of FS coefficients Xk

% without any additional processing.

% Command format: simpleFS(xt,Fs)

N = length(xt); %Blocklength (or period)

Xk = 1/N*fft(xt); %Xk approximated using FFT

kk = [0:N-1]; %Indexes k of Xk

ff = Fs/N*kk; %Frequency axis

Continued on next page.

2

Page 3: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

subplot(211)

stem(ff,abs(Xk),’.-b’)

grid

ylabel(’|X_k|’)

str = ’FS Coefficient Approximation using FFT’;

str = [str ’, N=’ int2str(N) ’, F_s=’ int2str(Fs) ’ Hz’];

title(str)

figure(gcf)

Running the Matlab script file shown below

Fs = 8000; %Sampling rate

A = 1; %Amplitude

f = 2010; %Frequency

theta = -90; %Phase

tlen = 0.01; %Time duration

tt = [0:floor(tlen*Fs)-1]/Fs; %Time axis

xt = A*cos(2*pi*f*tt+pi/180*theta);

%Sinusoidal signal x(t)

simpleFS(xt,Fs); %Show |Xk| of x(t)

results in this graph of the Xk:

0 1000 2000 3000 4000 5000 6000 7000 80000

0.1

0.2

0.3

0.4

0.5

|Xk|

FS Coefficient Approximation using FFT, N=80, Fs=8000 Hz

Some thoughts, observations, and suggestions for improvement of the simpleFS functionare triggered by looking at this graph. The first observation is that we would expect asinusoid of frequency f = 2010 Hz to produce exactly two spectral lines, one at -2010 Hzand one at +2010 Hz. Thus, the question of resolution in the frequency domain, and therange of frequencies to display arises. The second observation (try it out) is that the graphlooks the same if you set theta=0 (corresponding to x(t) = cos(2πft) instead of theta=-90(corresponding to x(t) = sin(2πft)). Thus, plotting only |Xk| is not enough to show all

3

Page 4: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

information contained in the complex number Xk. A possible solution is to add anothergraph that shows ∠Xk. A third, more general observation is that the blocklength N andthe sampling frequency Fs, both of which do not appear explicitly as part of the originalx(t), need to be chosen intelligently to obtain a good and computationally efficient FFTapproximation for the Xk.

For the DT sequence xn the period is equal to the blocklength N . For the CT signal x(t)this translates into a period T0 = NTs = N/Fs. Thus, in terms of frequency f in Hertz,index k corresponds to frequency f = kFs/N . The fundamental frequency f1 = 1/T0 istherefore f1 = ∆f = Fs/N , where ∆f denotes the frequency resolution (in Hertz) of theFFT approximation to Xk. Thus, for a higher frequency resolution (i.e., smaller ∆f) andgiven Fs, it is necessary to choose a larger N .

A second reason for choosing a larger N comes from the periodic nature of the DFT (andthus the FFT) in both the time and frequency domains. The sampling of x(t) at timest = nTs is what leads to the DT sequence xn and the approximation of the integration overthe period T0 for the FS by the summation from n = 0 to N − 1 for the DFT/FFT. As aresult Xk+N = Xk, i.e., Xk is periodic with period N , as can be easily seen from

Xk+N =N−1∑n=0

xn e−j2π(k+N)n/N =N−1∑n=0

xn e−j2πkn/N e−j2πN/N =N−1∑n=0

xn e−j2πkn/N ,

where e−j2πN/N = e−j2π = 1 is merely “a complicated way of saying 1”. As a consequenceXN = X0, XN+1 = X1, XN+2 = X2, etc. Similarly, XN−1 = X−1, XN−2 = X−2 so that adisplay for negative frequencies can actually be obtained by relabeling the Xk for k ≥ N/2to Xk−N and moving them to k − N on the frequency axis. Thus, the range of k for theDFT/FFT can either be taken as k = 0, 1, . . . N−1, or as k = −N/2, . . .−1, 0, 1, . . . , N/2−1(if N is odd, use k = −(N − 1)/2, . . .− 1, 0, 1, . . . , (N − 1)/2). Another consequence of theperiodicity of the Xk is that a CT signal, such as a 50% duty cycle rectangular pulse withperiod T0 which has frequency components at ±k/T0 for k = 1, 3, 5, . . . all the way up toinfinity, will have the components above N (and above 2N , 3N , etc.) all shifted down to the0, 1, . . . , N − 1 range (or −N/2, . . . ,−1, 0, 1, . . . , N/2 − 1) range where they combine withthe original components in that range. This phenomenon is called aliasing and leads tosubstantial errors if N is too small for the frequency content in x(t). The solution to thisproblem is to choose the sampling rate Fs large enough while keeping the period T0 fixed(and thus, through T0 = N/Fs, increasing N).

An improved Matlab function to compute Xk and display both |Xk| and ∠Xk for x(t) sampledwith rate Fs is the following

4

Page 5: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

FS/FFT Function showFS

function showFS(xt,Fs,ff_lim)%showFS Plot (approximation to) FS coefficients Xk of (periodic,% period N=length(xt)) waveform x(t) sampled at rate Fs.% ff_lim = [f1 f2] specifies the range f1...f2 of frequencies% f = k*Fs/N for which the Xk are displayed.% Command format: showFS(xt,Fs,ff_lim)

if nargin<3ff_lim = [0 Fs]; %Default f1,f2 display limits

endllim = 1e-3; %Lower limit for magnitude/phase displayN = length(xt); %Total number of samples (period)Xk = 1/N*fft(xt); %Xk approximated using FFTff = Fs/N*[0:N-1]; %Frequency axisf1 = ff_lim(1); %Lower frequency limit for displayf2 = ff_lim(2); %Upper frequency limit for displayif f1<0Xk = fftshift(Xk); %Swap lower and upper ranges of Xkff = fftshift(ff); %Swap upper and lower part of f axisixu = find(ff>=Fs/2); %Find indexes of frequencies >=Fs/2ff(ixu) = ff(ixu)-Fs; %Make negative part of f axis

endix = find(ff>=f1&ff<f2); %Find indexes for displayffd = ff(ix); %Frequency axis for displayabsXk = abs(Xk(ix)); %Magnitude of Xk for displayargXk = 180/pi*angle(Xk(ix)); %Phase of Xk in degrees for displayixllim = find(absXk<llim); %Indexes of |Xk| that are too smallabsXk(ixllim) = llim*ones(size(ixllim));argXk(ixllim) = zeros(size(ixllim));

%Set lower limit, suppress phase

subplot(211)stem(ffd,absXk,’.-b’)gridylabel(’|X_k|’)str = ’FS Coefficient Approximation for x(t)’;str = [str ’, N=’ int2str(N) ’, Fs=’ int2str(Fs) ’ Hz’];str = [str ’, \Delta_f=’ num2str(Fs/N) ’ Hz’];title(str)

subplot(212)stem(ffd,argXk,’.-r’)gridxlabel(’f = k*F_s/N [Hz]’)ylabel(’\angle X_k [deg]’)

figure(gcf)

Using the Matlab script file shown below with showFS(xt,Fs,[-2500 2500]) (which dis-plays the frequency range from -2500 to 2500 Hz, rather than from 0 to Fs) and tlen

extended to 0.1

5

Page 6: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

Fs = 8000; %Sampling rate

A = 1; %Amplitude

f = 2010; %Frequency

theta = -90; %Phase

tlen = 0.1; %Time duration

tt = [0:floor(tlen*Fs)-1]/Fs; %Time axis

xt = A*cos(2*pi*f*tt+pi/180*theta);

%Sinusoidal signal x(t)

showFS(xt,Fs,[-2500 2500]); %Show Xk of x(t) for

%f in range -2500 to 2500 Hz

now leads to the improved graph of the Xk shown below.

−2500 −2000 −1500 −1000 −500 0 500 1000 1500 2000 25000

0.1

0.2

0.3

0.4

0.5

0.6

0.7

|Xk|

FS Coefficient Approximation for x(t), N=800, Fs=8000 Hz, ∆f=10 Hz

−2500 −2000 −1500 −1000 −500 0 500 1000 1500 2000 2500−100

−50

0

50

100

f = k*Fs/N [Hz]

∠ X

k [deg

]

Note that the spectral lines of |Xk| are now just to the left of -2000 Hz and just to the rightof 2000 Hz, corresponding to the 2010 Hz frequency. The phase ∠Xk now correctly identifiesthe signal as a sine (−90 at 2010 Hz and +90 at -2010 Hz). In general, there is a smallproblem for the display of the phase of a signal whose magnitude is small for many or most ofthe frequencies displayed. That problem is that any small complex-valued random number(that results from the use of finite precision arithmetic), e.g., (1.25 + j0.93) × 10−14, has a

6

Page 7: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

random phase in the range between −180 and +180. If all those random phase values areplotted, then the phase values of the large Xk which are of interest become invisible sincethey get buried in the noise. The solution for this is relatively simple: Just set all the phasevalues to zero for those Xk whose magnitude |Xk| is below a preset limit, e.g., below llim

= 1e-3, the limit which is used in showFS.

4 Filters

Filters are input-output devices which exhibit frequency-selective behavior. In the simplestcase an ideal lowpass filter (LPF) passes all frequencies below a cutoff frequency fL withoutany change and rejects all frequencies above fL completely. Such a filter is not practicallyrealizable, but it is a good conceptual tool to explain ideas and principles behind practicaldevices, without getting distracted by implementation issues. In a similar spirit an idealhighpass filter (HPF) passes all frequencies above some cutoff frequency fH without anychange and rejects all frequencies below fH completely. Another filter of interest is an idealbandpass filter (BPF) with center frequency fc and bandwidth W . Such a filter passesall frequency components in the range fc−W/2 to fc +W/2 without any change and rejectsall frequency components outside that range completely.

The unit impulse response hL(t) (i.e., the output signal that results from applying a unitimpulse δ(t) at the input of the filter) of an ideal lowpass filter with cutoff frequency fL isgiven by

hL(t) =sin(2πfLt)

πt, −∞ < t <∞ .

Because hL(t) extends from −∞ to +∞ along the time axis, any practical implementationhas to truncate hL(t), e.g., to the range −k/(2fL) ≤ t ≤ k/(2fL) for some positive integerk. The graph below shows the resulting frequency responses for k = 1, 5, 10 for an LPF atfL = 400 Hz..

0 200 400 600 800 1000 1200 1400 1600 1800 2000−80

−70

−60

−50

−40

−30

−20

−10

0

10

f = k*Fs/N [Hz]

|Hk| i

n dB

LPF: FS Coefficient Approximation for h(t), N=8000, Fs=8000 Hz, ∆f=1 Hz, f

L=400 Hz

Ideal LPFk=1k=5k=10

7

Page 8: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

Note that the magnitude of the frequency response is plotted in dB so that the amount ofattenuation outside the passband can be more easily assessed. As k increases the “tails”of the magnitude of the frequency response clearly decrease, but the first sidelobe after thepassband never decreases in amplitude, it only becomes more narrow. The reason for this isthe steep transition from passband (below fL) to stopband (above fL) that an ideal LPF has.To get the sidelobes of the magnitude of the frequency response to decrease more quickly,the trick is to allow for a more gradual transition from passband to stopband. One way toachieve this is using a filter with trapezoidal magnitude of frequency response, as shown inthe figure below.

HL(f)

1

f−(1+α)fL

−(1−α)fL

0(1−α)fL

(1+α)fL

0 ≤ α ≤ 1

hL(t) =sin(2πfLt)

πt

sin(2παfLt)

2παfLt⇐⇒

The parameter α, with 0 ≤ α ≤ 1 is used to control the transition from passband tostopband. The case α = 0 corresponds to the ideal LPF. The other extreme of α = 1 leads toa magnitude of frequency response that is triangular, with a total width from −2fL to +2fL,which is twice the bandwidth of the ideal LPF. The graph below shows the magnitude of thefrequency response for a more moderate expansion of the bandwidth to 1.2fL, correspondingto α = 0.2, for k = 1, 5, 10.

0 200 400 600 800 1000 1200 1400 1600 1800 2000−80

−70

−60

−50

−40

−30

−20

−10

0

10

f = k*Fs/N [Hz]

|Hk| i

n dB

LPF: FS Coefficient Approximation for h(t), N=8000, Fs=8000 Hz, ∆f=1 Hz, f

L=400 Hz, α=0.2

Ideal LPFk=1k=5k=10

Except for the case of k = 1, this clearly leads to a tradeoff where a little more bandwidthresults in a much faster increase of the attenuation in the stopband. The following Matlabfunction implements a LPF with trapezoidal magnitude of frequency response characteristicthat is cntrolled using the k and α parameters.

8

Page 9: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

Trapezoidal LPF Function trapLPF

function [yt,ord] = trapLPF(xt,Fs,fL,k,alfa)%trapLPF Lowpass filter with trapezoidal frequency response% magnitude and delay compensation. The input signal% xt and the output signal yt are sampled with sampling% rate Fs. The cutoff frequency (-6 dB) is fL in Hz.% The parameter k (default 5) controls the cutoff of% the (otherwise infinite) unit impulse response length.% The parameter alfa (range 0 to 1, default 0.2) controls% the transition from passband to stopband. The returned% variable ord is the filter order (number of memory% cells) used by the filter. The filter is a FIR filter% with linear phase.% Command format: [yt,ord] = trapLPF(xt,Fs,fL,k,alfa)

if nargin<5alfa = 0.2; %Default for parameter alfa

endif nargin<4k = 5; %Default for parameter k

endixk = round(Fs*k/(2*fL)); %Tail cutoff indextt = [-ixk:ixk]/Fs; %Time axis for h(t)ord = length(tt)-1; %Filter orderh = 2*fL*ones(size(tt)); %Initialize impulse response h(t)ix = find(tt~=0); %Avoid division by zeroh(ix) = sin(2*pi*fL*tt(ix))./(pi*tt(ix));if alfa~=0h2 = ones(size(tt)); %Initialize impulse response h2(t)h2(ix) = sin(2*pi*alfa*fL*tt(ix))./(2*pi*alfa*fL*tt(ix));h = h.*h2; %h(t) for H(f) of trapezoidal LPF

endyt = filter(h,1,[xt zeros(1,ixk)])/Fs; %Filter output y(t)yt = yt(ixk+1:end); %Filter delay compensation

To measure the frequency response of a CT filter in the form of the FS coefficients Hk

of its unit impulse response, the following approach can be used. First, note that the FScoefficients of a unit impulse δ(t), repeated with period T0, are

∆k =1

T0

∫T0

δ(t) e−j2πkt/T0︸ ︷︷ ︸= δ(t) e−j0

dt =1

T0

∫T0

δ(t) dt =1

T0

, all k .

Thus, the periodic CT waveform x(t) = T0 δ(t) with period T0, creates all frequencies f =k/T0 with magnitude 1 (and phase 0). If this is used as input waveform to test a filter, thenthe output, which is generally called h(t), gives rise to FS coefficients Hk which characterizethe frequency response of the filter. The DT counterpart of the unit impulse waveform x(t)is

xn = N δn ⇐⇒ Xk = N

N−1∑n=0

δn e−j2πkn/N = N , k = 0, 1, 2, . . . , N − 1 .

9

Page 10: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

The following Matlab script uses this to compute and display (using showFS) the frequencyresponse Hk of a trapezoidal LPF with cutoff frequency fL = 400 Hz.

Frequency Response of Trapezoidal LPF

Fs = 8000; %Sampling ratefL = 400; %Cutoff frequency of LPFk = 5; %Truncation parameter kalpha = 0.2; %Rolloff Prameter alphatlen = 0.1; %Duration of signal

tt = [0:floor(tlen*Fs)-1]/Fs; %Time axistt = tt-tlen/2; %Make symmetric around t=0N = length(tt); %Blocklength Ndeltat = zeros(size(tt)); %Prepare unit impulse[aux ix] = min(abs(tt)); %Find t~0deltat(ix) = N; %Unit impulse (area 1)[ht ord] = trapLPF(deltat,Fs,fL,k,alpha);ht = fftshift(ht); %Swap left and right half of h(t)

showFS(ht,Fs,[0 2000])

The resulting graph of |Hk| and ∠Hk versus frequency f = kFs/N is shown below.

0 200 400 600 800 1000 1200 1400 1600 1800 20000

0.2

0.4

0.6

0.8

1

1.2

1.4

|Hk|

FS Coefficient Approximation for h(t), N=800, Fs=8000 Hz, ∆f=10 Hz

0 200 400 600 800 1000 1200 1400 1600 1800 2000−200

−100

0

100

200

f = k*Fs/N [Hz]

∠ H

k [deg

]

10

Page 11: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

This filter is a linear phase finite impulse response (FIR) filter with delay compensation andthus the phase in the passband is zero and the phase in the stopband is either zero or ±180.That is a luxury that is usually too expensive for practical implementations because it iscomputationally quite expensive. In order to compute the FS coefficients correctly, the upperand lower halves of ht need to be swapped using the ht = fftshift(ht) command. Thisis a consequence of the fact that the FFT is computed over the range n = 0, 1, 2, . . . , N − 1and not over n = −N/2, . . .− 1, 0, 1, . . . N/2− 1 (or (N − 1)/2, . . .− 1, 0, 1, . . . (N − 1)/2 forodd N).

A BPF with center frequency fc and bandwidth W can be obtained quite easily from aLPF with cutoff frequency fL and unit impulse response hL(t) by setting fL = W/2 andcomputing the BPF unit impulse response hB(t) as

hB(t) = 2 hL(t) cos(2πfct) .

For an ideal BPF hL(t) is set to

hL(t) =sin(πWt)

πt, −∞ < t <∞ .

To obtain a physically realizable BPF, the “tails” of hB(t) (which come from hL(t)) must becut off at some point, e.g., at ±k/W for some integer k. As was the case for an LPF withtruncated hL(t), this leads to sidelobes in the magnitude of the frequency response which donot decrease rapidly. This can be improved by allowing for a more gradual transition frompassband to stopband, e.g., in the form of a trapezoidal-shaped magnitude of the frequencyresponse which is controlled by a parameter α with 0 ≤ α ≤ 1. A Matlab function file thatimplements such a BPF is given below.

Trapezoidal BPF Function trapBPF

function [yt,ord] = trapBPF(xt,Fs,fc,W,k,alfa)%trapBPF Bandpass filter with trapezoidal frequency response% magnitude and delay compensation. The input signal% xt and the output signal yt are sampled with sampling% rate Fs. The center frequency is fc in Hz and the% bandwidth (-6 dB) is W in Hz. The parameter k% (default 5) controls the cutoff of the (otherwise% infinite) unit impulse response length. The parameter% alfa (range 0 to 1, default 0.2) controls the% transition from passband to stopbands. The returned% variable ord is the filter order (number of memory% cells) used by the filter. The filter is a FIR filter% with linear phase.% Command format: [yt,ord] = trapBPF(xt,Fs,fc,W,k,alfa)

Continued on next page.

11

Page 12: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

if nargin<6alfa = 0.2; %Default for parameter alfa

endif nargin<5k = 5; %Default for parameter k

endixk = round(Fs*k/W); %Tail cutoff indextt = [-ixk:ixk]/Fs; %Time axis for h(t)ord = length(tt)-1; %Filter orderh = W*ones(size(tt)); %Initialize impulse response h(t)ix = find(tt~=0); %Avoid division by zeroh(ix) = sin(pi*W*tt(ix))./(pi*tt(ix));if alfa~=0h2 = ones(size(tt)); %Initialize impulse response h2(t)h2(ix) = sin(pi*alfa*W*tt(ix))./(pi*alfa*W*tt(ix));h = h.*h2; %h(t) for H(f) of trapezoidal LPF

endh = 2*h.*cos(2*pi*fc*tt); %BPF unit impulse responseyt = filter(h,1,[xt zeros(1,ixk)])/Fs; %Filter output y(t)yt = yt(ixk+1:end); %Filter delay compensation

This is again a FIR filter with linear phase and delay compensation. Here is an exampleof the frequency response (with linear magnitude display so that the trapezoidal shape isvisible) of a BPF with fc = 500 Hz and W = 200 Hz.

0 100 200 300 400 500 600 700 800 900 10000

0.2

0.4

0.6

0.8

1

1.2

1.4

|Hk|

FS Coefficient Approximation for h(t), N=1600, Fs=8000 Hz, ∆f=5 Hz

0 100 200 300 400 500 600 700 800 900 1000−200

−100

0

100

200

f = k*Fs/N [Hz]

∠ H

k [deg

]

12

Page 13: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

The parameters k and α were chosen as k = 5 and α = 0.2.

5 Amplitude Modulation

Mathematically, the simplest form of amplitude modulation is obtained by multiplying acarrier signal of the form c(t) = Ac cos(2πfct + θc) with a message signal m(t) to obtain

x(t) = m(t) Ac cos(2πfct + θc) .

The quantities Ac, fc, and θc are called carrier amplitude, carrier frequency, and carrierphase, respectively. A simple example for m(t) is a sinusoidal signal of the form m(t) =cos(2πfmt + θm) with frequency fm fc and phase θm. In this case

x(t) = Ac cos(2πfmt + θm) cos(2πfct + θc)

=Ac

2

[cos(2π(fc − fm)t + θc − θm) + cos(2π(fc + fm)t + θc + θm)

],

where the trigonometric identity

cos α cos β =1

2[cos(α− β) + cos(α + β)] ,

was used. The two graphs below show m(t) and x(t) for fm = 100 Hz, θm = −90 (thusm(t) = sin(2π100t)), Ac = 1, fc = 1000 Hz, and θc = 0.

0 2 4 6 8 10 12 14 16 18 20−1

−0.5

0

0.5

1

Mes

sage

Sig

nal m

n(t)

Amplitude Modulation: AM−DSB−SC, Ac=1, f

c=1000 Hz, f

m=100 Hz

0 2 4 6 8 10 12 14 16 18 20−1

−0.5

0

0.5

1

t [ms]

AM

Sig

nal x

(t)

13

Page 14: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

Note that every zero crossing of m(t) (at t = n/(2fm), n = 1, 2, 3, . . .) causes a phase changeby 180 in the sinusoidal carrier waveform. Thus, strictly speaking, this form of modulationaffects both the amplitude and the phase of the carrier. In the frequency domain this AMsignal has the following spectrum.

−1500 −1000 −500 0 500 1000 15000

0.05

0.1

0.15

0.2

0.25

0.3

0.35

|Xk|

FS Coefficient Approximation for x(t), N=44100, Fs=44100 Hz, ∆f=1 Hz

−1500 −1000 −500 0 500 1000 1500−200

−100

0

100

200

f = k*Fs/N [Hz]

∠ X

k [deg

]

There are two (positive) frequency components, one at fc− fm (at 900 Hz), called the lowersideband, and one at fc+fm (at 1100 Hz) called the upper sideband. Thus, the single messagefrequency fm gives rise to two spectral lines in the AM signal. Note also that there is nospectral line at the carrier frequency fc itself whenever m(t) is dc-free. Consequently, thisform of amplitude modulation is called AM-DSB-SC, where DSB stands for double sidebandand SC stands for suppressed carrier. Looking at the phase graph in the figure above, noticethat the upper sideband has a phase of −90 and the lower sideband has a phase of +90,which implies that

x(t) =1

2

[− sin(2π(fc − fm)t) + sin(2π(fc + fm)t)

],

with fc − fm = 900 Hz and fc + fm = 1100 Hz. This is a consequence of the trigonometricidentity

sin α cos β =1

2

[sin(α− β) + sin(α + β)

],

and the use of sin(2πfmt) for m(t).

14

Page 15: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

At the receiver, the received signal r(t) is multiplied by a locally generated carrier signalcLO(t) = 2 cos(2πfct + θc). Assuming that r(t) is an attenuated copy of x(t), i.e.,

r(t) = γ x(t) = γ m(t) Ac cos(2πfct + θc) ,

where γ is the attenuation factor, this yields

v(t) = r(t) cLO(t) = γ m(t) Ac cos(2πfct + θc) 2 cos(2πfct + θc)

= 2 γ Ac m(t) cos2(2πfct + θc) = γ Ac m(t) [1 + cos(4πfct + 2θc)]

= γ Ac m(t)︸ ︷︷ ︸m(t) attenuated

+ γ Ac m(t) cos(4πfct + 2θc)︸ ︷︷ ︸AM-DSB-SC signal at 2fc

,

where the trigonometric identity cos2 α = (1 + cos(2α))/2 was used. Thus, v(t) contains thedesired message signal m(t) (scaled by γ Ac) and another AM-DSB-SC signal with carrieramplitude γAc, carrier frequency 2fc, and carrier phase 2θc. If v(t) is lowpass filtered with acutoff frequency fL greater than or equal to the maximum frequency fmx in m(t), then theAM-DSB-SC signal at 2fc is removed (provided that fc ≥ fmx which is generally the case)and the estimate m(t) = γ Ac m(t) of the transmitted message signal m(t) is received. Thiswhole process of AM-DSB-SC modulation and demodulation is depicted in the followingblock diagram.

m(t) ×

x(t)

Ac cos(2πfct + θc)

r(t)

× LPFat fL

m(t)

2 cos(2πfct + θc)

v(t)

The blockdiagram for AM-DSB-SC tacitly assumes that the receiver is able to produce alocal oscillator signal cLO(t) = 2 cos(2πfct+θc) with the same fc and θc that the transmitteruses. In practice it is unrealistic to assume that this is the case unless some additional(fairly sophisticated) circuitry at the receiver actively tracks fc and θc. When commercialAM radio broadcasting started in the 1920’s no such circuitry was available and a differentapproach had to be taken. For AM-DSB-SC we saw that the phase of the carrier changes by180 whenever the message signal m(t) has a zero crossing. If those phase changes can beavoided, then the synchroniztion requirements at the receiver can be relaxed considerably.Thus, commercial AM radio uses the signal 1 + α mn(t) instead of the message signal m(t)to modulate the carrier c(t) = Ac cos(2πfct + θc) as shown in the following block diagram.

mn(t) +α ×

x(t)1

Ac cos(2πfct + θc)

1 + αmn(t)

15

Page 16: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

To ensure that 1 + α mn(t) ≥ 0 (thereby avoiding phase changes of the carrier), the modu-lation index α has to satisfy 0 ≤ α ≤ 1 and a normalized message signal

mn(t) =m(t)

maxτ m(τ),

with amplitude 1 is used instead of the more general m(t). An example of this type ofAM signal is shown in the figure below for mn(t) = cos(2πfmt + θm) with fm = 100 Hz,θm = −90, α = 2/3, Ac = 1, fc = 1000 Hz, and θc = 0.

0 2 4 6 8 10 12 14 16 18 20−1

−0.5

0

0.5

1

Mes

sage

Sig

nal m

n(t)

Amplitude Modulation: AM−DSB−TC, Ac=1, f

c=1000 Hz, f

m=100 Hz, α=0.66667

0 2 4 6 8 10 12 14 16 18 20−2

−1

0

1

2

t [ms]

AM

Sig

nal x

(t)

Note that now the carrier signal waveform has no phase changes and all the information aboutmn(t) is contained in the envelope (following the positive peaks) of x(t). The spectrum ofthis AM signal in the frequency domain is shown next.

16

Page 17: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

−1500 −1000 −500 0 500 1000 15000

0.1

0.2

0.3

0.4

0.5

|Xk|

FS Coefficient Approximation for x(t), N=44100, Fs=44100 Hz, ∆f=1 Hz

−1500 −1000 −500 0 500 1000 1500−200

−100

0

100

200

f = k*Fs/N [Hz]

∠ X

k [deg

]

The largest spectral component of x(t) is the carrier component at fc = 1000 Hz with amagnitude of Ac/2 (= 0.5 in the graph above). The sidebands are still at fc − fm (900 Hz)for the lower sideband and at fc + fm (1100 Hz) for the upper sideband. The magnitudesof the sidebands are αAc/4 (= 1/6 in the graph above). From the phase plot we can seethat the carrier is a cosine (θc = 0), the upper sideband is a positive sine (−90), and thelower sideband is a negative sine (+90). Because of the presence of the carrier and boththe lower and upper sidebands, this AM signal is called AM-DSB-TC, where TC stands fortransmitted carrier. One feature of AM-DSB-TC signals to note is that, even in the bestcase when α = 1, the average power in the sidebands (4 A2

c/16 = A2c/4) which carry all the

information about the message signal mn(t) is only one half of the average power in thecarrier (2 A2

c/4 = A2c/2). In practice, if mn(t) is a speech or music signal, the information

carrying sidebands typically only get a few percent of the total average power and everythingelse goes into the carrier. The principal advantage of transmitting the carrier component isease of demodulation at the receiver. Taking the absolute value

v(t) = abs(r(t)) ,

where r(t) = γ x(t) is the received attenuated (by γ) AM-DSB-TC signal, yields a rectified(non-negative) signal whose envelope is γAc (1+α mn(t)). This is shown for the AM-DSB-TCexample with fm = 100 Hz and fc = 1000 Hz in the next plot.

17

Page 18: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

0 2 4 6 8 10 12 14 16 18 200

0.5

1

1.5

2

t [ms]

Sig

nal v

(t)=

abs(

r(t)

)

Amplitude Modulation: AM−DSB−TC, Ac=1, f

c=1000 Hz, f

m=100 Hz, α=0.66667

Because 1 + α mn(t) ≥ 0,

v(t) = abs(r(t)) = abs(γ Ac (1 + α mn(t)) cos(2πfct + θc)

)= γ Ac (1 + α mn(t)) abs

(cos(2πfct + θc)

),

i.e., 1 + α mn(t)) is not affected by the abs(.) operation. Since q(t) = abs(cos(2πfct + θc)

)has Fourier series representation

q(t) =∞∑

k=−∞

Qk ej2πkt/T0 , where Qk =1

T0

∫ T0/2

−T0/2

abs(cos(2πfct + θc)

)e−j2πkt/T0 dt ,

and T0 = 1/(2fc), v(t) can be written as

v(t) = γ Ac (1 + α mn(t)) Q0︸ ︷︷ ︸baseband term w(t)

+γ Ac (1 + α mn(t))∞∑

k=1

[Qk ej2πkt/T0 + Q−k e−j2πkt/T0

].

The first term in this expression is the baseband term that contains a scaled and offsetversion of mn(t) and the other terms are AM-DSB-TC signals at the harmonics 2kfc, k =1, 2, 3, . . ., of the signal q(t). Passing v(t) through a lowpass filter with fL = fmx wherefmx is the maximum frequency in mn(t) removes the components at 2kfc for k ≥ 0 andpasses the baseband term w(t) = γ Ac (1 + α mn(t)) Q0. After removing the dc term (e.g.,by subtracting the mean of the signal w(t)), this yields the estimate m(t) = γαAcQ0 mn(t))of the transmitted message signal mn(t). The process of demodulating r(t) and obtainingm(t) is shown in the block diagram below.

r(t) abs(.)LPFat fL

m(t)v(t) w(t)

18

Page 19: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

The last block in the diagram between w(t) and m(t) is labeled with the symbol of a capacitorto indicate that it removes the dc component from w(t). Note that no reference is madein this receiver to either the carrier frequency fc or the carrier phase θc and therefore nosynchronization between transmitter and receiver is needed. The price for this convenienceis paid in the form of the carrier power that the transmitter needs to invest.

6 Mixers and Frequency Shifting

Consider the general case where

r(t) = s(t) cos(2πfct + θc) , and c(t) = 2 cos(2πfLOt + θLO) ,

are two sinusoidal signals with frequencies fc and fLO. The typical interpretations of fc andfLO are as the carrier frequency of a AM signal and as the frequency of a local oscillator,respectively. The product v(t) = r(t) c(t) can be written as

v(t) = s(t) cos(2πfct + θc) 2 cos(2πfLOt + θLO)

= s(t)[cos(2π(fc − fLO)t + θc − θLO) + cos(2π(fc + fLO)t + θc + θLO)

].

Usually only one of the two terms, either the one at fc−fLO (or fLO−fc with phase θLO−θc

if fLO > fc), or the one at fc + fLO are kept and the other one is suppressed, using a filteras shown in the block diagram below.

r(t) × Filter w(t)

c(t)

v(t)

For the purpose of demodulating a received AM signal r(t), fLO = fc (and θLO = θc) is thecarrier frequency of the desired signal and the filter is a LPF with cutoff frequency fL abovethe maximum frequency in the message signal.

However, if many radio signals are transmitted at the same time, then the question ariseshow to separate them at the receiver. If they are all of similar strength and have nicelyseparated carrier frequencies, then picking out one particular signal can be done relativelyeasily with an AM-DSB-SC receiver by selecting the right fc and θc. But even in the bestcase, an AM-DSB-TC receiver based on lowpass filtering the absolute value abs(r(t)) of thereceived signal will not be able to separate radio signals with different carrier frequencieswithout some additional filtering. Conceptually, the most straightforward way to pick aradio signal at a particular fc is to use a BPF that only passes a fairly narrow range offrequencies around fc. For commercial AM radio, for instance, fc would be approximately1 MHz and the bandwidth W of the BPF would have to be 10 kHz or less, i.e., about 1%of fc. Moreover, to receive different radio stations, it would be necessary to tune the center

19

Page 20: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

frequency of the BPF from about 500 kHz to 1.6 MHz, a tuning range of 3:1. Such a tunableBPF is difficult to implement with analog circuitry. It is much easier to build a narrowbandBPF with a fixed center frequency fIF (where IF stands for intermediate frequency) and thento move the desired carrier frequency fc to fIF using a mixer that multiplies the receivedsignal r(t) with a local oscillator signal c(t) as shown in the next figure.

r(t)=s(t) cos(2πfct + θc) × BPFfIF , WIF

w(t)=s(t) cos(2πfIF t + θIF )

c(t)=2 cos(2πfLOt + θLO)

v(t)

Using the expression

v(t) = s(t)[cos(2π(fc − fLO)t + θc − θLO) + cos(2π(fc + fLO)t + θc + θLO)

],

derived earlier, we can distinguish 3 different cases:

Case 1: fIF = fc − fLO, θIF = θc − θLO ⇒ fc = fLO + fIF ,

Case 2: fIF = fLO − fc, θIF = θLO − θc ⇒ fc = fLO − fIF ,

Case 3: fIF = fc + fLO, θIF = θc + θLO ⇒ fc = fIF − fLO , or fc = fLO − fIF .

Recall that the cosine is an even function of its argument, i.e., cos(−α) = cos(α). Whenconsidering the relationship between fc, fLO, and fIF , only positive frequencies are consideredand it is understood that, for r(t), c(t), and w(t) to be real, the negative frequencies mustsatisfy the same relationship as the positive ones (so that ej2πft + e−j2πft = 2 cos(2πft)).Case 1 occurs when fLO ≤ fc. For case 2 fLO > fc. In case 3 fc = fIF − fLO if fLO ≤ fIF ,otherwise fc = fLO − fIF . Expressed in a more compact fashion, fc = |fLO − fIF |. Thus,combining all three cases, for given fLO and fIF , there are always two (positive) carrierfrequencies, namely

fc1 = |fLO − fIF | , and fc2 = fLO + fIF ,

which, after mixing with the local oscillator signal c(t), pass through the BPF at the fixedcenter frequency fIF and appear in w(t) at the output of the BPF. One of those two frequen-cies is the carrier frequency of the desired signal and the other one is the carrier frequencyof the image signal. To suppress the image signal, a second BPF is necessary in front of themixer as shown in the block diagram below.

r(t)at fc

BPFfRF , WRF

× BPFfIF , WIF

w(t)at fIF

c(t) at fLO

wideband narrowband

rBP (t) v(t)

20

Page 21: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

The obvious question to ask is “What did we gain?”. Instead of just one BPF to single outthe signal at the desired carrier frequency, two BPFs are now used. The answer to this isthat the second BPF at fIF is a narrowband BPF with a fixed center frequency, whereas thefirst BPF is a much simpler wideband filter whose center frequency may depend loosely onthe carrier frequency of the desired signal.

As an example, consider a receiver for the range of fc from 5.7 to 6.5 MHz. Let fIF = 700kHz and WIF = 10 kHz. If the local oscillator frequency is chosen to be above fc, thenfLO = 6.4 . . . 7.2 MHz. In this case fc1 = |fLO − fIF | = 5.7 . . . 6.5 MHz is the range ofdesired carrier frequencies and fc2 = fLO + fIF = 7.1 . . . 7.9 MHz is the range of carrierfrequencies for the (undesired) image signals. Thus, the first BPF can use a center frequencyof fRF = 6.1 MHz and a bandwidth of WRF ≈ 800 . . . 2000 kHz. With this configuration areceiver is obtained with a selectivity of 10 kHz across the 5.7 to 6.5 MHz band.As another example, consider the NorCal 40A receiver. The desired carrier frequencies arein the range fc = 7.0 . . . 7.15 MHz and the second BPF has parameters fIF = 4.915 MHzand WIF = 400 Hz. The local oscillator frequency is chosen to be below fc and coversthe range fLO = 2.085 . . . 2.235 MHz. Therefore, fc2 = fLO + fIF = 7.0 . . . 7.15 MHz arethe desired carrier frequencies and fc1 = |fLO − fIF | = 2.68 . . . 2.83 MHz are the carrierfrequencies of the (undesired) image signals. The first BPF can be chosen with a centerfrequency fRF ≈ 7 MHz and a bandwidth of ≈ 8 MHZ or less. In this way a receiver forthe 7.0 . . . 7.15 MHz band is obtained with approximately 300 different 500 Hz slots, each ofwhich can accomodate a Morse code communication signal.

7 Problems

1) FFT Approximation to FS. (a) Generate the following sum of two sinusoids in Matlab:

Fs = 8000; %Sampling rate

A1 = 1; %Amplitude 1

f1 = 2000; %Frequency 1

theta1 = -90; %Phase 1

A2 = 1; %Amplitude 2

f2 = 2010; %Frequency 2

theta2 = 0; %Phase 2

tlen = 0.2; %Time duration

tt = [0:floor(tlen*Fs)-1]/Fs; %Time axis

s1t = A1*cos(2*pi*f1*tt+pi/180*theta1);

%Sinusoidal signal s1(t)

s2t = A2*cos(2*pi*f2*tt+pi/180*theta2);

%Sinusoidal signal s2(t)

xt = s1t + s2t; %Sum of s1(t) and s2(t)

21

Page 22: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

Display the FFT approximation of the FS coefficients Xk of x(t) using the showFS functionwith ff_lim=[-2500 2500]. Compare the graph that you get with the one given earlier inthis problem set. To see what happens to the phase plot when the phase is not blankedout for the Xk components with small magnitude, change llim = 1e-3 to llim = 0 in theshowFS function. Report what you see in your solution.

(b) In the script file in part (a), change A2 = 1 to A2 = 0.01. Now xt is a sum of twosinusoids with very different amplitudes. When you use showFS now to compute and displaythe FS coefficients Xk of x(t) it will look as if there is only one frequency component. Inwireless communications signal powers can vary widely and it is important to be able to seesamll signals even in the presence of big ones. To be able to see both frequency componentsin xt, modify showFS so that it displays 20 log(|Xk|) instead of |Xk| for the magnitudedisplay. Note that the logarithm is taken to the base 10 (log10 in Matlab). Call the newversion of showFS showFSdB. To get the display to look right you will also have to replacethe stem command with a plot command for the magnitude of Xk display.

(c) The .wav file sinusoids.wav contains sinusoidal signals with different amplitudes, fre-quencies, and phases. Listen to the signal. Can you tell how many sinusoids there are?Use your showFSdB function from part (b) to find all components in sinusoids.wav. De-termine the frequency and the phase of each component and express the amplitudes of thecomponents in dB with respect to the largest component.

2) Lowpass and Bandpass Filters. (a) Use the Matlab function trapLPF with Fs = 44100Hz to design a LPF with a -3 dB cutoff frequency of 700 Hz (i.e., all frequencies up to 700Hz must be passed with at most 3 dB attenuation) and a -40 dB stopband starting at 800Hz (i.e., all frequencies greater or equal to 800 Hz must be attenuated by at least 40 dB.Write a script file that displays the frequency response of the LPF with a resolution of 1Hz. Use (educated) trial and error to choose the parameters k and α. The goal is to satisfythe requirements with as small a filter order (returned in ord by the trapLPF function) aspossible. Include the order of your filter in the solution. Here is an example of a frequencymagnitude that satisfies the requirements with a filter order of 1212.

0 200 400 600 800 1000 1200 1400 1600 1800 2000−60

−50

−40

−30

−20

−10

0

10

|Hk| i

n dB

FS Coefficient Approximation for h(t), N=44100, Fs=44100 Hz, ∆f=1 Hz

(b) Use the Matlab function trapBPF with Fs = 44100 Hz to design a BPF with a -3 dBpassband from 1300 to 1700 Hz and -40 dB stopbands for f ≤ 1250 Hz and f ≥ 1750 Hz.

22

Page 23: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

Display the frequency response of the BPF with a resolution of 1 Hz and use (educated)trial and error to choose the parameters k and α. As in part (a), the goal is to satisfythe requirements with as small a filter order (returned in ord by the trapLPF function) aspossible. Include the order of your filter in the solution.

(c) Generate a rectangular waveform of duration 1 second with fundamental frequency fm =500 Hz using the Matlab command

st = sign(cos(2*pi*fm*tt));

Use a sampling frequency of Fs = 44100 Hz. Use the filters you found in parts (a) and (b)to filter the signal st. Listen to the original signal and the signals at the output of the LPFand the BPF. Describe the different signals you hear. Make a labeled plot that shows thefirst 10 ms of the three signals in the same graph.

3) Amplitude Modulation and Mixing. (a) Use the following Matlab commands togenerate an AM-DSB-SC signal with carrier frequency fc = 1500 Hz and sinusoidal messagesignal with frequency fm = 200 Hz.

Fs = 44100; %Sampling rate

Ac = 1.0; %Carrier amplitude 1

fc = 1500; %Carrier frequency 1

thetac = 0; %Carrier phase 1

fm = 200; %Message frequency

thetam = -90; %Message phase

tlen = 1; %Signal duration

tt = [0:floor(tlen*Fs)-1]/Fs; %Time axis

mt = cos(2*pi*fm*tt+(pi/180)*thetam);

%Message signal

mnt = mt/(max(abs(mt))); %Normalized message signal

xt = Ac*mnt.*cos(2*pi*fc*tt+(pi/180)*thetac);

%AM-DSB-SC signal

Display the spectrum of xt in the range -5000 to 5000 Hz using the showFS or the showFSdB

function and listen to the xt signal with the sound(xt,Fs) command. Then use the followingblockdiagram for AM-DSB-SC to write a Matlab script file that acts as receiver for the signalr(t). Set r(t) equal to x(t) (in a real wireless communication situation r(t) is an attenuatedand noisy version of x(t)).

m(t) ×

x(t)

Ac cos(2πfct + θc)

r(t)

× LPFat fL

m(t)

2 cos(2πfct + θc)

v(t)

23

Page 24: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

Look at the spectrum of v(t). Which frequency components does it have? Which componentsdoes the receiver need to remove? Use the trapLPF function with appropriate fL to removethe unwanted components and only pass the estimate m(t) of the transmitted message signalm(t). Look at the spectrum of m(t), listen to it, and compare it to m(t) to ensure that yourreceiver works right. What happens if the receiver fc frequency differs from the transmitterfc frequency by 1 or 2 Hz? What happens if the receiver phase θc differs from the transmitterphase θc by 90? Can you explain the phenomena that you observe?

(b) What happens to the AM-DSB-SC transmission in (a) if you replace

xt = Ac*mnt.*cos(2*pi*fc*tt+(pi/180)*thetac);

by

xt = Ac*mnt.*sign(cos(2*pi*fc*tt+(pi/180)*thetac));

Is it still an AM-DSB-SC signal? What does the spectrum look like? Can you use the samereceiver as in (a) to demodulate the signal? What if you would like to have an AM-DSB-SCsignal with a carrier frequency of 3fc? Could you use the trapBPF function to obtain sucha signal?

(c) Look at the two block diagrams below. The first one is the block diagram of a AM-DSB-TC transmitter.

mn(t) +α ×

x(t)1

Ac cos(2πfct + θc)

1 + αmn(t)

The second one is the block diagram of a AM-DSB-TC receiver (envelope detector).

r(t) abs(.)LPFat fL

m(t)v(t) w(t)

Note that this receiver does not need to know the fc and the θc that was used at thetransmitter. Write a Matlab script file that generates a AM-DSB-TC-Signal x(t) and thendemodulates it using the above receiver block diagram. Use the same Fs, fc and fm as inpart (a). Use α = 0.8 for the modulation index. Look at the spectra of the x(t), v(t) andw(t) signals. The last block in the receiver (with the capacitor symbol) removes any dccontent before m(t) is output. What solutions would you propose for this purpose? Could

24

Page 25: ECEN 2420 Wireless Electronics for Communication …ecee.colorado.edu/~mathys/ecen2420/pdf/ps02.pdfECEN 2420 Wireless Electronics for Communication Spring 2012 01-30-12 P. Mathys Problem

you possibly combine the LPF and the dc removal into one processing function? Listen tom(t) and compare it to m(t) to make sure that your receiver works right. What happens ifyou use this receiver for the AM-DSB-SC signal that you generated in part (a)? Can youexplain why this happens?

(d) The two .wav files AMsig003.wav and AMsig004.wav contain AM-DSB signals withsinusoidal message signals. Determine as many parameters of these signals, such as the carrierfrequency, the carrier phase, the message frequency, the message phase, the modulationindex, and the amplitudes as possible. Demodulate the signals using the receiver scriptsthat you generated in part (a) and part (c).

c©2012, P. Mathys. Last revised: 2-04-12, PM.

25