Commsys Lab Freq Modulation Matlab Report
-
Upload
mahin-akhtar -
Category
Documents
-
view
104 -
download
0
Transcript of Commsys Lab Freq Modulation Matlab Report
COMMUNICATION SYSTEMS-I (LAB)
ASSIGNMENT
(Frequency modulation and demodulation in MATLAB)
Submitted to:
Sir Zeeshan
Submitted by:
NS Sana Mazahir (093)NS Anika Sadiq (084)NS Mahin Akhtar (088)DE -31 EE B
Objective:
Implementing frequency modulation and demodulation of sinusoidal message signal in MATLAB.
Frequency demodulation using the Hilbert Transform:
MATLAB CODE:
clc;%carrier signalAc=1;t1=0:0.25:500;fs=80;f = fs*(0:length(t1)-1)/ length(t1);c=Ac*cos(2*pi*t1);c_f=fft(c);%message signalt2=0:0.0025:5;m=cos(2*pi*t2);m_f=fft(m);%modulation beta=2;sfm=Ac*cos(2*pi*t1+beta*sin(2*pi*t2));sfm_f=fft(sfm);%demodulation using hilbert transform
y1=hilbert(sfm);%same results are obtained if following %signal is used instead of using%hilbert function%y1=Ac*cos(2*pi*t1+beta*sin(2*pi*t2))%+i*Ac*sin(2*pi*t1+beta*sin(2*pi*t2));y2=conj(y1);%delaying the signaly3=1:1:length(y2);y3(1)=1 + 0.51i;for j=2:length(y2) y3(j)=y2(j-1);endy=angle(y1.*y3);y_f=fft(y);%plotssubplot(4,2,1),plot(c,'color','black','linewidth',2);title('Carrier signal c(t)');xlabel('samples');ylabel('amplitude');subplot(4,2,2),plot(f,abs(c_f),'color','black','linewidth',2);title('Carrier signal C(f)');xlabel('frequency');ylabel('amplitude');subplot(4,2,3),plot(m,'color','black','linewidth',2);title('Message signal m(t)');xlabel('samples');ylabel('amplitude');subplot(4,2,4),plot(f,abs(m_f),'color','black','linewidth',2);title('Carrier signal M(f)');xlabel('frequency');ylabel('amplitude');subplot(4,2,5),plot(sfm,'color','black','linewidth',2);title('Modulated signal s(t)');xlabel('samples');ylabel('amplitude');subplot(4,2,6),plot(f,abs(sfm_f),'color','black','linewidth',2);title('Modulated signal S(f)');xlabel('frequency (kHz)');ylabel('amplitude');subplot(4,2,7),plot(y,'color','black','linewidth',2);title('Demodulated signal y(t)');xlabel('samples');ylabel('amplitude');subplot(4,2,8),plot(f,abs(y_f),'color','black','linewidth',2);title('Demodulated signal Y(f)');xlabel('frequency (kHz)');ylabel('amplitude');%DC shift in the demodulated wavey_dc=mean(y);%amplitude of demodulated signaly_amp=max(y(500:1500))-mean(y);%maximum value in steady state is useddisplay(y_dc);display(y_amp);%comparing message signal and demodulated signalfigure(2)plot(m,'color','black','linewidth',2);
hold onplot(y,'color','black','linewidth',2);title('Comparison of message signal and demodulated signal');xlabel('samples');ylabel('amplitude');
RESULTS:
For β=2:
0 500 1000 1500 2000 2500-1
0
1Carrier signal c(t)
samples
ampli
tude
0 10 20 30 40 50 60 70 800
500
1000Carrier signal C(f)
frequencyam
plitud
e
0 500 1000 1500 2000 2500-1
0
1Message signal m(t)
samples
ampli
tude
0 10 20 30 40 50 60 70 800
1000
2000Carrier signal M(f)
frequency
ampli
tude
0 500 1000 1500 2000 2500-1
0
1Modulated signal s(t)
samples
ampli
tude
0 10 20 30 40 50 60 70 800
500
1000Modulated signal S(f)
frequency (kHz)
ampli
tude
0 500 1000 1500 2000 25000
1
2Demodulated signal y(t)
samples
ampli
tude
0 10 20 30 40 50 60 70 800
2000
4000Demodulated signal Y(f)
frequency (kHz)
ampli
tude
0 500 1000 1500 2000 2500-1
-0.5
0
0.5
1
1.5
2Comparison of message signal and demodulated signal
samples
ampl
itude
For β=5:
0 500 1000 1500 2000 2500-1
-0.5
0
0.5
1
1.5
2Comparison of message signal and demodulated signal
samples
ampl
itude
For β=10:
0 500 1000 1500 2000 2500-1
-0.5
0
0.5
1
1.5
2Comparison of message signal and demodulated signal
samples
ampl
itude
Mathematical justification for the small amplitude and DC shift in demodulated signal:
The modulated signal is represented as follows:
(referring Simon haykin, Communication Systems, 4th edition, pg 114, 115)
s ( t )=Ac∗cos (2πfct+ β∗sin (2πfmt ) )
s (t )=Ac Σ (Jn (β )cos (2πfct+2πnfmt ) ) , n=(−∞ ,∞)
S ( f )= Ac2
Σ (Jn (β ) [δ (f −fc−nfm )+δ ( f + fc+nfm ) ] ) , n=(−∞ ,∞)
Let H(f) be the Fourier transform of the Hilbert transform h(t) of s(t), then
H (f )=− j sgn (f )S (f )
H (f )= Ac2
Σ (Jn (β ) [− j δ ( f −fc−nfm )+ jδ (f + fc+nfm ) ]) , n=(−∞,∞)
h (t )=Ac Σ (Jn (β )sin (2 πfct+2πnfmt ) ) , n=(−∞ ,∞)
h( t)=Ac∗sin (2πfct+β∗sin (2πfmt ) )
Thus the Hilbert transform shifts all positive frequencies by –π/2.
Using the ‘hilbert()’ function in matlab returns a complex sequence whose real part contains s(t) and imaginary part contains the Hilbert transform h(t)of s(t). Let this signal be denoted by y1:
y 1(t)=s (t)+ί h (t)
y 1 (t )=Ac∗cos (2πfct+β∗sin (2 πfmt ) )+ί sin (2πfct+β∗sin (2πfmt ) )
Or
y 1 (t )=Ac∗exp ¿
Taking the conjugate of y1,
y 2 (t )=Ac∗cos (2πfct+β∗sin (2 πfmt ) )−ί Ac∗sin (2πfct+β∗sin (2πfmt ) )
Or
y 2 (t )=Ac∗exp ¿
Delaying the signal by 1 sample means is equivalent to delaying it by 1/fs = Ts, where Ts is time interval between two samples and fs is sampling frequency. Let the delayed signal be denoted by y3,
y 3 (t )= y2 (t−Ts )
y 3 (t )=Ac∗cos (2πfc (t−Ts)+β∗sin (2πfm(t−Ts)) )−Ac∗ί sin (2πfc( t−Ts)+β∗sin (2 πfm(t−Ts)) )
Or
y 3 ( t )=Ac∗exp (− j (2πfc ( t−Ts )+β∗sin (2πfm ( t−Ts ) ) ))
Multiplying y1(t) by y3(t):
z (t )=A c2∗exp (− j (2πfc ( t−Ts )+β∗sin (2 πfm ( t−Ts ) ) ))∗exp ¿
z (t )=A c2∗exp ¿
z (t )=A c2∗exp ¿
The ‘angle()’ function computes the phase of the above signal:
y (t )=2πfcTs−β∗sin (2πfm (t−Ts ) )+β∗sin (2πfmt )
Using the identity,
sin ( A )−sin (B )=2∗cos ((A+B)/2)sin ((A−B) /2)
y (t )=2πfcTs+2∗β∗cos (2πfmt−πfmTs ) sin (πfmTs )
Since πfmTs is very small (referring to MATLAB results),
sin (πfmTs )=πfmTs
So the amplitude of the demodulated wave is:
Amp=2∗β∗πfmTs
For β=2,
Amp=2∗2∗π∗20080000
=0.0314
For β=5,
Amp=2∗5∗π∗20080000
=0.0785
For β=10,
Amp=2∗10∗π∗20080000
=0.157
The DC shift in the demodulated signal is:
ydc=2 πfcTs=2 π∗2080
=1.57
The mathematical results obtained above match the MATLAB results.
Frequency demodulation using local carrier and mixer:
MATLAB CODE:
clc;%carrier signalAc=1; t1=0:0.25:2000;fs=80;f = fs*(0:length(t1)-1)/ length(t1);c=Ac*cos(2*pi*t1);c_f=fft(c);%message signalt2=0:0.0025:20;m=cos(2*pi*t2);m_f=fft(m);%modulationbeta=2;sfm=Ac*cos(2*pi*t1+beta*sin(2*pi*t2));sfm_f=fft(sfm);%demodulation%multiplying by local carriery1=sfm.*c;y1_f=fft(y1);%frequency translationy2=2*y1.*cos(2*pi*t2);y2_f=fft(y2);%filtering %low pass filter with fp=290, fs=310load lp_freqmod;y=filter(lp_freqmod,y2);y_f=fft(y);%plotssubplot(4,3,1),plot(c,'color','black');title('Carrier signal c(t)');xlabel('samples');ylabel('amplitude');subplot(4,3,2),plot(f,abs(c_f),'color','black');title('Carrier signal C(f)');xlabel('frequency');ylabel('amplitude');subplot(4,3,3),plot(m,'color','black');title('Message signal m(t)');xlabel('samples');ylabel('amplitude');subplot(4,3,4),plot(f,abs(m_f),'color','black');title('Carrier signal M(f)');xlabel('frequency');ylabel('amplitude');subplot(4,3,5),plot(sfm,'color','black');title('Modulated signal s(t)');xlabel('samples');ylabel('amplitude');subplot(4,3,6),plot(f,abs(sfm_f),'color','black');title('Modulated signal S(f)');
xlabel('frequency (kHz)');ylabel('amplitude');subplot(4,3,7),plot(y1,'color','black');title('signal after multiplication with local carrier y1(t)');xlabel('samples');ylabel('amplitude');subplot(4,3,8),plot(f,abs(y1_f),'color','black');title('signal after multiplication with local carrier Y1(f)');xlabel('frequency (kHz)');ylabel('amplitude');subplot(4,3,9),plot(y2,'color','black');title('Frequency translated signal y2(t)');xlabel('samples');ylabel('amplitude');subplot(4,3,10),plot(f,abs(y2_f),'color','black');title('Frequency translated signal Y2(f)');xlabel('frequency (kHz)');ylabel('amplitude');subplot(4,3,11),plot(y,'color','black');title('Demodulated signal (after filtering) y(t)');xlabel('samples');ylabel('amplitude');subplot(4,3,12),plot(f,abs(y_f),'color','black');title('Demodulated signal (after filtering) Y(f)');xlabel('frequency (kHz)');ylabel('amplitude');%DC shift in the demodulated wavey_dc=mean(y);%amplitude of demodulated signaly_amp=max(y(500:1500))-mean(y);%maximum value in steady state is useddisplay(y_dc);display(y_amp);%comparing message signal and demodulated signalfigure(2)subplot(2,1,1),plot(m,'color','black','linewidth',2);title('Comparison of message signal and demodulated signal');xlabel('samples');ylabel('amplitude');subplot(2,1,2),plot(y,'color','black','linewidth',2);xlabel('samples');ylabel('amplitude');
RESULTS:
For β=2:
0 2000 4000 6000 8000 10000-1
0
1Carrier signal c(t)
samples
ampli
tude
0 20 40 60 800
2000
4000Carrier signal C(f)
frequencyam
plitud
e0 2000 4000 6000 8000 10000
-1
0
1Message signal m(t)
samples
ampli
tude
0 20 40 60 800
5000Carrier signal M(f)
frequency
ampli
tude
0 2000 4000 6000 8000 10000-1
0
1Modulated signal s(t)
samples
ampli
tude
0 20 40 60 800
2000
4000Modulated signal S(f)
frequency (kHz)
ampli
tude
0 2000 4000 6000 8000 10000-1
0
1signal after multiplication with local carrier y1(t)
samples
ampli
tude
0 0.2 0.4 0.6 0.8 1 1.20
20
signal after multiplication with local carrier Y1(f)
frequency (kHz)
ampli
tude
0 2000 4000 6000 8000 10000-2
0
2Frequency translated signal y2(t)
samples
ampli
tude
0 0.2 0.4 0.6 0.8 1 1.2
120
140
160
Frequency translated signal Y2(f)
frequency (kHz)
ampli
tude
0 2000 4000 6000 8000 10000-1
0
1Demodulated signal (after filtering) y(t)
samples
ampli
tude
0 10 20 30 400
500
1000Demodulated signal (after filtering) Y(f)
frequency (kHz)
ampli
tude
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-1
-0.5
0
0.5
1Comparison of message signal and demodulated signal
samples
ampl
itude
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-1
-0.5
0
0.5
1
samples
ampl
itude
For β=5:
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-1
-0.5
0
0.5
1Comparison of message signal and demodulated signal
samples
am
plitu
de
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-0.2
-0.1
0
0.1
0.2
samples
am
plitu
de
For β=10:
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-1
-0.5
0
0.5
1Comparison of message signal and demodulated signal
samples
ampl
itude
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-0.01
-0.005
0
0.005
0.01
samples
ampl
itude
Mathematical justification for the frequency component at 2fm when modulated signal is multiplied by local carrier:
The modulated signal is represented as follows:
(referring Simon haykin, Communication Systems, pg 114, 115)
s ( t )=Ac∗cos (2πfct+ β∗sin (2πfmt ) )
s (t )=Ac Σ (Jn (β )cos (2πfct+2πnfmt ) ) , n=(−∞ ,∞)
S ( f )= Ac2
Σ (Jn (β ) [δ (f −fc−nfm )+δ ( f + fc+nfm ) ] ) , n=(−∞ ,∞)
Multiplying s(t) by local carrier,
y 1=cos (2 πfct ) Ac∗cos (2πfct+β∗sin (2πfmt ) )
Multiplication in time domain is periodic convolution in frequency domain:
Y 1 ( f )=conv ( Ac2 Σ (Jn (β ) [δ ( f−fc−nfm )+δ ( f+ fc+nfm ) ] ) , 12
(δ [ f −fc ]+δ [ f + fc ] )),n=(−∞,∞)
Y 1 ( f )= Ac4
Σ ¿
n=(−∞,∞)
Let
G (n )=δ (f −2 fc−nfm )+δ (f +2 fc+nfm )+δ (f −nfm)+δ (f +nfm)
For the low frequency components,
G (n )=G (−n )=δ (f −nfm)+δ (f +nfm)
Bessel function has the property:
Јn (β )=(−1 )n Ј (−n )(β)
Y 1 ( f )= Ac4
Σ (Jn (β )∗G(n))
n=(−∞,∞)
Expanding the summation,
Y 1 ( f )= Ac4
[ ..G (−2 ) Ј (−2 ) (β )+G (−1 ) Ј (−1) (β )+G (0 ) Ј (0) (β )+G (1 )∗Ј (1 ) (β )+G (2 ) Ј (2 ) (β )… ]
For odd values of n,
G (n ) Ј (n ) (β )=−G (−n ) Ј (−n )(β)
and
G (0 ) Ј 0 (β )=0 for β>0
So the odd n terms cancel and Y1(f) contains only even n terms,
Y 1 ( f )= Ac4
[J 2 (β )∗(δ ( f −2 fm )+δ ( f +2 fm ) )+J 4 (β )∗(δ ( f−4 fm )+δ (f +4 fm ) )+J 6 (β )∗(δ (f −6 fm )+δ ( f+6 fm ))+J 8 (β )∗(δ ( f−8 fm )+δ ( f +8 fm ) )+……]
Thus after multiplying the modulated signal by local carrier, the frequency spectrum of the resulting signal y1(t) contains impulses at 2fm, 4fm,6fm,8fm….. with magnitude decreasing with increasing n, which is due to the fact that the Bessel function Јn(β) value decreases for increasing n.