Am Modulation

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Take Home Project # 1

AM Modulation and Demodulation


%**********AMPLITUDE MODULATION AND DEMODULATION***********%
close all;
clear all;
clc;
fs=100000; %SAMPLE FREQUENCY
fm=20; %THREE MESSAGE SIGNAL FREQUENCY
fc=500; %CARRIER FREQUENCY
Am=1; %MESSAGE AMPLITUDE
Ac=1; %CARRIER AMPLITUDE
t=[0:0.1*fs]/fs; %TIME DURATION
m=Am*cos(2*pi*fm*t);
c=Ac*cos(2*pi*fc*t);
ka=0.5;
u=ka*Am;
s1=Ac*(1+u*cos(2*pi*fm*t)).*cos(2*pi*fc*t);
subplot(4,3,1:3);
plot(t,m);
title('Modulating or Message signal(fm=20Hz)');
subplot(4,3,4:6);
plot(t,c);
title('Carrier signal(fc=500Hz)');
subplot(4,3,7);
plot(t,s1);
title('Under Mod signal');
Am=2;
ka=0.5;
u=ka*Am;
s2=Ac*(1+u*cos(2*pi*fm*t)).*cos(2*pi*fc*t);
subplot(4,3,8);
plot(t,s2);
title('Exact Mod signal');
Am=5;
ka=0.5;
u=ka*Am;
s3=Ac*(1+u*cos(2*pi*fm*t)).*cos(2*pi*fc*t);
subplot(4,3,9);
plot(t,s3);
title('Over Mod signal');
r1=s1.*c;
[b a]=butter(1,0.01); %BUTTERWORTH FILTER
mr1=filter(b,a,r1); %DEPTH OF MODULATION
subplot(4,3,10);
plot(t,mr1);
title('DeModulated signal');
r2=s2.*c;
[b a]=butter(1,0.01);
mr2=filter(b,a,r2);
subplot(4,3,11);
plot(t,mr2);
title('DeModulated signal');
r3=s3.*c;
[b a]=butter(1,0.01);
mr3=filter(b,a,r3);
subplot(4,3,12);
plot(t,mr3);
title('DeModulated signal');
figure
s3 = abs(hilbert(Am)); % hilbert transform to calculate the envelope of the
signal
plot(s3,r3);
title('envelop detector');
% Audio Signal
[h,fs]=audioread('Handel.wav');
figure
stem(h)
xlabel ('Time');%taking time on X-axis
ylabel ('Magnitude');%taking magnitude on Y-axis
title ('audio signal');%giving name
grid 'on'

FIGURE:
Modulating or Message signal(fm=20Hz)
1

-1
0 0.01 0.02 0.03 Carrier
0.04 signal(fc=500Hz)
0.05 0.06 0.07 0.08 0.09 0.1
1

-1
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
Under Mod signal Exact Mod signal Over Mod signal
2 2 5
0 0 0
-2 -2 -5
0 0.05 0.1 0 0.05 0.1 0 0.05 0.1
DeModulated signal DeModulated signal DeModulated signal
2 2 5
1 1 0
0 0 -5
0 0.05 0.1 0 0.05 0.1 0 0.05 0.1
envelop detector
3.5

2.5

1.5

0.5

-0.5

-1

-1.5
4 4.2 4.4 4.6 4.8 5 5.2 5.4 5.6 5.8 6

You might also like