ac lab matlab based report
TRANSCRIPT
`
071
Program 1: % Amplitude Modulation t=0:0.0001:0.02 msg=10*cos(2*pi*100*t) carr=20*cos(2*pi*1000*t) amw=(20+msg).*cos(2*pi*1000*t) subplot(2,1,1) plot(t,msg) title('Message signal') subplot(2,1,2) plot(t,carr) title('Carrier signal') figure; subplot(3,1,1) plot(t,amw) title('Under Modulation') msg=30*cos(2*pi*100*t) amw=(20+msg).*cos(2*pi*1000*t) subplot(3,1,2) plot(t,amw) title('over modulation') msg=20*cos(2*pi*100*t) amw=(20+msg).*cos(2*pi*1000*t) subplot(3,1,3) plot(t,amw) title('100 % modulation')
`
072
OUTPUT WAVEFORMS
`
073
`
074
Program 2: %Demodulation of AM wave using Hilbert transform t=0:0.0001:0.02 fc=1000 Ec=7 Carr=Ec*sin(2*pi*fc*t) fm=100 Em=7 Mod=Em*sin(2*pi*fm*t) Am=(Ec+Mod).*(sin(2*pi*fc*t)) disp('Performing Amplitude Demodulation using Hilbert transform'); Am_hil=hilbert(Am) Am_abs=abs(Am_hil) Am_Demod=Am_abs-mean(Am_abs) disp('plotting the results'); figure;subplot(4,1,1);plot(t,Mod); title('Message Waveform'); %xlabel('Time(sec)');ylabel('Amplitude'); subplot(4,1,2);plot(t,Carr);title('carrier waveform'); %xlabel('Time(Sec)');ylabel('Amplitude'); subplot(4,1,3);plot(t,Am);title('amplitude modulated wave form'); %xlabel('Time(sec)');ylabel('Amplitude'); subplot(4,1,4); plot(t,Am_Demod); title('Amplitude demodulated waveform'); %xlabel('Time(sec)');ylabel('Amplitude');
`
075
Output Waveforms
`
076
Program 3:
%Demodulation using Diode detector t=0:0.0001:0.02 msg=16*cos(2*pi*200*t) carr=10*cos(2*pi*1000*t) subplot(4,1,1) plot(t,msg) title('Message waveform') subplot(4,1,2) plot(t,carr) title('Carrier waveform') amw=(10+msg).*cos(2*pi*1000*t) subplot(4,1,3) plot(t,amw) title('AM wave') for tim=1:200;
if(amw(tim)<0) amw(tim)=0; end end
[den,num]=butter(1,2*pi*0.025) for i=1:20
amw=filter(den,num,amw); end subplot(4,1,4) plot(t,amw) title('Demodulated waveform')
`
077
Output Waveforms
`
078
Program 4: %DSBSC Modulation t=0:0.0001:0.02; fc=1000 Ec=3 Carr=Ec*sin(2*pi*fc*t) fm=100 Em=7 Mod=Em*sin(2*pi*fm*t) DSBSC=Mod.*Carr subplot(3,1,1) plot(t,Mod) title('Message waveform') subplot(3,1,2) plot(t,Carr) title('Carrier waveform') subplot(3,1,3) plot(t,DSBSC) title('DSBSC modulated waveform')
`
079
Output Waveforms
`
0710
Program 5: % DSBSC Demodulation t=0:0.0001:0.02; fc=1000 Ec=3 Carr=Ec*sin(2*pi*fc*t) fm=100 Em=7 Mod=Em*sin(2*pi*fm*t) DSBSC=Mod.*Carr x=DSBSC.*sin(2*pi*fc*t) R=1000; C=1.59*power(10,-6); h=(1/(R*C))*exp(-t/(R*C)) y=conv(x,h) subplot(3,1,1) plot(t,Mod) title('Modulating Signal') subplot(3,1,2) plot(t,DSBSC) title('Double Side Band Suppressed Carrier') subplot(3,1,3) plot(y) axis([0 200 -1.5*power(10,5) 1.5*power(10,5)]) title('DSBSC after Demodulation')
`
0711
Output Waveforms
`
0712
Program 6: %Generation DSBSC using Balanced Modulator t=0:0.0001:0.02 fc=1000 Ec=3 fm=100 m=3 s1=Ec*(1+(m*cos(2*pi*fm*t))).*cos(2*pi*fc*t) s2=Ec*(1-(m*cos(2*pi*fm*t))).*cos(2*pi*fc*t) s=s1-s2 subplot(3,1,1) plot(t,s1) title('Amplitude Modulated Signal 1') subplot(3,1,2) plot(t,s2) title('Amplitude Modulated Signal 2') subplot(3,1,3) plot(t,s) title('DSBSC')
`
0713
Output Waveforms
`
0714
Program 7: %SSBSC Modulation t=0:0.0001:0.04 msg=5*cos(2*pi*200*t) carr=10*cos(2*pi*1000*t) ht=imag(Hilbert(msg)) subplot(3,1,1) plot(t,msg) title('Message waveform') subplot(3,1,2) plot(t,carr) title('Carrier Waveform') ssb1=(msg.*(carr/10))+(ht.*sin(2*pi*1000*t)) subplot(3,1,3) plot(t,ssb1) title('SSBSC')
`
0715
Output Waveforms
`
0716
Program 8: %Demodulation of SSBSC t=0:0.0001:0.04 msg=5*cos(2*pi*200*t) carr=10*cos(2*pi*1000*t) ht=imag(Hilbert(msg)) subplot(4,1,1) plot(t,msg) title('Message waveform') subplot(4,1,2) plot(t,carr) title('Carrier Waveform') ssb1=(msg.*(carr/10))+(ht.*sin(2*pi*1000*t)) subplot(4,1,3) plot(t,ssb1) title('SSBSC Modulated wave') impres=(400*pi)*exp(-t*400*pi) demd=conv((ssb1.*(carr/10)),impres) k=0:0.0001:0.08 subplot(4,1,4) plot(k,demd) title('Demodulated waveform')
`
0717
Output Waveforms
`
0718
Program 9: %Frequency Spectrum of Amplitude Modulated Wave t=0:0.0001:0.02 fc=1000 Ec=7 Carr=Ec*sin(2*pi*fc*t) fm=100 Em=3 Mod=Em*sin(2*pi*fm*t) Am=(Ec+Mod).*(sin(2*pi*fc*t)) FA=fft(Am,1024) subplot(1,1,1) plot(fftshift(abs(FA))) axis([375 700 0 1000]) title('frequency Spectrum of AmplitudeModulated Wave')
`
0719
Output Waveform
`
0720
Program 10: %Frequency Spectrum of Amplitude Modulated Wave t=0:0.0001:0.02 fc=1000 Ec=7 Carr=Ec*sin(2*pi*fc*t) fm=100 Em=3 Mod=Em*sin(2*pi*fm*t) DSBSC=Carr.*Mod FA=fft(DSBSC,1024) subplot(1,1,1) plot(fftshift(abs(FA))) axis([375 700 0 1000]) title('frequency Spectrum of DSBSC Wave')
`
0721
Output Waveform
`
0722
Program 11: %Frequency Spectrum of SSBSC t=0:0.0001:0.04 msg=5*cos(2*pi*200*t) carr=10*cos(2*pi*1000*t) ht=imag(Hilbert(msg)) ssb1=(msg.*(carr/10))+(ht.*sin(2*pi*1000*t)) FT=fft(ssb1) plot(abs(FT)) title(‘Frequency Spectrum of SSBSC wave’)
`
0723
Output Waveforms
`
0724
Program 12: %Performing Pre-emphasis and De-emphasis f1=10; for f=1:50 x(f)=(1/sqrt(1+(f1/f)^2)); f2(f)=f; end subplot(2,1,1); plot(f2,x); title('Pre-emphasis waveform') for f=1:50 y(f)=(1/sqrt(1+(f/f1)^2)); f3(f)=f; end subplot(2,1,2); plot(f3,y); title('De-emphasis waveform')
`
0725
Output Waveforms
`
0726
Program 13: %Frequency Modulation Am=1; Ac=2 fc=500; fm=200; fs=400 kf=30 dt=1/fs T=20e-3 t=0:T/fs:T mod=Am*cos(2*pi*fm*t) FM=Ac*cos(2*pi*fc*t+(2*pi*kf*(cumsum(mod)*dt))) subplot(2,1,1) plot(t,mod) axis([0 0.02 -5 5]) title('Message Signal') subplot(2,1,2) plot(t,FM) axis([0 0.02 -5 5]) title('FM Signal')
`
0727
Output Waveforms
`
0728
Program 14:
%Demodulation of FM wave Am=1;Ac=2;fc=500;fm=200;fs=400;kf=30 dt=1/fs T=20e-3 t=0:T/fs:T mod=Am*cos(2*pi*fm*t) FM=Ac*cos(2*pi*fc*t+(2*pi*kf*(cumsum(mod)*dt))) AM=diff(FM) lengthC=400; FM_Diode_out=AM for time_indx=1:lengthC; if(FM_Diode_out(time_indx)<0) FM_Diode_out(time_indx)=0; end end fs1=8000; [den,num]=butter(1,2*pi*fm/fs1); FM_Demod=filter(den,num,FM_Diode_out); for n=1:100 FM_Demod=filter(den,num,FM_Demod) end subplot(3,1,1) plot(t,mod);axis([0 0.01 -5 5]) title('Message Signal') subplot(3,1,2) plot(t,FM);axis([0 0.01 -5 5]) title('FM Signal') subplot(3,1,3) plot(FM_Demod);axis([200 400 0 0.4]) title('FM demodulated signal')
`
0729
Output Waveforms
`
0730
Program 15: %Frequency Spectrum of FM Am=1 Ac=2 fc=500 fm=200 fs=400 kf=30 dt=1/fs T=20e-3 t=0:T/fs:T mod=Am*cos(2*pi*fm*t) FM=Ac*cos(2*pi*fc*t+(2*pi*kf*(cumsum(mod)*dt))) FFM=fft(FM) plot(abs(FFM)) title('Frequency Spectrum')
`
0731
Output Waveforms
`
0732
Program 16: %Construction of SQUELCH circuit t=0:0.0001:0.02 fc=1000;Ec=7 Carr=Ec*sin(2*pi*fc*t) fm=100;Em=5 Mod=Em*sin(2*pi*fm*t) Am=(Ec+Mod).*(sin(2*pi*fc*t)) for t1=1:200 Am1(t1)=Am(t1) end for t1=201:400 Am1(t1)=0 end for t1=401:600 Am1(t1)=Am(t1-400) end disp(' Amplitude Demodulation using diode detector') lengthC=600; AM_Diode_out=Am1 for time_indx=1:lengthC; if(AM_Diode_out(time_indx)<0) AM_Diode_out(time_indx)=0; end end fs=8000; [den,num]=butter(1,2*pi*fm/fs); AM_Demod=filter(den,num,AM_Diode_out); for n=1:10 AM_Demod=filter(den,num,AM_Demod) end subplot(2,1,1);plot(Am1) title('Transmitted Signal') subplot(2,1,2);plot(AM_Demod) title('Squelch Circuit i.e after Quieting')
`
0733
Output Waveforms