0% found this document useful (0 votes)
41 views61 pages

Cmslab Manual - 1

Here are the steps to perform the tasks in the lab: 1) Consider the signal X(t)=sin(2πft) where f=1Hz and t=0→2 The time domain representation of this signal is: X(t) = sin(2πt) For t=0→2 2) Amplitude scale the above signal by a factor of 2. The new signal is: Y(t) = 2sin(2πt) For t=0→2 3) Time shift the original signal X(t) by 1 second. The new signal is: Z(t) = sin(2π(t-1)) For t

Uploaded by

tayybahaseeb18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views61 pages

Cmslab Manual - 1

Here are the steps to perform the tasks in the lab: 1) Consider the signal X(t)=sin(2πft) where f=1Hz and t=0→2 The time domain representation of this signal is: X(t) = sin(2πt) For t=0→2 2) Amplitude scale the above signal by a factor of 2. The new signal is: Y(t) = 2sin(2πt) For t=0→2 3) Time shift the original signal X(t) by 1 second. The new signal is: Z(t) = sin(2π(t-1)) For t

Uploaded by

tayybahaseeb18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 61

COMMUNICATION SYSTEM

LAB MANUAL

DEPARTMENT OF TELECOM ENGINEERING UNIVERSITY OF


ENGINEERING AND TECHNOLOGY TAXILA

COMMUNICATION SYSTEM LAB MANUAL Page 1


List of Experiments
1. Introduction to MATLAB
2. Signal transformation techniques
3. Square wave synthesis (Gibb’s Phenomenna), Power and energy of signals, Gaussian noise,
4. Auto-correlation sequence (ACS) and effect of time-shifting on auto correlation, Power
spectral density
5. Fourier Series, exponential fourier series
6. Fourier Transform
7. Simulation of communication system using MATLAB (amplitude modulation)
8. Single side band
9. Balanced Modulator
10. Frequency mixer
11. Introduction of Communication Systems Trainer, Envelop Detector using Trainer Modules
12. Phase Modulation and Demodulation on Trainer
13. Frequency Modulation and Frequency Demodulation using PLL method
14. Pre-Emphasis and De-Emphasis Filters
15. Pulse Modulation and Demodulation

COMMUNICATION SYSTEM LAB MANUAL Page 2


LAB 01

INTRODUCTION TO MATLAB
Objectives:

(a) To get acquainted with MATLAB’s environment.

(b) To use MATLAB as a calculator.

(c) To learn to create MATLAB variables and basic plots.

(d) To learn to initialize and manipulate vectors, matrices.

Pre-lab theory:

What is MATLAB?

MATLAB is a software program that allows you to do data manipulation and visualization, calculations,
math and programming. It can be used to do very simple as well as very sophisticated tasks. It
can solve large systems of equations efficiently and it is therefore useful for solving differential
equations and optimization problems. It also provides excellent means for data visualization and has
symbolic capabilities. Whilst simple problems can be solved interactively with MATLAB, its real
power shows when given calculations that are cumbersome or extremely repetitive to do by hand!

Where can we use MATLAB?

MATLAB is recognized as the interactive program for numerical linear algebra and matrix
computation. In industries, MATLAB is used for research and to solve practical engineering and
mathematical problems. Also, in automatic control theory, statistics and digital signal processing (Time-
Series Analysis) one can use MATLAB. The following tool boxes make it useful in soft computing at
various industrial and scientific areas:

(i) Neural Networks (ii) Optimization (iii) Genetic Algorithms (iv) Wavelets (v) Fuzzy Logic
(vi) Control systems (vi) Signal processing (vii) Communication Systems

Starting MATLAB

After logging into your account, you can enter MATLAB by double-clicking on the MATLAB shortcut
icon on the Window. After starting MATLAB, the MATLAB Desktop will appear. The default
three-part window looks similar to the figure below. The Desktop is also known as an Integrated
Development Environment (IDE). Clicking the Start button in the lower left-hand corner will display
a list of MATLAB tools, shortcuts, and documentation.

COMMUNICATION SYSTEM LAB MANUAL Page 3


Figure 1 : GUI view of MATLAB

1. Given that x=-5+9i and y=6-2i, Z= [ 13 2


]
1+2 i
use MATLAB find the following
A. x+y
B. x-y
C. xy
D. x/y
E. transpose of Z
F. inverse of Z
Solution:
Simple mathematical operations can be performed by following code:
x=-5+9i;
y=6-2i;
a=x+y;
b=x-y;
c=x*y;
d=x/y;
e=Z’
f=inv(Z)

display(a)
display(b)
display(c)

COMMUNICATION SYSTEM LAB MANUAL Page 4


display(d)
display(e)
display(f)

Result it displays is:


a=
1.0000 + 7.0000i
b=
-11.0000 +11.0000i
c=
-12.0000 +64.0000i
d=
-1.2000 + 1.1000i
e=

[ 12 3
1+2 i ]
2. Use MATLAB to compute: 6(35^1.4)+14^0.35
Solution:
We can write it as:
clc
clear all
e=6*35^1.4+14^0.35;
display(e)
It displays the result:
e=
873.1743

3. Define a 4x3 matrix with zeros everywhere except the first line that is filled with 1. Hint= use
ones and zeros command
Solution:
First we define 4x3 matrix then make it null matrix by replacing the rows and columns with zero. Then
using the same command for the replacement of first row from zero to one. Code is given below:
clc
clear all
close all
syms m;
matrix=[2,4,3;24,3,4;6,5,4;7,4,3];
display(matrix);
matrix(:,:)=0;
display (matrix);
matrix([1],:)=1;
display(matrix);
It displays the following result:
First matrix is matrix which we introduce, second one is null matrix and third one is required matrix.
matrix =

2 4 3

COMMUNICATION SYSTEM LAB MANUAL Page 5


4 3 4
6 5 4
7 4 3
matrix =
0 0 0
0 0 0
0 0 0
0 0 0
matrix =

1 1 1
0 0 0
0 0 0
0 0 0

4. Use MATLAB to solve following set of equations.


6x - 4y + 8z = 112
-5x – 3y +7z = 75
14x + 9y – 5z = -67
Solution:
To solve the ODE (ordinary differential equation) we use simple method here. We just take inverse of
matrix and multiply with constant matrix to get the values of X,Y and Z.

clc
clear all
close all
syms xyz;
A=[6 -4 8; -5 -3 7; 14 9 -5];
%X=[x;y;z];
B=[112;75;-67];
C=1./A;
X=C*B;
display(X);
Result that we get from above code is as follows:
X=
-8.4583
-56.9714
29.7333
5. Use MATLAB to find roots of 13x3 + 182x2 – 184x +2503 = 0
Solution:
To find the rootes of equation we just make its matrix and then apply command of ‘roots()’ which gives
roots in matrix form. Code for above equation is:

clc
clear all
close all
syms x;
A=[13 182 -184 2503];
r=roots(A);
display(r);

COMMUNICATION SYSTEM LAB MANUAL Page 6


Roots we get from above code is:
r=
-15.6850
0.8425 + 3.4008i
0.8425 - 3.4008i

LAB 01-B
INTRODUCTION TO PLOTTING COMMAND ON MATLAB
Objectives:

(a) To use MATLAB for plotting.

(b) To learn to create MATLAB basic plots.

Pre-lab theory:

MATLAB is very useful for making scientific and engineering plots. You can create plots of known,
analytical functions, you can plot data from other sources such as experimental measurements, and you
can analyze data, perhaps by fitting it to a curve, and then plot a comparison. MATLAB also has powerful
built-in routines for drawing contour and three-dimensional surface plots.

A vector is plotted against a vector, lengths of vectors must match

plot ─ for CT signals

stem ─ for DT signals

Two-dimensional line and symbol plots are created with the plot command. In its simplest form plot takes
two arguments

>> plot(xdata, ydata)

where xdata and ydata are vectors containing the data. Note that xdata and ydata must be the same length
and both must be the same type, i.e., both must be either row or column vectors. Additional arguments to
the plot command provide other options including the ability to plot multiple data sets, and a choice of
colors, symbols.

1. Use MATLAB to plot the functions y=4√(6x+1) and z=5e0.3x – 2x over the interval 0<x<1.5
Solution:
Code for plot of above two functions is:
clc
clear all
x=0:0.1:1.5;
y=4*sqrt(6*x+1);
z=5*exp(0.3*x)-2*x;
plot(x,y,'r');

COMMUNICATION SYSTEM LAB MANUAL Page 7


hold on;
plot(x,z,'b');
xlabel('x');ylabel('y=4sqrt(6x+1) z=5exp(0.3x)-2x');
gtext('y=red, z=blue');
title('Q3');

Its gives the result:

2. Use MATLAB to plot function s= 2 sin (3t+2) + √(5t+1) over the interval 0<t<5.
Solution:
Code for above function is:
clc
clear all
close all
symst;
t=0:0.1:5;
s=2*sin(3*t+2)+sqrt(5*t+1);
plot(t,s);
xlabel('t');ylabel('s=2sin(3t+2)+?(5t+1)');
gtext('s=2sin(3t+2)+?(5t+1)');
title('Q4');
It gives the graph:

3. Plot exp(-x) sin(8x) for 0≤ x ≤2Π


Solution:

COMMUNICATION SYSTEM LAB MANUAL Page 8


Code for this function is:
clc
clear all
close all
syms x;
x=0:0.1*pi:2*pi;
w=sin(8*x);
plot(x,w,'k');
title('Q5 (b)');
holdon;
q=exp(-x);
plot(x,q,'r');
title('Q5');
xlabel('Pi');ylabel('exp(-x) & sin(8x)');
It gives the graph like this:

4. Plot the function y= (4/Π) [(sin x) + (sin 3x)/3 + (sin 5x)/5 + (sin7x)/7] over the interval –Π<x<Π.
These are the first four terms of the Fourier Series representation of a square wave.
Solution:
Code for this function is as follows:
clc
clear all
close all
syms x;
x=-pi:0.1*pi:pi;
y=(4/pi)*[sin(x)+(sin(3*x)/3)+(sin(5*x)/5)+(sin(7*x)/7)];
plot(x,y,'r');
title('Q6');
xlabel('Pi');ylabel('y=(4/pi)*[sin(x)+(sin(3*x)/3)+(sin(5*x)/5)+(sin(7*x)/7)]');

COMMUNICATION SYSTEM LAB MANUAL Page 9


COMMUNICATION SYSTEM LAB MANUALPage 10
LAB 02
SIGNAL TRANSFORMATION TECHNIQUES

Objectives:
(a) Learn time domain representation of various discrete signals
(b) Learn and implement amplitude and continuous time scaling techniques
(c) Learn and implement time shifting techniques.

Pre-lab theory (a):


Amplitude scaling: The function g(t) is multiplied by the constant A for all values of t. This
transformation can be indicated by the notation:
g(t) → Ag(t)
Figure shows two examples of amplitude-scaling of the function g(t)

Figure 2:Amplitude scaling of g(t)

Time Shifting:
Time shifting by t0corresponds to the transformation:g(t) → g(t-t0) where, t0 is the time shift. If t0>0, the
waveform g(t) is obtained by shifting towards the right, relative to the time axis. If to<0, g(t) is shifted to
the left.

COMMUNICATION SYSTEM LAB MANUALPage 11


Figure 3 : Time shifting example

Time Scaling:
Time scaling corresponds to the transformation: g(t) → g(t/a), If a>0, t→ t/aexpands the function
horizontally by a factor of a.The figure compares g(t) and g(t/2).

LAB TASKS:
1) Consider the following signal X(t)=sin(2πft)
where f=1Hz
t=0→2
Write the MATLAB code to implement the following functions
A. 2X(t)
B. X(t-2)
C. X(t/2)
D. X(-t)
2) Draw the sum of signals.
10
−5
( t )=∑ *cos(2*pi*n*f*t)
n=1 2∗pi
WhereT= 2 ms and we wish to show the signal for 10 ms.Thus, f = 1/T = 5000Hz
MATLAB Code:
%Draw the sum of signals.
clc
clearall
closeall
del_t = 0.02e-3;
t=0:del_t:10e-3; %creates a 1 x 501 row vector of time points
n=(1:10).'; % creates a 10x1 column vector of integers 1 to 10
COS=cos((n*t)*2*pi*500);
plot(t,COS(1,:))
plot(t,COS(2,:))
A=-5./(pi*n.^2);
x=sum(A(:,ones(1,501)).*COS);
plot(t,x)

COMMUNICATION SYSTEM LAB MANUALPage 12


3) Write down a matlab code for ”Capacity with increasing bandwidth”

Capacity with increasing signal power

Increasing power will lead to more capacity. However, as the increase in capacity is logarithmic function
of power, the returns are diminishing.
MATLAB Code:
%Capacity with increasing signal power
clc
clearall
closeall
B=1;
N0=1;
P=[0:10^4];
C=B.*log2(1+P./( N0*B));
plot(P,C);
xlabel('Power,P');
ylabel('capacity,C bit/sec');
title('Capacity vs Power')

 Increase the noise and bandwidth one by one and observe the results.

COMMUNICATION SYSTEM LAB MANUALPage 13


LAB 03
POWER AND ENERGY OF SIGNALS, GAUSSIAN NOISE, SQUARE
WAVE SYNTHESIS
Objective:
To find the power and energy of the signals, to generate the Gaussian noise. After this lab, students would
be able to find the power and energy of the signals, to generate the Gaussian noise.

Background:

Power and Energy content of a signal is often calculated in signal processing for communication
applications. Gaussian noise is statistical noise that has a probability density function (abbreviated pdf) of
the normal distribution (also known as Gaussian distribution). In other words, the values that the noise
can take on Gaussian-distributed. It is most commonly used as additive white noise to yield additive white
Gaussian noise (AWGN). Gaussian noise is properly defined as the noise with a Gaussian amplitude
distribution, says nothing of the correlation of the noise in time or of the spectral density of the noise.
Labeling Gaussian noise as 'white' describes the correlation of the noise.

Task 01:

Find the power of the following signal

X(t) =cos(200πt)+ cos(400πt) + cos(600πt) for t=0:0.001:10

Task 02:

Find the energy of the following signal

X[n]=1 for -3<n<3

Task 03:

Generate the Gaussian noise for 50 number of samples

Plot the noise

LAB 03-B
SQUARE WAVE SYNTHESIS, CONDITIONALS AND LOOPS

Objective:
This lab gives the idea of implementation of programming (if-else, loops) in MATLAB also it tells us
how to find integrals and derivatives.
LAB TASK 1:
Write a code that take an input from user and display its required waveform

COMMUNICATION SYSTEM LAB MANUALPage 14


Hint: please press 1 for sawtooth, 2 for unit step, 3 for impulse, 4 for rectpulse etc.

Matlab code is given below:

a=input('please enter \n 1 for sawtooth \n 2 for unit step \n 3 for impulse \n 4 for rectpulse \n or any other
number for all graphs: \n')
global t n h s q u w p;
t=-10:0.001:10;
n=-10:10;
h=-10:10;
s=-3:0.001:3;

p=sawtooth(t);
u=[zeros(1,10) ones(1,11)];
q=[zeros(1,10) 1 zeros(1,10)];
w=rectpuls(s*0.5);

if(a==1)
plot(t,p);
xlabel('t'); ylabel('Sawtooth');
else
if(a==2)
stem(n,u,'.','r');
xlabel('n'); ylabel('unit step');
else
if(a==3)
stem(h,q,'.','g')
xlabel('t'); ylabel('Impulse');
else
if(a==4)
plot(s,w)
xlabel('t'); ylabel('Rectpulse');
end
end
end

It display output like:


please enter
1 for sawtooth
2 for unit step
3 for impulse
4 for rectpulse
or any other number for all graphs:
Output we get by entering any random number i.e. 10

COMMUNICATION SYSTEM LAB MANUALPage 15


LAB TASK 2:
Display a Table of 11 using for loop
clc
clearall
closeall
for A=1:10
B=A*11;
f= '11 * %i = %i \n';
fprintf(f,A,B)
end

Output we get.

LAB TASK 3:
Using while loop write a code that will display a series even or odd numbers.
a=input('enter 1 for even numbers 2 for Odd numbers')
global e;
e=0;
while e<20; %loop
if a==1
R=rem(e,2); %to get remainder

COMMUNICATION SYSTEM LAB MANUALPage 16


if R==0; % if even then remainder is zero
f= '%i\t';
fprintf(f,e) %displays value of 'e' in a row
end
e=e+1; %increment in value of 'e'
end
if a==2; %to display output of second option
R=rem(e,2);
if R~=0; %for odd, remainder is not 0
f= '%i\t';
fprintf(f,e) %displays value of 'e' in a row
end
e=e+1;
end
end

INTEGRATION, DERIVATION, SQUARE WAVE SYNTHESIS

LAB TASK 1:
Q1: Take 1st , 2nd , 3rd , order derivative of function
f(x)= x2cos(x)+xsin(x)2

MATLAB code is given below:


%f(x)= x2cos(x)+xsin(x)2
clc
clearall
closeall
symsx;
f = x^2 * cos(x) + x * (sin(x))^2;
a=diff(f,x,1); %% 1st order derivative
b=diff(f,x,2); %will give 2nd order derivative
c=diff(f,x,3); %will give 3rd order derivative
fprintf'First Order Derivative: \n'
pretty(a)
fprintf'\n'
fprintf'Second Order Derivative: \n'
pretty(b)
fprintf'Third Order Derivative: \n'
fprintf'\n'
pretty(c)

Output is:

COMMUNICATION SYSTEM LAB MANUALPage 17


LAB TASK 2:
Q2: Find anti derivative for the function
f(x)=xsin(x)2

%f(x)=xsin(x)2
clc
clearall
closeall
symsx;
f = x*sin(x^2);
fprintf'Integral is \n\n'
a=int(f,x);
pretty(a)

OUTPUT:

LAB TASK 3:
Q3:Evaluate integral
1
2∫sin(x)2dx

clc
symsx;
f = sin(x)^2;
a=int(f,x,1,2);
pretty(a)

OUTPUT:

COMMUNICATION SYSTEM LAB MANUALPage 18


LAB TASK 4:
Q4:
(a) Write the code to add the 7th harmonic to obtain the waveform.
(b) Write the instructions to add the 9th harmonic to obtain the waveform.
(c) Write a program to add Fundamental to 99th harmonic and display the resulting waveform.

7th harmonic:
V=5; %the peak voltage
f0 = 1000; % Fundamental frequency in Hertz
w0 = 2*pi*f0; % Fundamental frequency in radians
T=1/f0; % the period of the square wave
D=0.5; % pulse duty ratio
% plotting a square wave
dT=T/512; % incremental time,
t1=0:dT:D*T-dT; % Positive half period
t2=D*T:dT:T-dT; % Negative half period
t=[t1 t2]; %One complete period
v=V*square(w0*t); % keyword to generate a square wave in MATLAB
V0=0;
V1= 4*V/pi;
V3= 4*V/(3*pi);
V5= 4*V/(5*pi);
V7= 4*V/(7*pi);
V9= 4*V/(9*pi);
v1 = V0+V1*sin(w0*t); % First (fundamental) harmonic
v13 = v1+V3*sin(3*w0*t); % First + Third harmonic
v135 =v13+V5*sin(5*w0*t); % First +Third +Fifth harmonic
v1357=v135+V7*sin(5*w0*t); %first+third+fifth+seventh
subplot (2,2,1)
plot(t,v,t,v1357)
title('7th harmonic')
OUTPUT:

COMMUNICATION SYSTEM LAB MANUALPage 19


9th harmonic:
V=5; %the peak voltage
f0 = 1000; % Fundamental frequency in Hertz
w0 = 2*pi*f0; % Fundamental frequency in radians
T=1/f0; % the period of the square wave
D=0.5; % pulse duty ratio
% plotting a square wave
v1 = V0+V1*sin(w0*t); % First (fundamental) harmonic
v13 = v1+V3*sin(3*w0*t); % First + Third harmonic
v135 =v13+V5*sin(5*w0*t); % First +Third +Fifth harmonic
v1357=v135+V7*sin(7*w0*t); %first+third+fifth+seventh
v13579=v1357+V9*sin(9*w0*t); %first+third+fifth+seventh+ninth
subplot (3,2,1)
plot (t,v,t,v1)
title('1st harmonic')
axis ([ 0 .001 -15 15])
subplot(3,2,2)
plot(t,v,t,v13)
title('3rd harmonic')
axis([0 .001 -15 15])
subplot(3,2,3)
plot(t,v,t,v135)
title('5th harmonic')
subplot(3,2,4)
plot(t,v,t,v1357)
title('7th harmonic')
subplot(3,2,5)
plot(t,v,t,v13579)
title('9th harmonic')

99th harmonic:
clc
V=5;
f0 = 1000;
w0 = 2*pi*f0;

COMMUNICATION SYSTEM LAB MANUALPage 20


T=1/f0;
D=0.5;
dT=T/512;
t1=0:dT:D*T-dT;
t2=D*T:dT:T-dT;
t=[t1 t2];
v=V*square(w0*t);
V0=0;
V1= 4*V/pi;
V3= 4*V/(3*pi);
V5= 4*V/(5*pi);
V7= 4*V/(7*pi);
V9= 4*V/(9*pi);
axis ([ 0 .001 -15 15])
subplot(3,2,2)
plot(t,v,t,v13)
title('3rd harmonic')
axis([0 .001 -15 15])
subplot(3,2,3)
plot(t,v,t,v135)
title('5th harmonic')
subplot(3,2,4)
plot(t,v,t,v1357)
title('7st harmonic')
subplot(3,2,5)
plot(t,v,t,v13579)
title('9th harmonic')
v99=0; %synthesized square wave % add only odd harmonics.
for n=1:2:99
v99 = v99+(4*V/(n*pi))*sin(n*w0*t);
end
subplot(3, 2, 6)
plot(t,v99)
title('99th harmonic')
axis([0 .001 -15 15])

COMMUNICATION SYSTEM LAB MANUALPage 21


LAB 04

AUTO-CORRELATION SEQUENCE (ACS) AND EFFECT OF TIME


SHIFTING ON AUTO-CORRELATION, POWER SPECTRAL DENSITY

Objective:

To calculate auto-correlation sequence (ACS) and learn effect of time-shifting.

Description:

Correlation is the process that qualifies the degree of inter-dependence of one process upon another or
measures the similarity between one set of data and other. Correlation is of two types: Cross-correlation
and Auto Correlation. It is implemented in MATLAB by the command “xcorr”, provided that two
sequences be convolved are of finite length.

Task 1 :

Provided a signal x1= [1 2 3 4]

1. Apply auto-correlation on x1 without using build in Matlab function and plot the output.
2. Apply time shifting (no=2 )to the signal x1 and save the output in vector x2. Plot the output.
Implementation of build in MATLAB command of correlation is not allowed.
3. Now, apply autocorrelation on signal x2 and plot the output graphs.
4. Observe and write down your conclusion.

Task 02:

Plot the autocorrelation for the following function

X(t)=cos(2π3t)

LAB 04-B
POWER SPECTRAL DENSITY

Objective:

To learn concept of Power spectral Density.

Description:

The power spectral density (PSD) of the signal describes the power present in the signal as a function of
frequency, per unit frequency. Power spectral density is commonly expressed in watts per hertz (W/Hz).
An important relationship between the Autocorrelation of a signal g(t) and Power Spectral Density Ψg(τ )

COMMUNICATION SYSTEM LAB MANUALPage 22


exist that is the Power Spectral Density(ESD) of a periodic signal is equal to the Fourier Transform of
Autocorrelation of the signal.

Task 1:

Find the power Spectral density of the following signal

X(t) =cos(200πt) + cos(400πt) + cos(600πt) for t=0:0.001:10

Task 02:

Plot the Power Spectral Density for the Gaussian noise generated for 50 number of samples.

COMMUNICATION SYSTEM LAB MANUALPage 23


LAB 05
FOURIER SERIES
Fourier Series:
In mathematics, the discrete Fourier transform (DFT) is a specific kind of discrete transform,used in
Fourier analysis. It transforms one function into another, which is called the frequency domain
representation of the original function (which is often a function in the time domain).
The DFT requires an input function that is discrete. Such inputs are often created by sampling a
continuous function, such as a person’s voice. The discrete input function must also have a limited (finite)
duration, such as one period of a periodic sequence or a windowed segment of a longer sequence.
Discrete Fourier Transform(DFT) decomposes a sequence of values into components of different
frequencies. This operation is useful in many fields but computing it directly from the definition is often
too slow to be practical. An FFT is a way to compute the same result more quickly, computing a DFT of
N points using the definition, takes O(N) arithmetical operations, while an FFT can compute the same
result in only O(N log N ) operations.
The difference in speed can be substantial, especially for long data sets where N maybe
in the thousands, the computation time can be reduced by several orders of magnitude in such cases. This
huge improvement made many DFT-based algorithms practical. FFTs are of great importance to a wide
variety of applications, from digital signal processing and solving partial differential equations to
algorithms for quick multiplication of large integers.
In particular, the DFT is widely employed in signal processing and related fields to analyze the
frequencies contained in a sampled signal, to solve partial differential equations, and to
perform other operations such as convolutions or multiplying large integers. A key enabling factor for
these applications is the fact that the DFT can be computed efficiently in practice using a fast Fourier
transform (FFT) algorithm.
TASK
Write down MATLAB code to plot the following function g(t) on MATLAB

Also find out fourier series and fourier transform for the above signal.
Also plot the output.

COMMUNICATION SYSTEM LAB MANUALPage 24


Description:
This is the code segment for ploting the signal g(t). Vector g contains samples of function
g(t), which is formed by concatenating three individual vectors g1, g2 and g3.

Plotting signal :
g1 = [0 :1 / 3 2 :1 − ( 1 / 3 2 ) ] ;
g2 = [ − 1 :1 / 3 2 :1 − ( 1 / 3 2 ) ] ;
g3 = [ − 1 :1 / 3 2 :0 − ( 1 / 3 2 ) ] ;
g = [ g1 , g2 , g3 ] ;
t = [ − 1 :1 / 6 4 :1 − ( 1 / 6 4 ) ] ;
p lo t ( t , g ) ;
a x i s ( [ − 1 .5 1 .5 −1.5 1 . 5 ] )
g r id

Figure 4:Sawtooth signal

Discrete Fourier Series using FFT:


Using the following code we get the Fourier series coefficients.
z=fft(g);
stem ( t , z ) ;
If we plot this calculated fft what we get is an arrangement of those total 128 coefficients one
by one i.e. they are not arranged as a normal Fourier series spectrum. FFTSHIFT command
helps us to reach there. We will get a plot using FFTSHIFT command such that DC component
is at the centre, and plot gets the shape of a normal Fourier series plot.
Shifted version :
z1 = f f t s h i f t ( z ) ;
n=[1:1:128];
a = n −65;
f = 0 .5 ∗ a ;
stem ( f , abs ( z1 ) )

COMMUNICATION SYSTEM LAB MANUALPage 25


Figure 5:Plotting MATLAB function FFTSHIFT

The above approach uses the Matlab commands FFT and FFTSHIFT. Now by directly using the formula
we can also obtain the plot with the help of following code segment.

m=128;

a=1;

f o r n = − m/ 2 : 1 :m/2−1

i f n == 0

Dn( a ) = 0 ;

else

Dn=( i ∗ (( −1) . ˆ n ) ) / ( n ∗ p i ) ;

end

Finally,for getting output,our code will be as follows.

a = a +1;
end
n = − m/ 2 :m/2 −1;
stem ( n , abs (Dn) )
Magnitude and phase of Dn can also be obtained as follows.
magDn = abs (Dn) ;
argDn = a n g le (Dn) ;
stem ( f ,magDn) ;
stem ( f , argDn ) ;

Comments:
1. FFT function plot the fourier series but with the DC component.

COMMUNICATION SYSTEM LAB MANUALPage 26


2. FFTSHIFT shifts the DC component to the center of spectrum.
3. Magnitude of the fourier series is plotted against frequency to remove the complex part
from the fourier series.

LAB 05-B

EXPONENTIAL FOURIER SERIES


Objective:
The objective of this experiment is to calculate and plot exponential Fourier series coefficients.
Background:
In mathematics, a Fourier series decomposes periodic functions or periodic signals into the sum
of a (possibly infinite) set of simple oscillating functions, namely sines and cosines (or complex
exponentials). The study of Fourier series is a branch of Fourier analysis.
Using Eulers Equation, and a little trickery, we can convert the standard Rectangular Fourier Series into
an exponential form. Even though complex numbers are a little more complicated
to comprehend, we use this form for a number of reasons:
1. Only need to perform one integration.
2. A single exponential can be manipulated more easily than a sum of sinusoids.
3. It provides a logical transition into a further discussion of the Fourier Transform.
Description:
1.Evaluate the fourier series coefficients using

Plot the magnitude | Dn| (in volts) and phase Dn (in degrees) of the first twenty-one

coefficients {n = −10, −9, …, 10} versus frequency (in rad/sec).

2. Plot two periods of g(t) , directly i.e., by creating a vector of samples of g(t) and plotting

that vector.

3. Plot an approximation to g(t) using these first twenty-one terms of the exponential Fourier

series.

f u n c t io n y = s in c 1 ( x ) % s i n c f u n c t io n implement a t io n

k = le n g t h ( x ) ;

fori=1:k

f x ( i ) == 0

y(i)=1;

else

y ( i ) = s i n ( x ( i ) ) /x ( i ) ;

end

COMMUNICATION SYSTEM LAB MANUALPage 27


end

end

Magnitude and Phase of Fourier Series Coefficients

Write the following code in Matlab and run it.

n = [ − 1 0 :1 0 ]; % s e t s up t he v e c t o r o f i n t e g e r i n d i c e s .

z=n∗(pi/4);

Dn = 0 .2 5 ∗ exp (− i ∗ z ) . ∗ s in c 1 ( z ) ; % s in c 1 ( ) i s d e f in e d above .

magDn = abs (Dn) ; % magnitude o f Fo u r ie r s e r i e s c o e f f i c i e n t s .

argDn = a n g le (Dn) ∗ ( 1 8 0 / p i ) ; % phase o f Fo u r ie r s e r i e s c o e f f i c i e n t s .

w = 0 .5 ∗ n ;

stem (w,magDn) , x l a b e l ( ’ Frequency in rad / s e c ( u n it s o f p i ) ’ )

g r id

t i t l e ( ’ Magnitude o f t he Ex p o n e n t ia l Fo u r ie r S e r i e s C o e f f i c i e n t s ’ )

stem (w, argDn ) , x l a b e l ( ’ Frequency in rad / s e c ( u n it s o f p i ) ’ )

ylabel(’degrees’)

g r id

t i t l e ( ’ Phase o f t he Ex p o n e n t ia l Fo u r ie r S e r i e s C o e f f i c i e n t s ’ )

Sum of Fourier Series Coefficients:

The signal g(t) can be reconstructed by adding the Fourier coefficients. To verify this we find

COMMUNICATION SYSTEM LAB MANUALPage 28


the sum given by

n = [ − 1 0 :1 0 ];

z=n∗(pi/4);

Dn = 0 .2 5 ∗ exp (− i ∗ z ) . ∗ s in c 1 ( z ) ; % symbol . ∗ means element −by−element

multiplication

nwo = n ∗ ( p i / 2 ) ; % d e f i n e e le v e n f r e q u e n c i e s f o r sum

t = [ 0 : 0 . 0 1 : 8 ] ; % d e f i n e time s a mpling p o in t s

BIG = nwo ’ ∗ t ; % c r e a t e b ig mat r ix t o do mat r ix m u l t i p l i c a t i o n f o r sum

g = Dn ∗ exp ( i ∗BIG) ; % here ’ s where t he sum i s done

p lo t ( t , r e a l ( g ) ) , g r id , x l a b e l ( ’ Seconds ’ )

t i t l e ( ’ Approximation t o g ( t ) u s in g t he f i r s t t en components o f t he Fo u r ie r

series’)

COMMUNICATION SYSTEM LAB MANUALPage 29


We can approximate g(t) using the first ten components of the Fourier series. The following

code is used to generate two periods of function g(t). It uses a custom made unit step function,

u(t), a copy of which is also provided below. The ability to use the unit step function to write

piecewise functions proves extremely effective.

Unit step signal:

g t = ( u ( t ) − u ( t −1) ) + ( u ( t −4) − u ( t −5) ) + u ( t −8) ;

p lo t ( t , g t )

g r id , x l a b e l ( ’ s e c o n d s ’ )

t i t l e ( ’ The r e a l g ( t ) ’ )

a x i s ( [ 0 8 −0.2 1 . 2 ] ) ;

f u n c t io n [ y ] = u ( x )

y =0.5+0.5 ∗ s ig n ( x ) ;

end

Also plot the output.

COMMUNICATION SYSTEM LAB MANUALPage 30


LAB 06

FOURIER TRANSFORM
Objective:
This lab related to the implementation of Fourier Transform in MATLAB. This lab is also related to
remove noise (high freq. signal) from message signal.
LAB TASK 1:
Why is the output of the second plot like this? Find a better range for t to plot sin(20*pi*t) right. Can you
find a good lower bound for the sampling interval in terms of the frequency?
clc
clear; close all
t = 0:0.1:10;
y1 = sin(2*pi*t);
y2 = sin(2*pi*10*t);
subplot(2,1,1)
plot(t,y1,'r');
holdon;
plot(t,y2);
subplot(2,1,2)
plot(t,y2)

We observe that second plot i.e. y2=sin(20*pi*t) have magnitude of exp(-14) which is minimum as
compared to y1=sin(2*pi*t). y2 is consider as noise. When we plot both y1 and y2, the graph of y2 is
approximately at zero.
If we take our time interval low then y2 can be plot and can be visualize in more better way.
MATLAB Code for this is given below:
clc
clear; close all
t = 0:0.01:3;
y1 = sin(2*pi*t);
y2 = sin(2*pi*10*t);
subplot(2,1,1)
plot(t,y1,'r');
holdon;
plot(t,y2);
subplot(2,1,2)
plot(t,y2)

COMMUNICATION SYSTEM LAB MANUALPage 31


Now we see that y2 has 10 times more frequency than y1. Now we can multiply both, can apply
operations and much more.
After multiplying we get following signal.

LAB TASK 2:
Give the MATLAB commands to plot the amplitude spectrum for the signal.

In addition, plot the waveform spectrum of this signal.


clc
clearall; close all;
dt = 1/100; % sampling rate
et = 4; % end of the interval
t = 0:dt:et; % sampling range
sum=0;
for k=10:20
y=(20-k)*sin(2*pi*k*t);
sum=sum+y;

COMMUNICATION SYSTEM LAB MANUALPage 32


end
Y = fft(x); % compute Fourier transform
n = size(y,2)/2; % 2nd half are complex conjugates
amp_spec = abs(Y)/n; % absolute value and normalize

% To visualize the amplitude spectrum, we execute the following commands

subplot(2,1,2); % second of two plots


freq = (0:79)/(2*n*dt); % abscissa viewing window
plot(freq,amp_spec(1:80)); grid on% plot amplitude spectrum
xlabel('Frequency (Hz)'); % 1 Herz = number of cycles/second
ylabel('Amplitude'); % amplitude as function of frequency

LAB TASK 3:

Make a function to plot waveform and amplitude spectrum of a signal. The function has prototype:
functionspecplot ( t, dt, et, y )
% % Opens a new figure window with two plots:
% the waveform and amplitude spectrum of a signal.
% % On entry :
% t sampling range of the signal;
% dt sampling rate;
% et end of the range;
% y samples of the signal over the range t.
% Sospecplot computes the amplitude spectrum of the signal.
clc
clearall
closeall
dt = 1/100; % sampling rate
et = 4; % end of the interval
t = 0:dt:et; % sampling range
sum=0;
for k=10:20
y=(20-k)*sin(2*pi*k*t);

COMMUNICATION SYSTEM LAB MANUALPage 33


sum=sum+y;
end
x=sum;
Q3(t, dt, et,x)

COMMUNICATION SYSTEM LAB MANUALPage 34


LAB 07

SIMULATION OF COMMUNICATION SYSTEMS USING MATLAB


(AMPLITUDE MODULATION)
Objectives:
The main objective of this session is to learn the basic tools and concepts for simulating communication
systems using MATLAB.

Description:
Our focus in this session will be on using MATLAB for simulating communication systems. How to use
full wave rectifier and filters on MATLAB. A filter in MATLAB is represented by its transfer function.
The transfer function is in general in the form of the division of two polynomials. The filter is completely
defined by the coefficients of the polynomial at the numerator and the polynomial at the denominator.
These are the vectors a and b respectively in the program.

There are many realizations for designing filters. One common realization is Butterworth, which is the
one used here, hence the function name butter.

The butter function has two arguments. The first argument is the order of the filter. The larger the order
the sharper the filter (closer to ideal), but more processing is required. For most of our applications an
order of 3-5 should be sufficient.

The second argument is a coefficient related to the cutoff frequency. Without going into the details of the
derivation, to design a LPF filter of cutoff frequency W, the argument should be set to 2*W*ts, where ts
is the time step size of the program. For more details about the command butter , type:

>> help butter ; in the MATLAB prompt

To apply the filter to a given signal, we use the function filter. This function has three parameters: the
coefficients of the filter a and b, and the vector to be filtered. Note that although we think of the filter
operation in frequency domain, the filter function operates on a time-domain vector. The output should as
well be taken as a time-domain vector.

LAB TASK:

Write a MATLAB program to simulate the following system

COMMUNICATION SYSTEM LAB MANUALPage 35


where m(t) = exp(-100|t|) ;

c(t) = cos(2π 103t)

Also plot the outputs.

m-File:

% Define the time interval

ts=0.00001;

t= -0.1:ts:0.1;

% Define the functions m(t) and c(t)

m=exp(-100*abs(t));

c=cos(2*pi*1000*t);

% Performe the multiplication

g=m.*c;

% Perform full-wave rectification

y=abs(g);

% Create the filter

cutoff=1000; [a b]=butter(5,2*cutoff*ts);

% Get the output after the filter;

z=filter(a,b,y);

% Plot the input and output on the same graph

figure (1)

plot(t,m,t,z);

legend('Input Signal','Output Signal')

xlabel ('time')

ylabel('amplitude')

title ('Case Study')

% Finding the FT of the signals

M=abs(fftshift(fft(m)));

G=abs(fftshift(fft(g)));

Y=abs(fftshift(fft(y)));

COMMUNICATION SYSTEM LAB MANUALPage 36


Z=abs(fftshift(fft(z)));

% Creating the vector for the frequency axis

f=[-length(t)/2:length(t)/2-1]/(length(t)*ts);

% Plotting all FT on one sheet, in a 2x2 matrix format

figure (2)

subplot (221)

plot(f,M)

subplot(222)

plot(f,G)

subplot (223)

plot(f,Y)

subplot(224)

plot(f,Z)

Discussion

% Define the time interval

This is usually the first step in any simulation. There are three parameters to define: the beginning of the
interval, the step size, the end of the interval. The beginning and end of the interval are intuitive; for
periodic signals you want to cover 3-5 periods; for non-periodic signals, you usually want to cover the
non-zero part of the signal.

The selection of the step size is crucial for the accuracy of the simulation. You need enough sample points
to represent the signal. Usually, the step size is taken to be of the order of one hundredth of the smallest
period in the program (Or, the sampling frequency fs = 1/ts should be 100 times the frequency of the
signal). In our example, since we are having c(t) of frequency 1000 Hz, we selected fs = 100000, or ts =
0.00001.

% Define the functions m(t) and c(t)

This is a straightforward step. The function abs stands for | |, while pi=π. Note that the signals m and c
are now vectors of the same size as t.

% Perform the multiplication

This is also a straightforward step. However note the dot after m. Why this is necessary here? What
would happen if you remove the dot?

% Perform full-wave rectification

This is again a straightforward step, provided you recognize that full-wave rectification is mathematically
equivalent to taking the absolute value.

COMMUNICATION SYSTEM LAB MANUALPage 37


% Create the LPF

This operation is frequently encountered in simulating communication systems. A LPF is defined by one
parameter, the cutoff frequency.

A filter in MATLAB is represented by its transfer function. The transfer function is in general in the form
of the division of two polynomials. The filter is completely defined by the coefficients of the polynomial
at the numerator and the polynomial at the denominator. These are the vectors a and b respectively in the
program.

There are many realizations for designing filters. One common realization is Butterworth, which is the
one used here, hence the function name butter.

The butter function has two arguments. The first argument is the order of the filter. The larger the order
the sharper the filter (closer to ideal), but more processing is required. For most of our applications an
order of 3-5 should be sufficient.

The second argument is a coefficient related to the cutoff frequency. Without going into the details of the
derivation, to design a LPF filter of cutoff frequency W, the argument should be set to 2*W*ts, where ts
is the time step size of the program. For more details about the command butter , type:

>> help butter ; in the MATLAB prompt

How many arguments would a BPF require? What are they?

% Get the output after the filter;

In the previous step we have only created the filter. To apply the filter to a given signal, we use the
function filter. This function has three parameters: the coefficients of the filter a and b, and the vector to
be filtered. Note that although we think of the filter operation in frequency domain, the filter function
operates on a time-domain vector. The output should as well be taken as a time-domain vector.

% Finding the FT of the signals

The Fourier Transform of signals can be found in MATLAB using the function fft. It can be used with a
single argument, which is the time-domain vector. The fft function yields only the positive side of the
spectrum. To get the double-sided spectrum, augment fft by fftshift. Finally, if you are only interested in
the amplitude spectrum, augment all by the function abs. The resulting frequency-domain vector will
have the same size as the size of the input time-domain vector.

% Creating the vector for the frequency axis

To plot the frequency spectrum as a function of frequency, you need to create the frequency axis. The
available range of frequencies depends on ts, and is given by the relation:

f=[-length(t)/2:length(t)/2-1]/(length(t)*ts);

% Plotting

We leave this step to the student to explore. Use the help command to read about plot subplot, figure,
legend, xlabel, ylabel, title and axis commands.

COMMUNICATION SYSTEM LAB MANUALPage 38


LAB 07-B
AMPLITUDE MODULATION
Objective:
This lab is related to amplitude modulation and demodulation.

Theory:
Amplitude Modulation:
It is the simplest form of signal processing in which the carrier amplitude is simply changed
according to the amplitude of the information signal,hence the name Amplitude Modulation. When the
information signal’s amplitude is increased the carrier signal’s amplitude is increased and when the
information signal’s amplitude is decreased the carrier signal’s amplitude is decreased. In other
words, the ENVELOPE of the carrier signal’s amplitude contains the information signal.
LAB TASK 1:
In communication we need modulation for proper and reasonable communication. And for modulation we
multiply our message signal with carrier signal. Following code is of modulation of a signal.
MATLAB CODE:
clc; clear all; close all;
ts=1*0.0005;
t=-0.04:ts:0.04;
T=0.02; %gives width
c_f=300; %carrier frequency
sig1=sinc(2*t/T); %at origin sinc function
sig2=sinc(2*t/T-1); %right shifted
sig3=sinc(2*t/T+1); %left shifted
m_sig=2*sig1+sig2+sig3; %message signal
Len=length(t);
Len=2^ceil(log2(Len)); %round length in terms of power of 2
M_freq=fftshift(fft(m_sig,Len)); %FT of msgsgnlfftshift gives origin at zero fft find fourierlen gives how
much
freqm=(-Len/2:Len/2-1)/(Len*ts); %freq axis -Len/2 gives 2 half parts +ve and -ve,
%we want small values so we devide "len*ts"
% above line also tells us len/2+len/2 gives equal to length, but at zero
% it also gives one more length, so we -1 from length to satisfy length
% dimention
c=cos(2*pi*c_f*t); %carrier sgnlc_f is carrier freq
s_dsb=m_sig.*c; %modulation
Len=length(t);
Len=2^ceil(log2(Len)+1);
S_dsb=fftshift(fft(s_dsb,Len)); %fft of modulated sgnl
freqs=(-Len/2:Len/2-1)/(Len*ts);
Tranges=[-0.03 0.03 -2 2]; %time ranges
figure(1)
subplot(221);
tdl=plot(t,m_sig) %we define it equal a veriable so that we can define more properties. i.e it use further
axis(Tranges); title('message signal')
set(tdl,'Linewidth',2); %2 points increases of line width
xlabel('{\it t (sec)}');
ylabel('{\it m} (t})');
subplot(223);

COMMUNICATION SYSTEM LAB MANUALPage 39


td2=plot(t,s_dsb); title('modulated signal')
axis(Tranges);
set(td2,'Linewidth',2);
xlabel('{\it t} (sec)');
ylabel('{\it s} (t})')
Frange=[-600 600 0 200]; %freq ranges
subplot(222)
fdl=plot(freqm,abs(M_freq)); title('F.T of message signal')
subplot(224)
fdl=plot(freqs,abs(S_dsb)); title('F.T of modulated signal')
%Demodulation
s_dm=s_dsb.*c;
S_dm=fftshift(fft(s_dm,Len));
figure(2)
subplot(221);
tdl=plot(t,s_dm); title('demodulated signal')
axis(Tranges);
set(tdl,'Linewidth',2);
xlabel('{\it t (sec)}');
ylabel('{\it m} (t})');
Frange=[-600 600 0 200]
subplot(222)
fdl=plot(freqs,abs(S_dm));title('message signal in freq domain')
subplot(223)
%use low pass filter
B_M=150;
h=fir1(40,[B_M.*ts]);
s_rec=filter(h,1,s_dm);
S_rec=fftshift(fft(s_rec,Len));
fdl=plot(freqs,abs(S_rec)); title('magnitude after filtering')

It displays the following output:

COMMUNICATION SYSTEM LAB MANUALPage 40


Here first two graphs are of message signal in time and frequency domain. 2 nd is modulated signal after
multiplying the carrier signal. In second figure, here is demodulation of message signal. Then apply low
pass filter to remove high frequency components. Then we received our message signal.

LAB TASK 2:
Following figure is given:

Figure 6:Block diagram of AM

To plot m(t), m(-t) and s(t)=s1(t)+s2(t) code is as follows:


clc; clear all; close all;
ts=1*0.0005;t=-0.04:ts:0.04;T=0.01;
sig1=sinc(2*t/T);
sig2=sinc(2*t/T-1);
sig3=sinc(2*t/T+1);
m_sig1=2*sig1+sig2+sig3; %message signal m(t)
m_sig2=-(m_sig1); % inverse message -m(t)
c1=cos(2*pi*300*t); %carrier signal C(t)
c2=-(c1); %inverse carrier signal -C(t)
s=m_sig1.*c1;
z=m_sig2.*c2;
s_dsb1=m_sig1.*c1+c1; %modulated signal s1(t)
s_dsb2=m_sig2.*c2+c2; %modulated signal s2(t)
s_dsb=s_dsb1+s_dsb2; %summation s(t)=s1(t)+s2(t)
figure(1)
subplot(311)
plot(t,m_sig1); title('message 1'); xlabel('Time');
subplot(312)
plot(t,m_sig2); title('inverted message 1'); xlabel('Time');

COMMUNICATION SYSTEM LAB MANUALPage 41


subplot(313)
plot(t,s_dsb); title('sum of modulated signals'); xlabel('Time');

This gives following output:

COMMUNICATION SYSTEM LAB MANUALPage 42


LAB 08

SINGLE SIDE BAND


Objective:
This lab is related to amplitude modulation and demodulation for SSB (single side band).
LAB TASK:
In communication we need modulation for proper and reasonable communication. And for modulation we
multiply our message signal with carrier signal. For single sided band we modulate message signal with
carrier signal and then half of modulated signal is SSB, for this we simply define range and do our work
regularly. Following code is of modulation and demodulation of a signal using SSB.
MATLAB CODE:
clc; clear all; close all;
N=1024;
fs=2048; %sampling frequency
t=(0:N-1)/fs; %interval
fc=600; %carrier frequency
fm1=200; %frequency of message signal
Em1=1; %amplitude of message signal
m=Em1*cos(2*pi*fm1*t); % message Signal
figure(1);
plot(t,m); %plot of message signal
title('Time Domain Representation of original signal');
xlabel('Time'); ylabel('original signal');
mh=Em1*cos((2*pi*fm1*t)-pi/2); %Hilbert Transform of the message signal
sbu=m.*2.*cos(2*pi*fc*t)-mh.*2.*sin(2*pi*fc*t);%Expression for USB SSb
sbl=m.*2.*cos(2*pi*fc*t)+mh.*2.*sin(2*pi*fc*t); % expression for LSB SSB
SBU=2/N*abs(fft(sbu)); % Fourier Transfoem of USB SSB
SBL=2/N*abs(fft(sbl)); % Fourier Transform of LSB SSB
figure(2);
subplot(223);
freq=fs*(0:N/2)/N; %frequency range
plot(freq,SBU(1:N/2+1)) %freq. Domain Plot of USB SSB
title('Frequency Domain Representation');
xlabel('Frequency(HZ)'); ylabel('spectral magnitude');
legend('USB');
subplot(224)
plot(freq,SBL(1:N/2+1), freq,SBL(1:N/2+1)); % Frequency DOmainplot of LSB SSB
title('frequency domain representation');
xlabel('frequency(HZ)'); ylabel('spectral magnitude');
legend('USB','LSB');
%Demodulation of USB:
md=sbu.*cos(2*pi*fc*t); %modulated signal
figure(3)
subplot(211)
plot(t,md); title('demodulated signal');
[b,a]=butter(2,0.1);
mf=filter(b,a,md);
subplot(212)
plot(t,mf)

COMMUNICATION SYSTEM LAB MANUALPage 43


It displays the following output:

Here in first graph there is message signal and demodulated signal and received SSB signal in time
domain. In second figure USB (upper side band) and LSB (lower side band) in time and frequency
domain in given.
Assignment : Write a code for envelop detection in MATLAB

QAM

ts=1*0.0005;
t=-0.04:ts:0.04;
T=0.01;
fc=2200;
sg1=sinc(2*t/T);
sg2=sinc(2*t/T-1);
sg3=sinc(2*t/T+1);
m1=sg1+sg2+sg3;
m2=(sg1+sg2)-abs(t);
len=length(m1);
lt=length(t);
Lfft=2^ceil(log2(lt));
M1=fftshift(fft(m1,Lfft));
M2=fftshift(fft(m2,Lfft));
freqm=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
B=150;
h=fir1(40,[B*ts]);
dem1=m1.*cos(2*pi*fc*t);
dem2=m2.*sin(2*pi*fc*t);
Franges=[-700 700 0 250];

COMMUNICATION SYSTEM LAB MANUALPage 44


s_qam=m1.*cos(2*pi*fc*t)+m2.*sin(2*pi*fc*t);
l=length(t);
Lfft=2^ceil(log2(l)+1);
S_qam=fftshift(fft(s_qam,Lfft));
freq=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
% S1=fftshift(fft(dem1,Lfft));
% S2=fftshift(fft(dem2,Lfft));
S1=fftshift(fft(dem1,Lfft));
S2=fftshift(fft(dem2,Lfft));
%Demodulation begain by using a rectifier
s_dem1=s_qam.*cos(2*pi*fc*t);
S_dam=fftshift(fft(s_dem1,Lfft));
%Demodulation begain by using a rectifier
s_dem2=s_qam.*sin(2*pi*fc*t);
S_dam2=fftshift(fft(s_dem2,Lfft));
%using an ideal low pass filter with bandwidt 150
s_rec1=filter(h,1,s_dem1);
S_rec1=fftshift(fft(s_rec1,Lfft));
s_rec2=filter(h,1,s_dem2);
S_rec2=fftshift(fft(s_rec2,Lfft));
Tranges=[-0.025 0.025 -2 2];
Tranges2=[-0.025 0.025 -2 4];
figure(1)
% Display message signal 1
subplot(221);td1=plot(t,m1);
axis(Tranges); set(td1,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it m1} (t)');
title('Message signal 1');
% Display the QAM modulated signal
subplot(222);td2=plot(t,s_qam);
axis(Tranges); set(td2,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it s}_{\rm DSB} (t)');

title('QAM Modulated Signal');

subplot(223);td3=plot(t,s_dem1);
axis(Tranges); set(td3,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it m1} (t)');
title('First Demodulated Signal 1');

subplot(224);td4=plot(t,s_rec1);
axis(Tranges); set(td4,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it m1} (t)');
title('Detected Signal 1');

figure(2)
subplot(221);td5=plot(t,m2);
axis(Tranges); set(td5,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it m1} (t)');
title('Message signal 2');

subplot(222);td6=plot(t,s_qam);
axis(Tranges); set(td6,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it s}_{\rm DSB} (t)');

title('QAM Modulated Signal');

COMMUNICATION SYSTEM LAB MANUALPage 45


subplot(223);td7=plot(t,s_dem2);
axis(Tranges); set(td7,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it m1} (t)');
title('sec Demodulated Signal 1');

subplot(224);td8=plot(t,s_rec2);
axis(Tranges); set(td8,'Linewidth', 1.5);
xlabel('{\it t} (sec)'); ylabel('{\it m1} (t)');
title('Detected Signal 2');
% Display Branch 1 in Frequency Domain
Franges=[-700 700 0 100];
figure(3);
subplot(221);fd1=plot(freqm,abs(M1));
axis(Franges); set(fd1,'Linewidth', 1.5);
xlabel('{\it f} (Hz)'); ylabel('{\it M1} (f)');
title('Spectrum of Message Signal 1');

subplot(222);fd2=plot(freq,abs(2*S_qam));
axis(Franges); set(fd2,'Linewidth', 1.5);
xlabel('{\it f} (Hz)');ylabel('{\it S}_{\rm QAM} (f)');
title('QAM Spectrum Magnitude');
subplot(223);fd3=plot(freq,abs(S_dam));
axis(Franges); set(fd3,'Linewidth', 1.5);
xlabel('{\it f} (Hz)');ylabel('{\it E}_{1(f)}');
title('First Demodulated Spectrum');
subplot(224);fd4=plot(freq,abs(S_rec1));
axis(Franges); set(fd4,'Linewidth', 1.5);
xlabel('{\it f} (Hz)');ylabel('{\it M}_{d1(f)}');
title('Recovered Spectrum 1');

% Display Branch 2 in Frequency Domain


Franges=[-700 700 0 100];
figure(4);
subplot(221);fd5=plot(freqm,abs(2*M2));
axis(Franges); set(fd5,'Linewidth', 1.5);
xlabel('{\it f} (Hz)'); ylabel('{\it M2} (f)');
title('Spectrum of Message Signal 2');

subplot(222);fd6=plot(freq,abs(2*S_qam));
axis(Franges); set(fd6,'Linewidth', 1.5);
xlabel('{\it f} (Hz)');ylabel('{\it S}_{\rm QAM} (f)');
title('QAM Spectrum Magnitude');

subplot(223);fd7=plot(freq,abs(2*S_dam2));
axis(Franges); set(fd7,'Linewidth', 1.5);
xlabel('{\it f} (Hz)');ylabel('{\it E}_{2(f)}');
title('Second Demodulated Spectrum');
subplot(224);fd8=plot(freq,abs(1*S_rec2));
axis(Franges); set(fd8,'Linewidth', 1.5);
xlabel('{\it f} (Hz)');ylabel('{\it M}_{d2(f)}');
title('Recovered Spectrum 2');

Lab 09
COMMUNICATION SYSTEM LAB MANUALPage 46
Balanced Modulator
Objective: To generate AM-Double Side Band Suppressed Carrier (DSB-SC) signal.
Apparatus Required:

Component/Equipment Specifications/Range Quantity

IC 1496 Wide frequency response up to 1


100 MHz

Internal power dissipation –


500mw(MAX)

Resistors 6.8KΩ 1

10 KΩ, 3.9 KΩ 2 each

1K_Ω,51 KΩ 2 each

Capacitors 0.1 μF 4

Variable Resistor 0-50KΩ 1

(Linear Pot)

CRO 100MHz 1

Function Generator 1MHz 2

Regulated Power Supply 0-30 v, 1A 1

Theory:
Balanced modulator is used for generating DSB-SC signal. A balanced modulator consists of two
standard amplitude modulators arranged in a balanced configuration so as to suppress the carrier wave.
The two modulators are identical except the reversal of sign of the modulating signal applied to them.

COMMUNICATION SYSTEM LAB MANUALPage 47


Fig.1. Balanced Modulator Circuit
Procedure:
1) Connect the circuit diagram as shown in Fig.1.
2) An Carrier signal of 1Vp-p amplitude and frequency of 83 KHz is applied as carrier to pin no.10.
3) An AF signal of 0.5Vp-p amplitude and frequency of 5 KHz is given as message signal to pin
no.1.
4) Observe the DSB-SC waveform at pin no.12.

Observation Table:

Signal AMPLITUDE (Volts) Frequency (Hz)

Message signal

Carrier signal

DSB-SC Signal

Model Waveforms:

COMMUNICATION SYSTEM LAB MANUALPage 48


Precautions:

1. Check the connections before giving the supply


2. Observations should be done carefully

Results:

Inferences:

Questions:
1. What is the efficiency of the DSB-SC modulating system?
2. What are the applications of balanced modulator?
3. What is the effect of amplitude of message on DSB-Sc signal?

COMMUNICATION SYSTEM LAB MANUALPage 49


Lab 10
Frequency Mixer
Objective: To design and obtain the characteristics of a mixer circuit.
Apparatus Required:
Component/Equipment Specifications/Range Quantity

Transistors (BC 107) fT = 300 MHz 1

Pd = 1W

Ic(max) = 100 mA

Resistors 1 KΩ, 6.8 KΩ, 10 KΩ 1 each

Capacitor 0.01μF 1

Inductor 1mH 1

CRO 20MHz 1

Function Generator 1MHz 1

Regulated Power Supply 0-30v, 1A 1

Theory:
Mixers are used in a variety of RF/microwave applications, including military radar, cellular
base stations, and more. An RF mixer is a three-port passive or active device that can modulate
or demodulate a signal. The purpose is to change the frequency of an electromagnetic signal
while (hopefully) preserving every other characteristic (such as phase and amplitude) of the
initial signal. A principal reason for frequency conversion is to allow amplification of the
received signal at a frequency other than that of the RF.

COMMUNICATION SYSTEM LAB MANUALPage 50


Fig.1 A mixer preseted symbolically

Circuit Diagram:

FIG.2. Mixer Circuit

Procedure:
1. Connect the circuit as per the circuit diagram as shown in Fig.2. Assume C=0.1μF and calculate the
1
value Of L1 using f= where f=7KHz
2 π √ L1 C 1
2. Apply the input signals at the appropriate terminals in the circuit.
3. Note down the frequency of the output signal, which is same as the difference frequency of giving
signals.

Sample readings:
Signal Amplitude (Volts) Frequency(KHz)

Input signal1 4 5

COMMUNICATION SYSTEM LAB MANUALPage 51


Input signal2 4 12

Output signal 9 7

Waveforms:

Precautions:
1.Check the connections before giving the supply
2.Observations should be done carefully

Questions:

1: what is frequency mixer ?


2: What are the differences between single- and double-balanced mixers?
3: For what applications are microwave double-balanced mixers best suited?

For Lab 11 and 12 see manual of Communication Systems Trainer

COMMUNICATION SYSTEM LAB MANUALPage 52


Lab 13

Frequency Modultion and Frequency Demodulation using PLL Method

Objective: In this Laboratory exercise you will generate a single-tone modulated FM signal
using the Voltage-controlled Oscillator (VCO) in a Phase-locked loop (PLL)

