AC_LabFile
AC_LabFile
No
onSimulink.
EXPERIMENT - 01
AIM: To study the generation of AM Modulation and Demodulation.
SOFTWARE USED: MATLAB CAMPUS SUITE
SOURCE CODE:
clc;
close all;
clear all;
fs=8000;
fm=20;
fc=500;
Am=1;
Ac=1;
t=[0:0.1*fs]/fs;
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('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 modulated signal(ka.Am=0.5)');
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('perfect modulated signal(ka.Am=1)');
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 modulated signal(ka.Am=2.5)');
r1=s1.*c;
[b,a]=butter(5,2*fc/fs);
mr1 = filter(b,a,r1);
subplot(4,3,10);
plot(t,mr1);
title('Demodulated Signal for (ka*Am=0.5)');
r2 = s2.*c;
[b,a] = butter(5,2*fc/fs);
mr2 = filter(b,a,r2);
subplot(4,3,11);
plot(t,mr2);
title('Demodulated Signal for ka*Am=1');
r3 = s3.*c;
[b,a] = butter(5,2*fc/fs);
mr3 = filter(b,a,r3);
subplot(4,3,12);
plot(t,mr3);
title('Demodulated Signal for ka*Am=2.5');
CODE SNIPPET:
OUTPUT SNIPPET:
EXPERIMENT - 02
AIM: To study the generation of SSB Modulation and Demodulation.
SOFTWARE USED: MATLAB CAMPUS SUITE
SOURCE CODE:
clc;
clear all;
Vm = input("Enter msg amp:");
fm = input("Enter msg freq:");
Vc = input("Enter carrier amp:");
fc = input("Enter carrier freq:");
fs = input("Enter Sampling freq:");
t = 0.1/fs:1;
m = Vm*cos(2*pi*fm*t);
c = Vc*cos(2*pi/fc*t);
Vn = Vm*cos(2*pi*fm*t-(pi/2));
usb = m*2*cos(2*fc*t*pi)-Vn*2*sin(2*pi*fc*t);
subplot(2,3,2);
plot(t,c,'r');
grid;
xlabel('Frequency');
ylabel10('Amplitude');
title('Carrier signal');
subplot(2,3,3);
plot(t,usb,'k');
grid;
xlabel('Frequency');
ylable('Amplitude');
title('USB');
subplot(2,3,4);
plot(t,lsb,'k');
grid;
xlabel('Frequency');
ylabel('Amplitude');
title('LSB');
z=filtfilt(num,den,temp)*2;
z=z-vc;
subplot(2,3,5);
plot(t,z);
grid;
xlabel('time');
ylabel('amp');
title('recieved msg signal');
CODE SNIPPET:
OUTPUT SNIPPET:
EXPERIMENT - 03
AIM: To study the generation of DSB-SC Modulation and Demodulation.
SOFTWARE USED: MATLAB CAMPUS SUITE
SOURCE CODE:
clc;
clear all;
Vm = input('Enter msg ampl ');
fm = input('Enter msg freq ');
Vc = input('Enter carr ampl ');
fc = input('Enter carr freq ');
fs = input('Enter sampling freq ');
t = 0:1/fs:1;
m = Vm*cos(2*pi*fm*t);
c = Vc*cos(2*pi*fc*t);
Vm = Vm*cos(2*pi*fm*t - pi/2);
usb = m.*cos(2*pi*fc*t) - Vm.*sin(2*pi*fc*t);
lsb = m.*cos(2*pi*fc*t) + Vm.*sin(2*pi*fc*t);
subplot(2,3,1);
plot(t,m);
grid;
xlabel('freq');
ylabel('Ampl');
title('carrier signal');
subplot(2,3,2);
plot(t,c);
grid;
xlabel('freq');
ylabel('Ampl');
title('carrier signal');
subplot(2,3,3);
plot(t,usb);
grid;
xlabel('freq');
ylabel('Ampl');
title('USB');
subplot(2,3,4);
plot(t,lsb);
grid;
xlabel('freq');
ylabel('Ampl');
title('LSB');
subplot(2,3,5);
plot(t,m);
xlabel('freq');
ylabel('Ampl');
title('carrier signal');
temp = usb.*cos(2*pi*fc*t);
[num,den] = butter(5,2*fc/fs);
z = filter(num,den,temp);
z = z - Vc;
subplot(2,3,5);
plot(t,z);
grid;
xlabel('time');
ylabel('Ampl');
title('Recovered msg signal');
CODE SNIPPET:
OUTPUT SNIPPET:
EXPERIMENT - 04
CODE SNIPPET:
OUTPUT SNIPPET:
EXPERIMENT - 05
AIM: To study the generation and detection of PWM wave.
SOFTWARE USED: MATLAB CAMPUS SUITE
SOURCE CODE:
fc=1000;
fs=10000;
f1=200;
t=0:1/fs:((2/f1)-(1/fs));
x1=0.4*cos(2*pi*f1*t)+0.5;
%modulation
y1=modulate(x1,fc,fs,'pwm');
subplot(421);
plot(x1);
title('original signal tokne mesage,f1=500,fs=10000');
subplot(422);
plot(y1);
axis([0 500 -0.2 1.2]);
title('PWM')
%demodulation
x1_recov=demod(y1,fc,fs,'pwm');
subplot(423);
plot(x1_recov);
title('time domain recovered single tone,f1=200');
CODE SNIPPET:
OUTPUT SNIPPET:
EXPERIMENT - 06
AIM: To study the generation and detection of PPM wave.
SOFTWARE USED: MATLAB CAMPUS SUITE
SOURCE CODE:
clc;
clear all;
close all;
fc=100; fs=1000;
f1=80;
t=0:1/fs:((2/f1)-(1/fs));
x1=0.4*cos(2*pi*f1*t)+0.5;
subplot(4,2,1)
plot(x1)
title('original msg signal')
y1=modulate(x1,fc,fs,'ppm');
subplot(4,2,2)
plot(y1)
axis([0 50 -0.2 1.2])
title('ppm one of f1,fc=1000,f1=80')
fx1=abs(fft(y1,1024));
fx1=fftshift(fx1);
f=(-fs/2):(fs/1024):(fs/2-(fs/1024));
subplot(4,2,3)
plot(f,fx1)
title('freq des ppm signal tone,fc=1000')
x1_recov = demod(y1,fc,fs,'ppm');
subplot(4,2,4)
plot(x1_recov)
title('time domain recovered signal');
CODE SNIPPET:
OUTPUT SNIPPET:
EXPERIMENT - 07
SOURCE CODE:
Clc;
Clear all;
Close all;
syms t f
fc=10;
x = heaviside(t+2)- heaviside(t-2);
X=fourier(x,f) ;
XX = @(f) 2*(sin(2*f)./(f));
f=[-100:0.01:100-0.01];
Xshift=( XX(f-fc)+XX(f+fc));
OUTPUT SNIPPET:
EXPERIMENT - 08
AIM: Write a MATLAB code for frequency synthesizer
SOFTWARE USED: MATLAB CAMPUS SUITE
SOURCE CODE:
close all;
clear all;
clc;
fs = 10000;
t = 0:1/fs:1.5;
f=50;
x1 = square(2*pi*f*t);
subplot(3,1,1);
plot(t,x1);
axis([0 0.2 -1.2 1.2]);
xlabel('Time (sec)');
ylabel('Amplitude');
title('Square wave input with freq=50HZ');
t = 0:1/fs:1.5;
x2 = square(2*pi*2*f*t);
subplot(3,1,2);
plot(t,x2);
axis([0 0.2 -1.2 1.2]);
xlabel('Time (sec)');
ylabel('Amplitude');
title('frequency multiplication by a factor of 2');
x3 = square(2*pi*f/2*t);
subplot(3,1,3);
plot(t,x3);
axis([0 0.2 -1.2 1.2]);
xlabel('Time (sec)');
ylabel('Amplitude');
title('frequency division by a factor of 2');
CODE SNIPPET:
OUTPUT SNIPPET:
EXPERIMENT - 09
PARAMETER SETTINGS:
OUTPUT:
EXPERIMENT - 10
AIM: To generate amplitude modulated and demodulated signal using
Simulink.
SOFTWARE USED: MATLAB CAMPUS SUITE.
SIMULINK DESIGN:
PARAMETER SETTINGS:
OUTPUT:
EXPERIMENT - 11
AIM: To perform the AM DSB-SC signal generation and detection using
Simulink.
SOFTWARE USED: MATLAB CAMPUS SUITE
SIMULINK DESIGN:
PARAMETER SETTINGS:
OUTPUT:
EXPERIMENT - 12
AIM: To perform the AM SSB-SC signal generation and detection using
Simulink.
SOFTWARE USED: MATLAB CAMPUS SUITE
SIMULINK DESIGN:
PARAMETER SETTINGS:
OUTPUT: