communication.pdf
-
Upload
anonymous-j2rscfdm -
Category
Documents
-
view
214 -
download
1
Transcript of communication.pdf
Lab Manual Communication Systems
Updated by: Engr.Onaiza Yousaf
Revised On: 16
th March, 2015
Department of Electrical Engineering The University of Lahore, Lahore, Pakistan
1-KM Raiwind Road, Lahore.
Contents Lab 1 .........................................................................................................................3
Introduction to MALTAB ........................................................................................3
Lab 2 ....................................................................................................................... 16
Introduction to Basic Signals and Signal Operations........................................... 16
Lab 3 ....................................................................................................................... 24
Fourier series, magnitude and phase calculation on Matlab ............................... 24
Lab 4 ....................................................................................................................... 33
Signal Correlation ................................................................................................ 33
Lab 5 ....................................................................................................................... 41
Fourier series, magnitude and phase calculation on Matlab ............................... 41
Lab 6 ....................................................................................................................... 50
Evaluation ........................................................................................................... 50
Lab 7 ....................................................................................................................... 51
Computing Fourier Transforms ........................................................................... 51
Lab 8 ....................................................................................................................... 56
Calculation of Essential Bandwidth ..................................................................... 56
Lab 9 ....................................................................................................................... 60
To design and implement the AM Modulator by balanced modulator using Matlab ............................................................................................................................ 60
Lab 10 ..................................................................................................................... 63
To demodulate a modulated AM signal using Matlab .......................................... 63
Lab 11 ..................................................................................................................... 66
Implement a modulation and demodulation of signal using DSB SC .................. 66
Lab 12 ..................................................................................................................... 73
Implement a modulation and demodulation of signal using SSB SC .................. 73
Lab 13 ..................................................................................................................... 76
Implement a modulation and demodulation of signal using frequency Modulation ............................................................................................................................ 76
Lab 14 ..................................................................................................................... 78
Study the multiplexing and digital modulation techniques ................................... 78
Lab 15 & 16 ............................................................................................................ 81
Study thedifferent digital modulation techniques ................................................. 81
Lab 1
Introduction to MALTAB
Objective: To become familiar with the use of some basic operations such as addition,
subtraction, multiplication, division and some basic commands like eye, zeros,
ones, plot and stem.
Introduction: What Is MATLAB? MATLAB® is a high-performance language for technical computing. It
integrates computation, visualization, and programming in an easy-to-use
environment where problems and solutions are expressed in familiar
mathematical notation. Typical uses include
Math and computation
Algorithm development
Data acquisition
Modeling, simulation, and prototyping
Data analysis, exploration, and visualization
Scientific and engineering graphics
Application development,
including graphical user interface building
MATLAB is an interactive system whose basic data element is an array that
does not require dimensioning. This allows you to solve many technical
computing problems, especially those with matrix and vector formulations, in
a fraction of the time it would take to write a program in a scalar
noninteractive language such as C or Fortran.
The name MATLAB stands for matrix laboratory. MATLAB was originally
written to provide easy access to matrix software developed by the LINPACK
and EISPACK projects. Today, MATLAB engines incorporate the LAPACK
and BLAS libraries, embedding the state of the art in software for matrix
computation.
MATLAB has evolved over a period of years with input from many users. In
university environments, it is the standard instructional tool for introductory
and advanced courses in mathematics, engineering, and science. In industry,
MATLAB is the tool of choice for high-productivity research, development,
and analysis.
MATLAB features a family of add-on application-specific solutions called
toolboxes. Very important to most users of MATLAB, toolboxes allow you to
learn and apply specialized technology. Toolboxes are comprehensive
collections of MATLAB functions (M-files) that extend the MATLAB
environment to solve particular classes of problems. Areas in which toolboxes
are available include signal processing, control systems, neural networks,
fuzzy logic, wavelets, simulation, and many others.
The MATLAB System The MATLAB system consists of five main parts:
Development Environment. This is the set of tools and facilities that help you
use MATLAB functions and files. Many of these tools are graphical user
interfaces. It includes the MATLAB desktop and Command Window, a
command history, an editor and debugger, and browsers for viewing help, the
workspace, files, and the search path.
The MATLAB Mathematical Function Library. This is a vast collection of
computational algorithms ranging from elementary functions, like sum, sine,
cosine, and complex arithmetic, to more sophisticated functions like matrix
inverse, matrix eigenvalues, Bessel functions, and fast Fourier transforms.
The MATLAB Language. This is a high-level matrix/array language with
control flow statements, functions, data structures, input/output, and object-
oriented programming features. It allows both "programming in the small" to
rapidly create quick and dirty throw-away programs, and "programming in the
large" to create large and complex application programs.
Graphics. MATLAB has extensive facilities for displaying vectors and
matrices as graphs, as well as annotating and printing these graphs. It includes
high-level functions for two-dimensional and three-dimensional data
visualization, image processing, animation, and presentation graphics. It also
includes low-level functions that allow you to fully customize the appearance
of graphics as well as to build complete graphical user interfaces on your
MATLAB applications.
The MATLAB Application Program Interface (API). This is a library that
allows you to write C and Fortran programs that interact with MATLAB. It
includes facilities for calling routines from MATLAB (dynamic linking),
calling MATLAB as a computational engine, and for reading and writing
MAT-files. Have marginal abilities for visual data display.
This is a very important tool used for making long complicated calculations
and
Plotting graphs of different functions depending upon our requirement. Using
MATLAB an m-file is created in which the basic operations are performed
Which leads to simple short and simple computations of some very
complicated
Problems in no or very short time.
Some very important functions performed by MATLAB are given as follows:
Matrix computations
Vector Analysis
Differential Equations computations
Integration is possible
Computer language programming
Simulation
Graph Plotation
2-D & 3-D Plotting
Benefits:
Some Benefits of MATLAB are given as follows:
• Simple to use
• Fast computations are possible
• Wide working range
• Solution of matrix of any order
• Desired operations are performed in matrices
• Different Programming languages can be used
• Simulation is possible
Basic Commands: Some basic MATLAB commands are given as follows:
A) Operators
MATLAB provides several arithmetic and logical operators, some of which
are as follows. For a complete list, MATLAB‟s help manual should be
consulted.
== equality
+ addition
- subtraction or minus
* multiplication
.* array multiplication
^ power
.^ array power
/ division
./ array division
<> relational operators & logical AND
| logical OR
~ logical NOT
‟ transpose
.‟ array transpose
Addition:
A+B
Example:
Subtraction:
A-B
Example:
Multiplication:
A*B>> Matrix Multiplication
A.*B >>Element-wise Multiplication
Example:
Division:
A/B>> Matrix Division
A./B>>Element-wise Division
Example:
Power:
A^B
A.^B>> Power of each element individually
Example:
B) Numbers
MATLAB is a high-precision numerical engine and can handle all types of
numbers, that is, integers, real numbers, complex numbers, among others, with
relative ease. For example, the real number 1.23 is represented as simply 1.23
while the real number 4.56 × 10^7 can be written as 4.56e7. The imaginary
number √ is denoted either by 1i or 1j. Hence the complex number whose real
part is 5 and whose imaginary part is 3 will be written as 5+1j*3. Other
constants preassigned by MATLAB are pi for π, inf for ∞, and NaN for not a
number (for example, 0/0). These preassigned constants are very important
and, to avoid confusion, should not be redefined by users.
Example:
C) Variables
In MATLAB, which stands for MATrixLABoratory, the basic variable is a
matrix, or an array. Hence, when MATLAB operates on this variable, it
operates on all its elements. This is whatmakes it a powerful and an efficient
engine. Now test the following assignments and chose an appropriate answer.
This explains available matrix types in MATLAB:
>> a = [3]
a. Scalar
b. Row Vector
c. Column Vector
d. Matrix
>>x = [1,2,3]
a. Scalar
b. Row Vector
c. Column Vector
d. Matrix
>>y = [1;2;3]
a. Scalar
b. Row Vector
c. Column Vector
d. Matrix
>>A = [1,2,3;4,5,6]
a. Scalar
b. Row Vector
c. Column Vector
d. Matrix
MATLAB provides many useful functions to create special matrices. These include zeros(M,N) for creating a matrix of all zeros, ones(M,N) for creating matrix of all ones, eye(N) for creating an N × N identity matrix, etc. Consult MATLAB’s help manual and give two examples for each: ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Exercise # 1 Generate and plot of the following functions with four panels. (a)
(b)
(c)
(d) CODE: FIGURE:
Short Questions:
1) What is the difference between plot and stem?
2) What is the difference between these two commands?
A=[1:2:3]; and A=[1:2:3]
3) Find an error.
Assignment: Question:
Lab 2
Introduction to Basic Signals and Signal Operations
Objective:
To become familiar with the use of some basic signals (unit step
and delta) and signal operations such as time scaling, time shifting, inversion
or folding.
Soft ware Used:
MATLAB
Introduction:
Discrete time signals are defined only at certain specific values of time. They
can be represented by x[n] where „n‟ is integer valued and represents discrete
instances in time. i.e:
X[n] = {…., x[-1], x[0] ,x[1] ,…..}
Where the up-arrow indicates the sample at n=0.
In MATLAB, we can represent a finite-duration sequence like above by a row
of vector of appropriate values. However such a vector does not have any
information about sample position n. therefore a correct representation of x[n]
would require two vectors, one each for x and n. for example a signal
X[n] = {2,1,-1,0,1,4,3}
>>n=[-3,-2,-1,0,1,2,3];
>>x=[2,1,-1,0,1,4,3];
An arbitrary infinite duration signal cannot be represented by MATLAB
due to finite memory limitations.
Unit Step Function
Unit Step Function:
U(n) is the unit step function defined by:
Delta Function
Delta Function:
&(n) is the delta function defined by:
Basic Signal and Signal Operation:
Basic functions can be defined by using MATLAB‟s m-file.Two MATLAB programs
(ustep.m and impulse.m) that implement two basic functions when a vector`t‟ is provided:
ustep.m implements unit step function u(t)
impulse.m implements impulse function &(t)
__________________________________________________________________________
__
%(file name ustep.m) %ustep function is a function of time 't' %ustep(t)=0 if t<0 %ustep(t)=1 if t>0 function y=ustep(t)
y=(t>=0)
end
__________________________________________________________________________
__
%(file name impulse.m)
%impulse(t)=0 if t>0 %impulse(t)=0 if t<0 %impulse(t)=1 if t=0
function y=impulse(t)
y=(t==0);
end
Exercise:
(1)Use above function to plot unit step sequence having range between 1 and
15.
CODE:
t=1:15;
x=ustep(t);
stem(t,x)
GRAPH:
(2)Use above function to plot unit step sequence having range between 1 to 15,
shifted at n=-3.
CODE:
t=1:15;
x=ustep(t-3);
stem(t,x)
GRAPH:
(3) Use above function to plot unit sample sequence that has a value at n=0.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t);
stem(t,x)
GRAPH:
(4) Use above function to plot unit sample sequence that has a value at n=3.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t-3);
stem(t,x)
GRAPH:
SIGNAL OPERATIONS:
a.Shifting
b.Scaling
c.Time Inversion
(1)Apply time shifting ,time scaling and time inversion to the following signal.
x(t)=exp(-|t|/4)[u(t)-u(t-4)]
Time Shifting: Time Scaling: Time Inversion
x1(t)=x(t+2) x2(t)=x(2t) x3(t)=x(2-2t)
CODE: t=-5:5; x=exp(-abs(t)./4).*(ustep(t)-ustep(t-4)); subplot(221); axis([-3 5 -.5 1.5]); plot(t,x); grid on; title('original signal') xlabel('t'); ylabel('x(t)');
%Time Shifting: x1(t)=x(t+2) t1=t+2; x1=exp(-abs(t1)./4).*(ustep(t1)-ustep(t1-4)); subplot(222); axis([-3 5 -.5 1.5]); plot(t,x1); grid on; title('shifted signal') xlabel('t'); ylabel('x(t1)');
% Time Scaling: x2(t)=x(2t)
t2=t.*2; x2=exp(-abs(t2)./4).*(ustep(t2)-ustep(t2-4)); subplot(223); axis([-3 5 -.5 1.5]); plot(t,x2); grid on; title('scaled signal') xlabel('t'); ylabel('x(t2)');
% Time Inversion: x3(t)=x(2-2t)
t3=2-t*2; x3=exp(-abs(t3)./4).*(ustep(t3)-ustep(t3-4)); subplot(224); axis([-3 5 -.5 1.5]); plot(t,x3); grid on; title('inverted signal') xlabel('t'); ylabel('x(t3)');
GRAPH:
Questions: Q#1: For the signal shown in figure, sketch .
Lab 3
Fourier series, magnitude and phase calculation on Matlab
Objective:
To become familiar with the use of some basic signals (unit step)
and computing the coefficient of Fourier series and also plot the magnitude
and phase spectra.
Soft ware Used:
MATLAB
Introduction:
Transforms are used extensively in engineering to change the frame of
reference between the time domain and the frequency domain. Many
techniques exist for analyzing steady-state and smoothly changing systems in
the time domain, but complex systems often can be more easily analyzed in
other domains.
Fourier series and the Fourier transform play a vital role in many areas of
engineering such as communications and signal processing. These
representations are among the most powerful and most common methods of
analyzing and understanding signals. A solid understanding of Fourier series
and the Fourier transform is critical to the design of filters and is beneficial in
developing the understanding of many natural phenomena.
Almost all periodic signals can be represented as an infinite sum of sine and
cosines. This sum is called a Fourier series representation and is defined for a
periodic function of period T with the following equation.
∑( cos
sin
)
Where a0, an and bn are the Fourier series coefficients. These coefficients can be calculated
by applying the following equations:
∫
cos
t an
∫
sin
t
If the Fourier coefficients are written as a single complex number with real part
representing the coefficients of the cosine series and imaginary parts representing
coefficients of the sine series, we can write the complex form of the Fourier series as
∑
where
∫
Unit Step Function:
U(n) is the unit step function defined by:
Delta Function
Delta Function:
&(n) is the delta function defined by:
Basic Signal and Signal Operation:
Basic functions can be defined by using MATLAB‟s m-file.Two MATLAB programs
(ustep.m and impulse.m) that implement two basic functions when a vector`t‟ is provided:
ustep.m implements unit step function u(t)
impulse.m implements impulse function &(t)
__________________________________________________________________________
__
%(file name ustep.m) %ustep function is a function of time 't'
%ustep(t)=0 if t<0 %ustep(t)=1 if t>0 function y=ustep(t)
y=(t>=0)
end
__________________________________________________________________________
__
%(file name impulse.m)
%impulse(t)=0 if t>0 %impulse(t)=0 if t<0 %impulse(t)=1 if t=0
function y=impulse(t)
y=(t==0);
end
Exercise: (1)Use above function to plot unit step sequence having range between 1 and
15.
CODE:
t=1:15;
x=ustep(t);
stem(t,x)
GRAPH:
(2)Use above function to plot unit step sequence having range between 1 to 15,
shifted at n=-3.
CODE:
t=1:15;
x=ustep(t-3);
stem(t,x)
GRAPH:
(3) Use above function to plot unit sample sequence that has a value at n=0.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t);
stem(t,x)
GRAPH:
(4) Use above function to plot unit sample sequence that has a value at n=3.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t-3);
stem(t,x)
GRAPH:
CODE: Fourier series of Saw Tooth Wave
Plot of saw tooth wave
In this section we take an arbitrary saw tooth wave and plot it. Next we plot the magnitude
and phase of the Fourier co-efficient. Then reconstruct the saw tooth wave by combining
various harmonics.
x = [0.1 0.9 0.1]; % 1 period of x(t) x = [x x x x]; % 4 periods of x(t) tx = [-2 -1 0 0 1 2 2 3 4 4 5 6]; % time points for x(t) plot (tx , x ); grid; xlabel('Time (sec)'); ylabel('Amplitude '); title ('Periodic Signal x(t)'); axis ([-2 6 0 1]);
Figure 1
Code: Magnitude and Phase Plot
a0 = 0.5; % DC component of Fourier series ph0 = 0; n = [1 3 5 7 9]; % value of n to be evaluated an = -pi./ ( pi * n ) .^2 ; % Fourier Series C officients mag_an = abs (an); phase_an = -180 * ones (1, length (n)); n = (n); mag_an = [mag_an]; % including a0 with a_n; phase_an = [phase_an]; figure (2); clf; subplot (2, 1 , 1); plot (n, mag_an, 'o'); grid; xlabel('Harmonic Number'); ylabel ('Magnitude'); title (' Fourier Series Magnitude ');
axis ( [ 0 10 0 0.6 ] ); subplot ( 2 , 1, 2); plot (n,phase_an, 'o'); grid; xlabel( 'Harmonic Number'); ylabel ('Phase (radians)'); title ('Fourier Series Phase ');
Graph:
Questions: Q#1:Find the strength of a given signal within the shaded area?
Lab 4
Signal Correlation
Objective:
To become familiar with the use of some basic signals (unit step
and delta) and square root of energies and correlation coefficients.
Soft ware Used:
MATLAB
Introduction: Correlation is an important concept that is used to
determine the degree of similarity between two signals. The value of
correlation coefficient lies between -1 to 1.
Formula: If we have two signals and we want to find the
similarity between these two signals. Correlation coefficient determines the
degree of similarity in between them. Formula is given below.
∫
√ √
Unit Step Function
Unit Step Function:
U(n) is the unit step function defined by:
Delta Function
Delta Function:
&(n) is the delta function defined by:
Basic Signal and Signal Operation:
Basic functions can be defined by using MATLAB‟s m-file.Two MATLAB programs
(ustep.m and impulse.m) that implement two basic functions when a vector`t‟ is provided:
ustep.m implements unit step function u(t)
impulse.m implements impulse function &(t)
__________________________________________________________________________
__
%(file name ustep.m) %ustep function is a function of time 't' %ustep(t)=0 if t<0 %ustep(t)=1 if t>0 function y=ustep(t)
y=(t>=0)
end
__________________________________________________________________________
__
%(file name impulse.m)
%impulse(t)=0 if t>0 %impulse(t)=0 if t<0 %impulse(t)=1 if t=0
function y=impulse(t)
y=(t==0);
end
Exercise: (1)Use above function to plot unit step sequence having range between 1 and
15.
CODE:
t=1:15;
x=ustep(t);
stem(t,x)
GRAPH:
(2)Use above function to plot unit step sequence having range between 1 to 15,
shifted at n=-3.
CODE:
t=1:15;
x=ustep(t-3);
stem(t,x)
GRAPH:
(3) Use above function to plot unit sample sequence that has a value at n=0.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t);
stem(t,x)
GRAPH:
(4) Use above function to plot unit sample sequence that has a value at n=3.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t-3);
stem(t,x)
GRAPH:
SIGNAL Correlation:
CODE: clc
t=[-1:0.01:6]; x=sin(2*pi*t); g1=sin(2*pi*t).*[0.707*(ustep(t)-ustep(t-1))]; g2=sin(t).*[0.707*(ustep(t))];
subplot(131); plot(t,x); xlabel('t'); ylabel('x(t)'); axis([0 1 -1 1]); grid
subplot(132); plot(t,g1); xlabel('t'); ylabel('g1(t)'); axis([0 1 -1 1]); grid
subplot(133); plot(t,g2); xlabel('t'); ylabel('g2(t)'); axis([0 6 -1 1]); grid
e0=sum(x.*conj(x))*0.01; e1=sum(g1.*conj(x))*0.01; e2=sum(g2.*conj(x))*0.01;
p0=sum(x.*conj(x))*0.01/(sqrt(e0*e0)) p1=sum(x.*conj(g1))*0.01/(sqrt(e0*e1)) p2=sum(x.*conj(g2))*0.01/(sqrt(e0*e2))
GRAPH:
Questions: Q#1: For the signal and . Find the degree of similarity between
these signals.
Lab 5
Fourier series, magnitude and phase calculation on Matlab
Objective:
To become familiar with the use of some basic signals (unit step)
and computing the coefficient of Fourier series and also plot the magnitude
and phase spectra.
Soft ware Used:
MATLAB
Introduction:
Transforms are used extensively in engineering to change the frame of
reference between the time domain and the frequency domain. Many
techniques exist for analyzing steady-state and smoothly changing systems in
the time domain, but complex systems often can be more easily analyzed in
other domains.
Fourier series and the Fourier transform play a vital role in many areas of
engineering such as communications and signal processing. These
representations are among the most powerful and most common methods of
analyzing and understanding signals. A solid understanding of Fourier series
and the Fourier transform is critical to the design of filters and is beneficial in
developing the understanding of many natural phenomena.
Almost all periodic signals can be represented as an infinite sum of sine and
cosines. This sum is called a Fourier series representation and is defined for a
periodic function of period T with the following equation.
∑( cos
sin
)
Where a0, an and bn are the Fourier series coefficients. These coefficients can be calculated
by applying the following equations:
∫
cos
t an
∫
sin
t
If the Fourier coefficients are written as a single complex number with real part
representing the coefficients of the cosine series and imaginary parts representing
coefficients of the sine series, we can write the complex form of the Fourier series as
∑
where
∫
Unit Step Function:
U(n) is the unit step function defined by:
Delta Function
Delta Function:
&(n) is the delta function defined by:
Basic Signal and Signal Operation:
Basic functions can be defined by using MATLAB‟s m-file.Two MATLAB programs
(ustep.m and impulse.m) that implement two basic functions when a vector`t‟ is provided:
ustep.m implements unit step function u(t)
impulse.m implements impulse function &(t)
__________________________________________________________________________
__
%(file name ustep.m) %ustep function is a function of time 't' %ustep(t)=0 if t<0 %ustep(t)=1 if t>0 function y=ustep(t)
y=(t>=0)
end
__________________________________________________________________________
__
%(file name impulse.m)
%impulse(t)=0 if t>0 %impulse(t)=0 if t<0 %impulse(t)=1 if t=0
function y=impulse(t)
y=(t==0);
end
Exercise: (1)Use above function to plot unit step sequence having range between 1 and
15.
CODE:
t=1:15;
x=ustep(t);
stem(t,x)
GRAPH:
(2)Use above function to plot unit step sequence having range between 1 to 15,
shifted at n=-3.
CODE:
t=1:15;
x=ustep(t-3);
stem(t,x)
GRAPH:
(3) Use above function to plot unit sample sequence that has a value at n=0.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t);
stem(t,x)
GRAPH:
(4) Use above function to plot unit sample sequence that has a value at n=3.
Range from n=0 to n=10.
CODE:
t=0:10;
x=impulse(t-3);
stem(t,x)
GRAPH:
CODE: Fourier series of Saw Tooth Wave
Plot of saw tooth wave
In this section we take an arbitrary saw tooth wave and plot it. Next we plot the magnitude
and phase of the Fourier co-efficient. Then reconstruct the saw tooth wave by combining
various harmonics.
x = [0.1 0.9 0.1]; % 1 period of x(t) x = [x x x x]; % 4 periods of x(t) tx = [-2 -1 0 0 1 2 2 3 4 4 5 6]; % time points for x(t) plot (tx , x ); grid; xlabel('Time (sec)'); ylabel('Amplitude '); title ('Periodic Signal x(t)'); axis ([-2 6 0 1]);
Figure 1
Code: Magnitude and Phase Plot
a0 = 0.5; % DC component of Fourier series ph0 = 0; n = [1 3 5 7 9]; % value of n to be evaluated an = -pi./ ( pi * n ) .^2 ; % Fourier Series C officients mag_an = abs (an); phase_an = -180 * ones (1, length (n)); n = (n); mag_an = [mag_an]; % including a0 with a_n; phase_an = [phase_an]; figure (2); clf; subplot (2, 1 , 1); plot (n, mag_an, 'o'); grid; xlabel('Harmonic Number'); ylabel ('Magnitude'); title (' Fourier Series Magnitude '); axis ( [ 0 10 0 0.6 ] ); subplot ( 2 , 1, 2); plot (n,phase_an, 'o'); grid; xlabel( 'Harmonic Number'); ylabel ('Phase (radians)'); title ('Fourier Series Phase ');
Graph:
Questions: Q#1:Find the strength of a given signal within the shaded area?
Lab 6
Evaluation Pre-Lab: Lab Manual 1 to 5
Soft ware Used:
MATLAB
Questions:
(1) Apply time shifting, time scaling and time inversion to the following signal.
x(t)=exp(-|t|/4)[u(t)-u(t+4)]
Time Shifting: Time Scaling: Time Inversion
x1(t)=x(t+2) x2(t)=x(2t) x3(t)=x(2-2t)
(2) Find the signal energy and convert this energy signal to a power signal.
x(t)=exp(-|t|/4)[u(t)-u(t+4)]
Lab 7
Computing Fourier Transforms Objective: To become familiar with the use of fft n cart2pol commands.
Pre-Lab: Chapter #3 of B.P.Lathi
Soft ware Used:
MATLAB
Introduction: Use DFT(implementation by theft algorithm) to compute the
fourier transform of .Plot the resulting fourier spectra.
We first determine the and .The fourier transform of ) is
this low pas signal is not band limited. Let us take its essential bandwidth to be
the frequency where | | become 1% of its peak value at .Obsevere
that
| |
√
Also the peak of is at is 0.5.Hence the essential
bandwidth B is at ,where
B=
Hz
Let us round this value down to =0.0015625 second so that we have 64
samples per second. the second issue is to determine . The signal is not time
limited. We need to truncate it at such that g( )<<1.We shall pick
(eight times constant of the signals), which yields
.This is
power of 2. Note that there is a great deal of flexibility in determine and
.Depending upon the accuracy desired and the computational capacity
available. We could just as well have picked and
, yielding
, although this would have given a slightly higher aliasing error.
Code:
GRAPH:
Question:
Find the fourier transform of ).
Lab 8
Calculation of Essential Bandwidth Pre-Lab: Chapter #3 of B.P.Lathi
Soft ware Used:
MATLAB
Introduction:
The spectra of most signals extend to infinity.
However, because the energy of a practical signal is finite. The
signal spectrum must approach 0 as f approaches infinity. most of
the signal energy must contain within the certain band of B Hz is
negligible. we can therefore suppress the signal spectrum beyond B
Hz with little effect on signal shape and energy. The bandwidth is
said to be the essential bandwidth of the signal
Code:
function[p]=sink(x)
p=((sin(x./2))./(x./2)).^2
for b=0:.1:2
ti=1
x=2*pi.*b*ti
qd=quad(@sink,0,x);
ans=(qd./pi)
hold on
plot(b,ans)
xlabel('values of b')
ylabel('values of Eb/Eg=ans')
title('essentail bandwidth')
end
GRAPH:
Description:
• It is rectangular pulse
• 1st calculate its energy that is “ti” gives it some numeric value as 1
• Fourier transform of rect is sinc function
• Convert the sinc into sin as sinc=sin(x)/x
• Set the limits of sin function from 0 to x=2bti π
• Integrate this function by calling the sin function
• Divide the answer of integration by π
• Ans=Eb/Eg
• Hold on command is used to show all the values of “b” that is “for loop”
• Essential band width contain 90% energy
• Bandwidth of rect pulse is 1/ti Hz
• It is shown as 0.9 on graph
Question:
Estimate the essential bandwidth W (in rads/s) of the
signal ) if the essential bandwidth is required to contain 95% of the
signal energy.
Lab 9
To design and implement the AM Modulator by balanced modulator using Matlab
Pre-Lab: Chapter #4 of B.P.Lathi
Soft ware Used:
MATLAB 2009b
Introduction:
In amplitude Modulation (AM), we utilize the audio signal to modulate the amplitude of the carrier signal, which means that the amplitude of the carrier signal will be varied with the amplitude of the audio signal. The waveform of AM modulation is shown here
Figure: 1. Signal waveform of amplitude modulation
Let the audio signal be ))2cos( tfA mm and carrier signal be )2cos( tfA cc , then
the amplitude modulation can be expressed as
)2cos()]2cos([)( tfAtfAAtX ccmmDCAM
(1)
= )2cos()]2cos(1[ tftfmAA cmcDC
DCm AAm /
DCA DC Signal Amplitude
mA Audio signal amplitude
CA Carrier signal amplitude
mf Audio signal frequency
cf Carrier signal frequency
From equation (1) we notice that the variation of the magnitude
)]2cos(1[ tfmAA mcDC of the carrier signal can be controlled by the parameter
“m”. This means we can change the magnitu e of the au io signal mA or DC signal
DCA to control the level or depth of the carrier signal. Therefore this parameter “m”
is known as modulation index.
Besides we can also rewrite this equation (1) as
)2cos(]})(2cos[])(2{cos[2
1tfAAtfftffmAX mCDCmcmcDCAM
(2) The first term represents double sideband signals, the second term represents the carrier signal. From equation (2) we can sketch the frequency spectrum of amplitude modulation as shown in fig. 3. Since the audio signal is hidden in the double sidebands and the carrier signal does not contain any message therefore the power is consumed in the carrier during the transmission of amplitude modulation signal. For this reason the transmission efficiency of AM modulation is lower than double sidebands suppressed carrier (DSB-SC) modulation but its demodulation circuit is much more simple.
Figure: 2. Frequency spectrum of amplitude modulation signal
There is an important parameter “m” in equation (1) calle mo ulation in ex or depth of modulation. Normally it I represented in percentage, so we also call modulation percentage. Modulation index is an important parameter in equation (1) the definition is as follow
m= Audio signal amplitude / Dc signal magnitude %100%100 DC
m
A
A
(3)
Generally the magnitude of DC signal is not easy to measure: therefore we express the modulation index in another form
%100minmax
minmax
EE
EEm (4)
Where Emax and Emin as shown in figure (1) Are mC AAE max and
mC AAE min .
We know that at amplitude modulation the audio signal is hidden in the double sidebands, so if the double sidebands signals are getting stronger, the transmission efficiency is getting better. From equation 2 we know that the double sideband signals are proportional to the modulation index. Thus the larger the modulation index the better the transmission efficiency. Normally modulation index is smaller or equal to 1. If greater than 1 we call it over-modulation as shown in figure 3. From that figure we can see that the variation of the carrier signal is no longer a sinusoidal wave, it is rather a distorted sinusoidal wave, therefore this kind of signal is unable to demodulate and recover to original signal by using the envelop detection.
MATLAB CODE
clc; clear all; close all; Ac=2; %carrier amplitude fc=0.5; %carrier frequency Am=.5; %message signal amplitude fm=.05; %message signal frequency Fs=100; %sampling rate/frequency ka=1; %modulation coefficient t=[0:0.1:50]; %defining the time range & disseminating it into samples ct=Ac*cos(2*pi*fc*t); %defining the carrier signal wave mt=Am*cos(2*pi*fm*t); %defining the message signal AM=ct.*(1+ka*mt); %Amplitude Modulated wave, according to the standard definition subplot(3,1,1); %plotting the message signal wave plot(mt); ylabel('Message signal'); subplot(3,1,2); %plotting the carrier signal wave plot(ct); ylabel('carrier'); subplot(3,1,3); %plotting the amplitude modulated wave plot(AM); ylabel('AM signal');
Exercise 1. Define AM and draw its spectrum?
2. Define modulation index?
3. Now modify modulation index and show over-modulation in graph.
4. What are different degrees of modulation?
Lab 10
To demodulate a modulated AM signal using Matlab
Pre-Lab: Chapter #4 of B.P.Lathi
Soft ware Used:
MATLAB 2009b
Introduction:
The AM demodulator can be implemented by utilizing a balanced modulator. We call this type of modulator as synchronous detector or product detector. Figure 2.4 is the block diagram of product detector. In figure 2.4 we notice that the design of product detector is to multiply the modulated AM signal by synchronized carrier signal in AM modulator.
Let )(tX AM be the modulated be the modulated AM signal, )(tX c be the carrier
signal, i.e.:
)2cos()][2cos(1[)( tfAtfmAtX ccmDCAM
(2.1)
)2cos()( tfAtX ccc
(2.2) When these two signals input two different ports of balanced modulator then the output signal of the balanced modulator is as follow
)()()( txtkxtx AMcout
)2(cos]2cos(1[ 22tftfmAkA cmcDC
= )2(2cos[)]2cos(1[2
)2cos(22
222
tftfmAkA
tfmAkAAkA
cmcDC
mcDCcDC
(2.3) Where k represents the gain of the balanced modulator. In equation (2.3) the first term is the DC signal, second term is the audio signal and third term is the second harmonic of modulated AM signal. If we take out the second term by using the low pass filter as shown in fig. 2.4 then we can obtain the exact demodulated AM signal or audio signal.
Fig. 2.4: block diagram of Product detector Fig. 2.5 is the circuit diagram of the circuit diagram of the product detector. Variable resistor VRI controls the input magnitude of the carrier signal; variable resistor VR2 controls the input magnitude of the modulated AM signal; then the ouput signal of MC1496 IS LOCATED AT PIN 12. C7, C9, and R8 comprise a low pass filter which can remove the unwanted third term of Eq. (2.3), i.e. second harmonic of amplitude modulated signal. The DC signal, which is the first term of the Eq. (2.3) can be blocked by C10. Therefore the signal we obtain at output port will be:
)2cos(2
)(2
tfmAkA
tx mcDC
out
(2.4) Equation (2.4) representsthe audio signal or in other words the original modulated signal can be taken out by product detector.
MATLAB CODE
Fs = 44100;
T = 1;
Fc = 15000;
Fm = 10;
% Low-pass filter design
[num,den] = butter(10,1.2*Fc/Fs);
% Signals
t = 0:1/Fs:T;
x = cos(2*pi*Fm*t);
y = ammod(x,Fc,Fs);
z = amdemod(y,Fc,Fs);
w = amdemod(y,Fc,Fs,0,0,num,den);
% Plot
figure('Name','AM Modulation');
subplot(4,1,1); plot(t,x); title('Modulating signal');
subplot(4,1,2); plot(t,y); title('Modulated signal');
subplot(4,1,3); plot(t,z); title('Demodulated signal');
subplot(4,1,4); plot(t,w); title('Demodulated signal (filtered)');
Results
Exercise
1. Generate a carrier of 25KHz and Modulating signal of 5 KHz
1. First modulate and
2. Then demodulate a signal
Lab 11
Implement a modulation and demodulation of signal using DSB SC
Pre-Lab: Chapter #4 of B.P.Lathi
Soft ware Used:
MATLAB 2009b
Introduction:
The DSB-SC modulator output follows eqn. as given next.
The coherent DSB-SC requires a synchronized local oscillator and works on following
principle. Please refer to eqn
A low pass filter filters out the message signal from above.
The SIMULINK implementation is first shownforsinusoidalmodulatingsignalandthen for
a composite signal made up of two sinusoids. Next it is shown how an AM signal (DSB-
C) with modulation index 1.2 is recovered through coherent detection. Please refer to
result of mini-project on Amplitude Modulation Demodulation using SIMULINK model
for comparison. Finally, using spectrumscope frequency domain representation of
modulated and demodulated signal is seen andcompared. It is seen that for modulated
signal information is available around carrierfrequency while for demodulated signal in
baseband only.
The following shows SIMULINK model preparation and parameterization of local
oscillator.
The following shows time scope output for 10 second simulation, original and expanded
time axis.
The following shows preparation of model for composite signal and its performance.
The following shows DSB-C coherent detection for modulation index 1.2. Please refer to
mini-project on Amplitude Modulation Demodulation for comparison.
The following shows use of spectrum scope, its parameterization and display. The input
of bottomscope is output port of filter block which is renamed. Else this by default
shows „Ch1‟ as legend. The modulating signal frequency is made 3000Hz for better
visualization.
Note that the range 0.5 MHz in frequency axis refers to Fs/2 = 100000/2 = 50000 Hz.
EXERSCISE 1. What is difference between Am with Large carrier and DSB SC communication.
2. Do both have same demodulation techniques.
Lab 12
Implement a modulation and demodulation of signal using SSB SC
Pre-Lab: Chapter #4 of B.P.Lathi
Soft ware Used:
MATLAB 2009b
Introduction:
%Single SideBand Modulation %By Naveed Ahmad Chughtai N = 1024; fs = 2048; ts = 1/fs; %t = (0:ts:1); t=(0:N-1)/fs; fc = 600; %Carrier frequency !! Limit fc<800 to avoid freqdomain aliasing fm1 = 200; Em1 = 1; m = Em1*cos(2*pi*fm1*t); %Message 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 Transform of USB SSB SBL = 2/N*abs(fft(sbl)); %Fourier Transform of LSB SSB freq = fs * (0 : N/2) / N; close all; figure(2) subplot(221); plot(10*t(1:200),sbu(1:200),'r');%Time Domain Plot of USB SSB title('Time Domain Representation === USB');
xlabel('Time'); ylabel('Modulated Signal'); subplot(222) plot(10*t(1:200),sbl(1:200),'b');%Time Domain Plot of LSB SSB title('Time Domain Representation === LSB'); xlabel('Time'); ylabel('Modulated Signal'); subplot(223); plot(freq,SBU(1:N/2+1)) title('Frequency Domain Representation'); xlabel('Frequency(Hz)'); ylabel('Spectral Magnitude'); legend('USB'); subplot(224) plot(freq,SBL(1:N/2+1)); %Frequency domain plot title('Frequency Domain Representation'); xlabel('Frequency(Hz)'); ylabel('Spectral Magnitude'); legend('LSB'); figure(4) plot(freq,SBU(1:N/2+1),freq,SBL(1:N/2+1)); title('Frequency Domain Representation'); xlabel('Frequency(Hz)'); ylabel('Spectral Magnitude'); legend('USB','LSB');
Demodulation md=sbu.*cos(2*pi*fc*t); [b,a]=butter(2,0.1); mf=filter(b,a,md);
figure(3) plot(t,mf) title('Demodulated Signal'); xlabel('Time'); ylabel('Demodulated Signal'); figure(1); plot(t,m); title('Time Domain Representation of Orignal Signal'); xlabel('Time'); ylabel('Original Signal');
EXERSCISE 1. What is difference between Am with Large carrier and SSB SC communication.
2. Do both have same demodulation techniques.
Lab 13
Implement a modulation and demodulation of signal using frequency Modulation
Pre-Lab: Chapter #5 of B.P.Lathi
Soft ware Used:
MATLAB 2009b
Matlab code
Modulation
%fm=35HZ,fc=500HZ,Am=1V,Ac=1V,B=10
fs=10000;
Ac=1;
Am=1;
fm=35;
fc=500;
B=10;
t=(0:.1*fs)/fs;
wc=2*pi*fc;
wm=2*pi*fm;
m_t=Am*cos(wm*t);
subplot(3,1,1);
plot(t,m_t);
title('Modulating or Message signal(fm=35Hz)');
c_t=Ac*cos(wc*t);
subplot(3,1,2); plot(t,c_t);
title('Carrier signal(fm=500Hz)');
s_t=Ac*cos((wc*t)+B*sin(wm*t));
subplot(3,1,3);
plot(t,s_t);
title('Modulated signal');
Demodulation
d=demod(s_t,fm,fc,'fm'); Subplot(5,1,4); plot(t,d); title('demodulated signal')
EXERSCISE 1. What is difference between Am with Large carrier and FM communication.
2. Which is preferable for which type of application.
3. Define FM and draw its spectrum?
4. Define modulation index & its formula for FM?
5. Explain how FM wave is related to PM ?
6. Is FM Linear or nonlinear modulation? Why?
7. Draw the block diagram of FM?
Lab 14
Study the multiplexing and digital modulation techniques
Pre-Lab: Chapter #5 of B.P.Lathi
Soft ware Used:
MATLAB 2009b
Matlab code
FREQUENCY DIVISION MULTIPLEXING
Frequency division multiplexing is another type for multiplexing and is defined as “Frequency-division multiplexing (FDM) is a type of multiplexing in which numerous signals are combined for transmission on a single communications line or channel. Each signal is assigned a different frequency ( sub channel) within the main channel.” Frequency division multiplexing (FDM) is the process by which the total bandwidth available to the system is divided into a series of non overlapping frequency sub-bands that are then assigned to each communicating source and user pair. In the current milieu FDM has become obsolete as modern communication systems employ digital transmissions in which time division multiplexing is used. WORKING OF FDM
Frequency Division Multiplexing (FDM) works by transmitting all of the signals along the same high speed link simultaneously with each signal set at a different frequency. For FDM to work properly frequency overlap must be avoided. Therefore, the link must have sufficient bandwidth to be able to carry the wide range of frequencies required. The demultiplexor at the receiving end works by dividing the signals by tuning into the appropriate frequency.
FDM operates in a similar way to radio broadcasting where a number of different stations will broadcast simultaneously but on different frequencies. Listeners can then "tune" their radio so that it captures the frequency or station they want.
FDM gives a total bandwidth greater than the combined bandwidth of the signals to be transmitted. In order to prevent signal overlap there are strips of frequency that separate the signals. These are called guard bands.
Frequency division Multiplexing clc Fs = 100; % sampling frequency t = [0:2*Fs+1]'/Fs; x1 = sin(2*pi*2*t); % signal 1 signal z1 = fft(x1); z1=abs(z1); x2 = sin(2*pi*10*t); % signal 2 signal z2 = fft(x2); z2=abs(z2); figure; subplot(4,1,1); plot(x1); title('signal 1');xlabel('time');ylabel('amplitude'); subplot(4,1,2); plot(x2); title('signal 2');xlabel('time');ylabel('amplitude'); subplot(4,1,3); plot(z1); title('Spectrum of signal 1');xlabel('frequency');ylabel('magnitude'); subplot(4,1,4); plot(z2); title('Spectrum of signal 2');xlabel('frequency');ylabel('magnitude'); % frequency multiplexing z=z1+z2; figure; plot(z); title('frequency multiplexed signals'); figure;
Pulse Width Modulation close all clear all clc 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(311); plot(x1); axis([0 50 0 1]); title('original signal taken mesage,f1=500,fs=10000') subplot(312); plot(y1); axis([0 500 -0.2 1.2]); title('PWM')
EXERSCISE 1. Define PWM? 2. What do you infer from the frequency spectrum of a PWM signal? 3. What is other name for PWM? 4. What are the disadvantages of PWM? 5. Will PWM work if the synchronization between Tx and Rx fails?
Lab 15 & 16
Study the different digital modulation techniques
Pre-Lab: Chapter #6 of B.P.Lathi
Soft ware Used:
MATLAB 2009b
Matlab code
Pulse Amplitude Modulation
a = input('Enter the amplitude = ');
f = input('Enter the frequency = ');
t = 0:0.02:2; % for a total of 20 samples
x1 = stem(t); %generation of impulse signal
x2 = sin(2*pi*f*t); %generation of sine wave
y = x1.*x2; %modulation step
subplot(3,1,1); %for impulse signal plot
stem(x1);
title('Impulse Signal');
xlabel('Time');
ylabel('Amplitude ');
subplot(3,1,2) %for sine wave plot
plot(t,x2);
title('Sine Wave');
xlabel('Time ');
ylabel('Amplitude ');
subplot(3,1,3) %for PAM wave plot
stem(t,y);
title('PAM Wave');
xlabel('Time');
ylabel('Amplitude');
Delta Modulation t=[0:0.01:1]
m=sinc(2*pi*t)
subplot(211)
hold on
plot(m,'black')
title('sinc pulse')
xlabel('time')
ylabel('amplitude')
d=2*pi/100
for n=1:1:100
if n==1
e(n)=m(n)
eq(n)=d*sign(e(n))
mq(n)=eq(n)
else
e(n)=m(n)-mq(n-1)
eq(n)=d*sign(e(n))
mq(n)=mq(n-1)+eq(n)
end
end
stairs(mq,'red')
hleg=legend('original signal','stair case approximated signal')
hold off
subplot(212)
hold on
m1=sin(2*pi*t)
plot(m1,'blue')
title('sin wave')
xlabel('time')
ylabel('amplitude')
d=2*pi/100
for n=1:1:100
if n==1
e1(n)=m1(n)
eq1(n)=d*sign(e1(n))
mq1(n)=eq1(n)
else
e1(n)=m1(n)-mq1(n-1)
eq1(n)=d*sign(e1(n))
mq1(n)=mq1(n-1)+eq1(n)
end
end
stairs(mq1,'black')
hleg=legend('original signal','stair case approximated signal')
hold off
Pulse Code Modulation t=0:.01:3 a=sin(2*pi*t) p=square(2*pi*10*t) p(p<0)=0 s=a.*p figure(1) subplot(211) plot(a) xlabel('time') ylabel('amplitude') title('analog signal') subplot(212)
plot(s) xlabel('time') ylabel('amplitude') title('sampled signal') n=3 y=uencode(s,n,1) r=udecode(y,n,1) figure(2) subplot(211) plot(y) xlabel('time') ylabel('amplitude') title('encoded signal') subplot(212) plot(r) xlabel('time') ylabel('amplitude') title('decoded signal') figure(3) plot(p) xlabel('time') ylabel('amplitude') title('square signal')
Updates In Manual Experiments list is revised again with the consensus of mentors. In this manual contrary to last one we have included MATLAB coding and Simulink drills for students. Experiments on digital communication as per HEC contents are included. Required outcome of given assignment is also added for students to match their results with the required one. In each lab demo codes for student familiarization in each lab are added. During this update time span available for lab is taken into mind. Focus on graphical result in time domain and Frequency domain both are given.