Task
Build the circuit shown next. This uses the VCO portion of the 4046 PLL.

First, investigate it using the "test input" circuit that is shown in Figure 2. Find the
frequency and sketch the waveform for the three VCO input voltages shown in the table below.
From that information, deterine the FM constant , Kf, for your modulator. See the data analysis
section below for guidence in this calculation.
Second, instead of the "test input" circuit, use, as the input, the function generator with
the sinusoidal output listed as follows:
Frequency = 5 kHz (fm = modulating frequency)
Amplitude = 2 volts (p-p)
D.C.Offset = 5V

COMMUNICATION SYSTEM LAB MANUALPage 53


VCOin Frequency

2VDO/3

VDD/2

VDD/3

Here we assumend that Vss= Ground

Phase Locked Loop

PLL has emerged as one of the fundamental building block in electronic technology. It is used
for the frequency multiplication, FM stereo detector , FM demodulator , frequency shift keying
decoders, local oscillator in TV and FM tuner. It consists of a phase detector, a LPF and a
voltage controlled oscillator (VCO) connected together in the form of a feedback system. The
VCO is a sinusoidal generator whose frequency is determined by a voltage applied to it from an
external source. In effect, any frequency modulator may serve as a VCO. The phase detector or
comparator compares the input frequency, fin , with feedback frequency , f out , (output
frequency). The output of the phase detector is proportional to the phase difference between f in ,
and f out . The output voltage of the phase detector is a DC voltage and therefore m is often refers
to as error voltage . The output of the phase detector is then applied to the LPF , which removes
the high frequency noise and produces a DC lend. The DC level, in term is the input to the VCO.
The output frequency of the VCO is directly proportional to the input DC level. The VCO
frequency is compared with the input frequencies and adjusted until it is equal to the input
frequency. In short, PLL keeps its output frequency constant at the input frequency.
Thus, the PLL goes through 3 states.
1. Free running state.
2. The capture range / mode

