Sunteți pe pagina 1din 19

AC & DC

Date:

ANALOG AND DIGITAL COMMUNICATION


SOFTWARE LAB MANUAL
(ECE-III/ II-Semester)

PREPARED BY VENKATLAKSHMI Asst.Professor (ECE.Dept)

Department of Electronics and Communication Engineering

VIGNANA BHARATHI INSTITUTE OF TECHNOLOGY


Aushapur (V), Ghatkesar (M), Rangareddy (Dt).-501301.

VBIT Page 1

AC & DC

Date:

List of experiments

1. 2. 3. 4. 5.

Amplitude Modulation and Demodulation Frequency Modulation and Demodulation Double side band suppressed carrier Modulation and Demodulation Pulse Width Modulation and Demodulation Pulse Position Modulation and Demodulation

VBIT Page 2

AC & DC

Date:

1. AMPLITUDE MODULATION AND DEMODULATION


Aim: Write a program to perform Amplitude Modulation and Demodulation by using MAT lab
and check the simulation responses.

Software used: MATLAB 7.0.4 In built functions:


1. INV Matrix inverse. INV(X) is the inverse of the square matrix X. A warning message is printed if X is badly scaled or nearly singular. 2. SIN Sine of argument in radians. SIN(X) is the sine of the elements of X. 3. PLOT Linear plot. PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, length(Y) disconnected points are plotted. 4. TITLE Graph title. TITLE('text') adds text at the top of the current axis. 5. XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the current axis. XLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the xlabel. 6. YLABEL Y-axis label. YLABEL('text') adds text beside the Y-axis on the current axis. YLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the ylabel. 7. LEGEND Display legend. LEGEND(string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The fontsize and fontname for the legend strings matches the axes fontsize and fontname. 8. GRID Grid lines. GRID ON adds major grid lines to the current axes. GRID OFF removes major and minor grid lines from the current axes. 9. FIGURE Create figure window. FIGURE, by itself, creates a new figure window, and returns its handle. VBIT Page 3

AC & DC

Date:

Procedure:
1. Open the matlab command & editor windows 2. Write the program 3. Save the program 4. Go to debug and run it 5. You can observe the output on the command window.

Program:
t0=0.15; f=1/0.15; ts=0.001; fc=250; fs=1/ts; t=[0:ts:t0]; a=0.85; df=0.5; %gen of msg signal m1=sin(2*pi*2*f*t); figure(1) subplot(3,1,1); plot(t,m1); n=length(m); grid on xlabel('time'); ylabel('magnitude'); title('message signal'); ylim([-1.1 1.1]); %gen of carrier signal c=cos(2*pi*fc.*t); subplot(3,1,2); plot(t,c); title('carrier signal'); xlabel('time'); %gen of modulated signal and spectrum [M,m,df1]=fftseq(m,ts,df); M=M/fs; f=[0:df1:df1*length(m)-1]-fs/2; u=(1+a*m); u=u(1:151).*c; subplot(3,1,3); plot(t,u); VBIT Page 4

AC & DC xlabel('time'); title('modulated signal'); ylim([-1.2 1.2]); %gen of frequency spectrum of message signal [U,u,df1]=fftseq(u,ts,df); U=U/fs; %frequency spectrum of message signal figure(2) subplot(1,2,1); plot(f,abs(fftshift(M))); xlabel('frequency'); title('spectrum of message signal'); subplot(1,2,2); plot(f,abs(fftshift(U))); xlabel('frequency'); title('spectrum of modulated signal');

Date:

Simulation Responses:

Result: Hence Amplitude Modulation and Demodulation performed and the simulation responses has been observed and verified.

VBIT Page 5

AC & DC

Date:

2. FREQUENCY MODULATION AND DEMODULATION


Aim: Write a program to perform Amplitude Modulation and Demodulation by using MAT lab
and check the simulation responses.

Software used: MATLAB 7.0.4 In built functions:


1. INV Matrix inverse. INV(X) is the inverse of the square matrix X. A warning message is printed if X is badly scaled or nearly singular. 2. SIN Sine of argument in radians. SIN(X) is the sine of the elements of X. 3. PLOT Linear plot. PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, length(Y) disconnected points are plotted. 4. TITLE Graph title. TITLE('text') adds text at the top of the current axis. 5. XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the current axis. XLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the xlabel. 6. YLABEL Y-axis label. YLABEL('text') adds text beside the Y-axis on the current axis. YLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the ylabel. 7. LEGEND Display legend. LEGEND(string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The fontsize and fontname for the legend strings matches the axes fontsize and fontname. 8. GRID Grid lines. GRID ON adds major grid lines to the current axes. GRID OFF removes major and minor grid lines from the current axes. 9. FIGURE Create figure window. FIGURE, by itself, creates a new figure window, and returns its handle. VBIT Page 6

AC & DC

Date:

Procedure:
1. Open the matlab command & editor windows 2. Write the program 3. Save the program 4. Go to debug and run it 5. You can observe the output on the command window.

Program:
% t0=0.15; ts=0.001; f=10; fc=200; kf=50; fs=1/ts; t=[0:ts:t0]; df=0.25; % %Message signal m=sin(2*3.14*2*f*t); %plot of the msg signal subplot (2,2,1); plot(t,m); grid on; ylim([-1.1 1.1]); xlabel('time'); ylabel('x(t)'); title('message signal'); %integral of m int_m(1)=0; for i= 1:length(t)-1; int_m(i+1)=int_m(i)+m(i)*ts; end %finding the fourier transform of m signal [M,m,df1]=fftseq(m,ts,df); M=M/fs; f=[0:df1:df1*(length(m)-1)]-fs/2; %generation of modulated signal u=cos(2*3.14*fc*t+2*3.14*kf*int_m); subplot(2,2,2); VBIT Page 7

AC & DC plot(t,u(1:length(t))); xlabel('time'); title('modulated signal'); % %finding the fourier transform of the modulated signal u % [U,u,df1]=fftseq(u,ts,df); U=U/fs; %plots magnitude of message and modulated signal in frequency domain length(f); length(M); length(U); subplot(2,2,3); plot(f,abs(fftshift(M))); xlabel('frequency'); title('spectrum of message signal'); grid on; subplot(2,2,4); plot(f,abs(fftshift(U))); xlabel('Frequency'); title('spectrum of modulated signal'); grid on;

Date:

Simulation Responses:

Result: Hence Frequency Modulation and Demodulation responses has been observed and verified. VBIT

performed and the simulation

Page 8

AC & DC

Date:

3. DOUBLE SIDE BAND SUPPRESSED CARRIER MODULATION AND DEMODULATION

Aim: Write a program to perform Double side band suppressed carrier Modulation and
Demodulation by using MAT lab and check the simulation responses.

Software used: MATLAB 7.0.4 In built functions:


1. SIN Sine of argument in radians. SIN(X) is the sine of the elements of X. 2. PLOT Linear plot. PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, length(Y) disconnected points are plotted. 3. TITLE Graph title. TITLE('text') adds text at the top of the current axis. 4. XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the current axis. XLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the xlabel. 5. YLABEL Y-axis label. YLABEL('text') adds text beside the Y-axis on the current axis. YLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the ylabel. 6. LEGEND Display legend. LEGEND(string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The fontsize and fontname for the legend strings matches the axes fontsize and fontname. 7. GRID Grid lines. GRID ON adds major grid lines to the current axes. GRID OFF removes major and minor grid lines from the current axes. 8. FIGURE Create figure window. FIGURE, by itself, creates a new figure window, and returns its handle. VBIT Page 9

AC & DC

Date:

Procedure:
1. Open the matlab command & editor windows 2. Write the program 3. Save the program 4. Goto debug and run it 5. You can observe the waveforms on the command window.

Program:
clc clear all close all %input fm=1000; wm=2*3.14*fm; t=0:0.000000001:1.5/fm; m=sin(wm*t); subplot(2,2,1); plot(t,m); title('input signal'); xlabel('time'); ylabel('amplitude'); %carrier fc=10000; wc=2*3.14*fc; c=sin(wc*t); subplot(2,2,2); plot(t,c); title('carriersignal'); xlabel('time'); ylabel('amplitude'); %dsbsc au=c.*m; subplot(2,2,3); plot(t,au); title('dsbsc signal'); xlabel('time'); ylabel('amplitude'); %demod d=c.*au; subplot(2,2,4); plot(t,d); VBIT Page 10

AC & DC title('demodulated signal'); xlabel('time'); ylabel('amplitude');

Date:

Simulation Responses:

Result: Hence Double side band suppressed carrier Modulation and Demodulation performed
and the simulation responses has been observed and verified.

VBIT Page 11

AC & DC

Date:

4. PULSE WIDTH MODULATION AND DEMODULATION


Aim: Write a program to perform Pulse Width Modulation and Demodulation by using MAT
lab and check the simulation responses.

Software used: MATLAB 7.0.4 In built functions:


1. INV Matrix inverse. INV(X) is the inverse of the square matrix X. A warning message is printed if X is badly scaled or nearly singular. 2. SIN Sine of argument in radians. SIN(X) is the sine of the elements of X. 3. PLOT Linear plot. PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, length(Y) disconnected points are plotted. 4. TITLE Graph title. TITLE('text') adds text at the top of the current axis. 5. XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the current axis. XLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the xlabel. 6. YLABEL Y-axis label. YLABEL('text') adds text beside the Y-axis on the current axis. YLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the ylabel. 7. LEGEND Display legend. LEGEND(string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The fontsize and fontname for the legend strings matches the axes fontsize and fontname. 8. GRID Grid lines. GRID ON adds major grid lines to the current axes. GRID OFF removes major and minor grid lines from the current axes. 9. FIGURE Create figure window. FIGURE, by itself, creates a new figure window, and returns its handle. VBIT Page 12

AC & DC

Date:

Procedure:
1. Open the matlab command & editor windows 2. Write the program 3. Save the program 4. Go to debug and run it 5. You can observe the output on the command window.

Program:
% clc Fc=100; Fs=4000; ts=1/Fs; t=[0:ts:1/Fc]; size(t); % %generation of message wave % figure(1) subplot(2,1,1) x=0.5+0.4*sin(2*3.14*Fc*t);%message or modulating signal plot(t,x); grid on ylabel('amplitude'); xlabel('time(in secs)'); title('modulating/message signal'); % %generation of pulse carrier % tt=(-4/1000:(ts/10):6/1000); m=zeros(size(tt)); m(1:40)=ones(size(m(1:40))); m(81:120)=ones(size(m(81:120))); m(161:200)=ones(size(m(161:200))); m(241:280)=ones(size(m(241:280))); VBIT Page 13

AC & DC m(321:360)=ones(size(m(321:360))); subplot(2,1,2); plot(tt,m); ylim([0 1.2]); ylabel('amplitude'); xlabel('time(in mill secs)'); title('pulse carrier signal'); % %generation of PWM % y=modulate(x,Fc,Fs,'pwm','centered'); k=1:1:length(y);

Date:

k=k/(length(y)*100); figure(2); subplot(2,2,2); plot(k,y); title('modulated signal'); ylim ([0 1.2]); subplot(2,2,1); plot(t,x); grid on; ylabel('amplitude'); xlabel('time(in secs)'); title('modulating/message signal'); %demod signal of modulated signal m1=demod(y,Fc,Fs,'pwm','centered'); subplot(2,2,3); plot(t,m1); title('PWM demodulated signal'); grid on; % Sx=fftshift(abs(fft(y)))% power spectrum of PWM f=-length(Sx)/2:1:(length(Sx-1)/2)-1; subplot(2,2,4); plot(f,Sx); grid; title('magnitude spectrum of x(n)'); xlabel('frequency,Hz'); ylabel('Magnitude,Db'); %

VBIT Page 14

AC & DC

Date:

Simulation Responses:

Result: Hence Pulse Width Modulation and Demodulation performed and the simulation
responses has been observed and verified.

VBIT Page 15

AC & DC

Date:

5. PULSE POSITION MODULATION & DEMODULATION


Aim: Write a program to perform Pulse Position Modulation and Demodulation by using MAT
lab and check the simulation responses.

Software used: MATLAB 7.0.4 In built functions:


1. INV Matrix inverse. INV(X) is the inverse of the square matrix X. A warning message is printed if X is badly scaled or nearly singular. 2. SIN Sine of argument in radians. SIN(X) is the sine of the elements of X. 3. PLOT Linear plot. PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, length(Y) disconnected points are plotted. 4. TITLE Graph title. TITLE('text') adds text at the top of the current axis. 5. XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the current axis. XLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the xlabel. 6. YLABEL Y-axis label. YLABEL('text') adds text beside the Y-axis on the current axis. YLABEL('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the ylabel. 7. LEGEND Display legend. LEGEND(string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The fontsize and fontname for the legend strings matches the axes fontsize and fontname. 8. GRID Grid lines. GRID ON adds major grid lines to the current axes. GRID OFF removes major and minor grid lines from the current axes. 9. FIGURE Create figure window. FIGURE, by itself, creates a new figure window, and returns its handle. VBIT Page 16

AC & DC

Date:

Procedure:
Open the matlab command & editor windows Write the program Save the program Go to debug and run it You can observe the output on the command window.

Program:
% clc Fc=100; Fs=4000; ts=1/Fs; t=[0:ts:1/Fc]; size(t); % %generation of message wave % figure(1) subplot(2,1,1) x=0.5+0.4*sin(2*3.14*Fc*t);%message or modulating signal plot(t,x); grid on ylabel('amplitude'); xlabel('time(in secs)'); title('modulating/message signal'); % %generation of pulse carrier % tt=(-4/1000:(ts/10):6/1000); m=zeros(size(tt)); m(1:40)=ones(size(m(1:40))); m(81:120)=ones(size(m(81:120))); m(161:200)=ones(size(m(161:200))); m(241:280)=ones(size(m(241:280))); m(321:360)=ones(size(m(321:360))); subplot(2,1,2); VBIT Page 17

AC & DC plot(tt,m); ylim([0 1.2]); ylabel('amplitude'); xlabel('time(in mill secs)'); title('pulse carrier signal'); % %generation of PPM % k=1:1:length(Sx); k=k/(length(Sx)*100); y1=modulate(x,Fc,Fs,'ppm'); figure(3); subplot(2,2,2); plot(k,y1); title(' pulse position modulated signal'); ylim ([0 1.2]); subplot(2,2,1); plot(t,x); grid on; ylabel('amplitude'); xlabel('time(in secs)'); title('modulating/message signal'); % %demod signal of pulse position modulated signal m2=demod(y1,Fc,Fs,'ppm'); subplot(2,2,3); plot(t,m2); title('PPM demodulated signal'); grid on; %Spectrum of ppm Sx1=fftshift(abs(fft(y1)))% power spectrum of PPM f=-length(Sx1)/2:1:(length(Sx1-1)/2)-1; subplot(2,2,4); plot(f,Sx1); grid on; title('magnitude spectrum of x(n)'); xlabel('frequency,Hz'); ylabel('Magnitude,Db'); %

Date:

VBIT Page 18

AC & DC

Date:

Simulation Responses:

Result: Hence Pulse Position Modulation and Demodulation performed and the simulation
responses has been observed and verified. VBIT Page 19

S-ar putea să vă placă și