COMMUNICATION SYSTEM LAB MANUALPage 54


3. Phase lock state.
Before input is applied, the PLL is in the free running state. Once the input frequency is applied,
the VCO frequency starts to change and the PLL is said to be the capture range/mode. The VCO
frequency continues to change (output frequency) until it equals the input frequency and the PLL
is then in the phase locked state. When phase is locked, the loop tracks any change in the input
frequency through its repetitive action.
Examine the time-domain signal at the VCO output. Essentially, this is a rectangular waveform
with a varying frequency , i.e., a frequency that is modulated. The maximum and minimum
frequencies, fmax and fmin, can be determined using the following formulas:
1
fmin =
T1
1
fmax =
T2
Write an expression for the time domain output, assuming that the output waveform is sinusoidal
like. What is the β for your signal? Examine the spectra using the spectrum analyzer. (Make the
Connection to the spectrum analyzer using a high impedence scope probe). Sketch the spectra
and measure the power in signicant sidebands (powers greater than one percent of the total
transmitted power). Record this data in the table shown in the "report" section.

Data Analysis
The FM constant, Kf , can be determined by plotting the VCO's output frequency v/s the VCO's
input voltage. This should give (approximately) a straight line, its slope is Kf in hert- per-volt.
You will want to conver it to radians/second-per-volt in order to write the expression
for the FM signal you generate. To find β , use

β = [peakmodulatingtoneamplitude/modulatingtonefrequency(inHz)]kf

An alternative method is given by

f max −f min
β=
fm

Use the following circuit for FM demodulation. It is not necessary to use the bu_er and
output low pass fiter.

COMMUNICATION SYSTEM LAB MANUALPage 55


Precautions:

1. Check the connections before giving the supply


2. Observations should be done carefully

Questions:

1. Effect of the modulation index on FM signal?


2. In commercial FM broadcasting, what is highest value of frequency deviation and
audio frequency to be transmitted?

COMMUNICATION SYSTEM LAB MANUALPage 56


Lab 14

Pre-Emphasis & De-Emphasis

Objective:
I) To observe the effects of pre-emphasis on given input signal.
ii) To observe the effects of De-emphasis on given input signal.

Apparatus Required:
As shown in the figure (Pre-emphasis Circuit) and (De-emphasis circuit)

Theory:
The noise has a effect on the higher modulating frequencies than on the lower ones. Thus, if the higher
frequencies were artificially boosted at the transmitter and correspondingly cut at the receiver, an
improvement in noise immunity could be expected, there by increasing the SNR ratio. This boosting of
the higher modulating frequencies at the transmitter is known as pre-emphasis and the compensation at
the receiver is called de-emphasis.

Circuit Diagrams:
For Pre-emphasis:

Fig.1. Pre-emphasis circuit

For De-emphasis:

COMMUNICATION SYSTEM LAB MANUALPage 57


Fig.2. De-emphasis circuit
Procedure:
1. Connect the circuit as per circuit diagram as shown in Fig.1.
2. Apply the sinusoidal signal of amplitude 20mV as input signal to pre emphasis
circuit.
3. Then by increasing the input signal frequency from 500Hz to 20KHz, observe
the output voltage (vo) and calculate gain (20 log (vo/vi).
4. Plot the graph between gain Vs frequency.
5. Repeat above steps 2 to 4 for de-emphasis circuit (shown in Fig.2). by applying
the sinusoidal signal of 5V as input signal.
Sample reading
Table1: Pre-emphasis Vi =

Frequency(KHz) Vo(mV) Gain in dB(20 log Vo/Vi)

0.5

10

11

15

Table2: De-emphasis Vi =

Frequency(KHz) Vo(Volts) Gain in dB(20 log Vo/Vi)

0.150

COMMUNICATION SYSTEM LAB MANUALPage 58


3

Graphs:

Precautions:
1. Check the connections before giving the power supply
2. Observation should be done carefully

Result:

COMMUNICATION SYSTEM LAB MANUALPage 59


Inferences:
Questions:
1. What is the value of time constant used in commercial pre-emphasis
circuit?
2. For which modulated signals pre-emphasis and de-emphasis circuits are
used.
3. On what parameters fc depends?
4. Explain the pre-emphasis and de-emphasis characteristics?

COMMUNICATION SYSTEM LAB MANUALPage 60


Lab 15

Pulse Modulation and Demodulation

Task: Design a complete System using Puls width modulation and demodulation.

Task: Design a complete System using Puls position modulation and demodulation.

Task: Design a system using Puls Amplitude Modulation.

COMMUNICATION SYSTEM LAB MANUALPage 61

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy