0% found this document useful (0 votes)
31 views

Lab Manual DC

This lab manual covers digital communication experiments using MATLAB and Simulink. It includes 15 experiments on topics such as signal generation and analysis, sampling theory, line coding techniques, modulation schemes, and digital communication systems. The experiments are designed to help students learn key concepts in digital communication and get hands-on practice implementing systems and analyzing signals in MATLAB and Simulink. The manual provides objectives, descriptions, and step-by-step instructions for each experiment. It is intended for an undergraduate digital communication course and will equip students with practical skills in modeling and simulation of communication systems.

Uploaded by

Faizan Butt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Lab Manual DC

This lab manual covers digital communication experiments using MATLAB and Simulink. It includes 15 experiments on topics such as signal generation and analysis, sampling theory, line coding techniques, modulation schemes, and digital communication systems. The experiments are designed to help students learn key concepts in digital communication and get hands-on practice implementing systems and analyzing signals in MATLAB and Simulink. The manual provides objectives, descriptions, and step-by-step instructions for each experiment. It is intended for an undergraduate digital communication course and will equip students with practical skills in modeling and simulation of communication systems.

Uploaded by

Faizan Butt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Digital Communication

Lab Manual

Course Instructor:
Engr. Dr. Lubna Nadeem

Telecommunication Engineering Department


UET Taxila
List of Experiments Digital Communication

1. Introduction to MATLAB
2. Continuous time and discrete time signal Generation & plotting in Matlab.
3. Analysis of Power Signals and Energy Signals and Power Spectral Density.
4. Analysis and implementation of sampling theorem (Nyquist criteria, under
sampling, over sampling), impulse and natural sampling
5. Implementation of NRZ and RZ line codes
6. Implementation of phase encoded and Multi-level binary codes.
7. Introduction to Simulink
8. Implementation of Sampling, Aliasing and Signal Reconstruction,
Quantization Error Associated With Analog-To-Digital Conversion Using
Simulink

9. Familiarization with CT-3000.


10.To study the Sampling Theorem.
11.To study Pulse Time Modulations.
12.To study two channel TDM System.
13.To study the FSK Modulation.
14.To study the PSK and ASK Modulations.
15.To study PSK/ASK Demodulation.
16.To study PCM Encoder and PCM Decoder.
Lab # 1 to 8
Software based Labs Using
Matlab/ Simulink
University of Engineering and Technology, Taxila
Department of Telecom Engineering
Subject: Digital Communication Lab#01
Title:
Introduction to MATLAB

Objective:
The purpose of this Lab is to review MATLAB for those that have used it before, and to provide a brief
introduction to MATLAB for those that have not used it before. This is a "hands-on" introduction.
After using this lab session, students should be able to:
➢ Enter matrices
➢ Perform matrix operations
➢ Make plots
➢ Use MATLAB functions
➢ Write simple m-files
Description:
MATLAB is an interactive program for numerical computation and data visualization. It was
originally developed in FORTRAN as a MATrix LABoratory for solving numerical linear algebra
problems. The original application may seem boring (except to linear algebra enthusiasts), but
MATLAB has advanced to solve nonlinear problems and provide detailed graphics. It is easy to
use, yet very powerful. A few short commands can accomplish the same results that required a
major programming effort only a few years ago. MATLAB features a family of add-on application-
specific solutions called toolboxes. These 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 communications, signal processing, control systems, neural networks, fuzzy
logic, simulation, and many others.

The best way for you to get started with MATLAB is to learn how to handle matrices. Start
MATLAB and follow along with each example. You can enter matrices into MATLAB by entering
an explicit list of elements or generating matrices using built-in functions. You only have to follow
a few basic conventions: Separate the elements of a row with blanks or commas. Use a semicolon
“;” to indicate the end of each row. Surround the entire list of elements with square brackets “[
]”.

Consider the following vector, x (recall that a vector is simply a matrix with only one row or
column)

» x = [1,3,5,7,9,11]

x = 1 3 5 7 9 11

Notice that a row vector is the default. We could have used spaces as the delimiter between
columns

» x = [1 3 5 7 9 11]

x = 1 3 5 7 9 11

There is a faster way to enter matrices or vectors that have a linear pattern. For example, the
following command creates the previous vector

» x = 1:2:11 (here what does ‘2’ indicate? Will be discussed in proceeding lab sessions)

x = 1 3 5 7 9 11

Transposing a row vector yields a column vector ( 'is the transpose command in MATLAB)

» y = x'

y = 1 3 5 7 9 11

» save file_name

(Saving your variables does not remove them from your workspace; only clear can do that)
You can also save just a few of your variables

» save file_name x y z

To load a set of previously saved variables

» load file_name

Complex variables

Both i and j represent the imaginary number, √-1, by default

»i

ans = 0 + 1.0000i

»j

ans = 0 + 1.0000i

» sqrt(-3)

ans = 0 + 1.7321i

Note that these variables (i and j) can be redefined (as the index in a for loop, for example), not
included in your course. Matrices can be created where some of the elements are complex and
the others are real

» a = [sqrt(4), 1;sqrt(-4), -5]

Some Matrix Operations

a = 2.0000 1.00000

+ 2.0000i -5.0000

b = [1 2 3;4 5 6]

b=123456

using the a matrix that was generated above:

» c = a*b

For a standard solid line plot, simply type

» plot(x,z)

Axis labels are added by using the following commands

» xlabel('x')

» ylabel('z')

For more plotting options, type


» help plot

Consider now the following equation

y(t) = 4 e-0.1 t We can solve this for a vector of t values by two simple commands

» t = 0:1:50;

» y = 4*exp(-0.1*t); and we can obtain a plot by typing

» plot(t,y)

Signal’s representation

A signal in MATLAB is represented by a row vector:

Examples: ─

x = [2, 3, -5, -3, 1]

─ n = 2:17 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17]

Default step size is 1

─ n = 2:3:17 = [2, 5, 8, 11, 14, 17]

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.

Lab 01 (Tasks):
1. Consider the matrices A and B
𝟏 𝟐 𝟓 𝟔
𝑨=[ ] B= [ ]
𝟑 𝟒 𝟕 𝟖

Perform the following operations without using in-build functions


Addition:
A+B, B+A
Subtraction:
A-B, B-A
Miltiplication:
AxB, BxA
Inverse:
A-1, B-1
Transpose:
At,Bt
2. Plot the following functions in continuous and discrete domain
X1(t)=e-jwt
X2(t)=cos(wt)
University of Engineering and Technology, Taxila
Department of Telecom Engineering
Subject: Digital Communication Lab#02
Title:
Continuous time and discrete time signal Generation & plotting in Matlab.

Objective:
To learn plotting of signal in continuous and discrete domain. After this lab, student would be
able to plot the continuous time signal and discrete time signal.

Description:
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.
Lab 02 (Tasks):
1. Consider the matrix

v= 1 5

3 10

5 15

7 20

9 25

11 30

2. Write the command to access the first column of and to delete the second column of v
3. Plot the following signal x = 10sin π t for t = [-2:0.002:2]
4. Plot the DT sequences:
x = [2, 3, -1, 5, 4, 2, 3, 4, 6, 1]
5. Use Matlab to draw the graph of f (x) = x 2 − 2x − 3 on the interval [−1,3]
6. Generate following elementary DT signals: –
A. Unit Impulse
B. Unit Step
7. Plot the curves of sine function for five different phases and frequencies with different
colors. Also plot all these curves on single graph or figure.
University of Engineering and Technology, Taxila
Department of Telecom Engineering
Subject: Digital Communication Lab#03
Title:

Analysis of Power Signals and Energy Signals and Power Spectral Density.

Objective:

To find the power and energy of the signals. After this lab, student would be able to find the
power and energy of the signals and how to calculate power or energy of a signal using Matlab.
To plot the histogram, to find the PSD.

Description:

Power and Energy content of a signal is often calculated in signal processing for communication
applications. For any signal in discrete form, power and energy can be calculated using the
following equations
Lab 03 (Tasks):

Here T=duration of the signal, and x[n] denotes discrete samples of the signal at regular intervals
(The sampled signal contains N points stretching from 0 to N-1). “NORM” function in Matlab can
be utilized for calculating the power or energy content of a signal.

Task 01:

Find the energy of the following signal


X=2n -3<n<3

Task 02:

Find the power of the following signal


X=cos(200πt)+ cos(400πt) + cos(600πt) for t=0:0.001:10
University of Engineering and Technology, Taxila
Department of Telecom Engineering
Subject: Digital Communication Lab#04
Title:
Analysis and implementation of sampling theorem (Nyquist criteria, under sampling, over
sampling), impulse and natural sampling

Objective:
To learn sampling with Nyquist criteria and understand aliasing phenomenon. After completing
this lab student must have strong knowledge of sampling.

Description:
To sample a continuous-time signal x(t) is to represent x(t) at a discrete number of points, t =
nTs , where Ts is the sampling period. The sampling theorem states that a band-limited signal
x(t) with bandwidth W can be reconstructed from its sample values x[n] = x[ nTs] if the sampling
frequency fs =1/Ts is greater than twice the bandwidth W of x(t) . Otherwise, aliasing would
result in x(t) . The minimum sampling rate of 2W for an analog band-limited signal is called the
Nyquist rate. A CT sinusoid containing a maximum frequency of Fmax must be sampled at a
sampling rate Fs > 2Fmax (Nyquist Rate) to avoid aliasing. If sampling rate is greater than Nyquist
Rate, then CT sinusoid can be uniquely recovered from its DT version.
MATLAB Code:

%sampling
t=-10:0.01:10;
T=4;fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);plot(t,x,'linewidth',3);
xlabel('time');ylabel('amplitude');
grid;
title('input signal');
n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);stem(n1,x1,'linewidth',3);
xlabel('number of samples');ylabel('amplitude');
hold on;
subplot(2,2,2);plot(n1,x1,'linewidth',3);
xlabel('time');ylabel('amplitude');
grid;
title('under sampling');
n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);stem(n2,x2,'linewidth',3);
xlabel('number of samples');ylabel('amplitude');
hold on;
subplot(2,2,3);plot(n2,x2,'linewidth',3);
xlabel('time');ylabel('amplitude');
grid;
title('uniform sampling');
n3=-20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);stem(n3,x3,'linewidth',3);
hold on;
subplot(2,2,4);plot(n3,x3,'linewidth',3);
xlabel('number of samples');ylabel('amplitude');
xlabel('time');ylabel('amplitude');
grid;
title('over sampling');
Lab 04 (Tasks):
Task 1:

Take two sinusoidal signals of different frequencies

F1=1Hz

F2=3Hz

Using MATLAB, Plot the two signals for time range of -2sec to 2sec

Sample signal 1 at Fs=F1, 2F1 and 3F1

Sample signal 2 at Fs=F2, 2F2 and 4F2

Also analyze the effects of up sampling, down sampling and aliasing.

Implement the technique of impulse sampling

Task 2:

Take sinusoidal signal having frequency of 2Hz. Sample this sinusoidal signal at sampling
frequency of 10Hz using the technique of natural sampling. Write down the Matlab code to
implement natural sampling for the above signal. On the output there must be three graphs

a. First graph must show the sinusoidal signal having frequency of 2Hz for t:0→1
b. Second graph must show the carrier (rectangular signal) signal having frequency of
10Hz
c. Third graph must show the resultant natural sampled signal
University of Engineering and Technology, Taxila
Department of Telecom Engineering
Subject: Digital Communication Lab#05
Title:

Implementation of NRZ and RZ line codes

Objective:
To learn how to implement following NRZ line codes:

1. NRZ-L
2. NRZ-M
3. NRZ-S

To learn how to implement following RZ line codes:

1. Unipolar RZ
2. Bipolar RZ
3. RZ AMI

Description:
Non-return to zero encoding is commonly used in slow speed communications interfaces for both
synchronous and asynchronous transmission. Using NRZ, a logic 1 bit is sent as a high value and
a logic 0 bit is sent as a low value (the line driver chip used to connect the cable may subsequently
invert these signals).

NRZ-L: 1 is represented by positive and 0 by negative level

NRZ-M: 1 is represented change in level by no change in level.

NRZ-S:1 is represented by no change in level 0 by change in previous level.

Return-to-zero (RZ or RTZ) describes a line code used in telecommunications signals in which
the signal drops (returns) to zero between each pulse. This takes place even if a number of
consecutive 0s or 1s occur in the signal. The signal is self-clocking. This means that a separate
clock does not need to be sent alongside the signal, but suffers from using twice the bandwidth to
achieve the same data-rate as compared to non-return-to-zero format.

Unipolar RZ: 1 is represented by half duration pulse 0 zero level (absence of pulse)

Bipolar RZ: 1 is represented by half duration positive pulse .0 by half duration negative pulse
RZ AMI: 1 is represented by alternate positive and negative half duration pulses 0 by 0 level
(absence of pulse).
Lab 05 (Tasks):
Task 1:

Write code for NRZ-L, NRZ-M, NRZ-S

Task 2:

Write code for Unipolar RZ, Bipolar RZ, RZ AMI


University of Engineering and Technology, Taxila
Department of Telecom Engineering
Subject: Digital Communication Lab#06
Title:

Implementation of phase encoded and Multi-level binary codes.

Objective:
To learn how to implement following phase encoded line codes:

1. Bi-Phi-L
2. Bi-Phi-M
3. Bi-Phi-S

To learn how to implement following RZ line codes:

1. Dicode NRZ
2. Dicode RZ

Description:
Biphase encoding is a variation on polar encoding and is an effective answer to synhronisation
problems. Biphase encoding works by changing the signal in the middle of the bit interval,
however, the signal does not then return to zero it continues to the opposite pole. This mid-interval
change is perfect for synchronisation purposes.

1. Bi-Phi-L: Two consecutive bits of the same type force a transition at the beginning of a
bit period.
1 forces a negative transition in the middle of the bit
0 forces a positive transition in the middle of the bit

2. Bi-Phi-M: Variant of Differential Manchester. There is always a transition halfway


between the conditioned transitions.
1 forces a transition
0 keeps level constant

3. Bi-Phi-S: Differential Manchester used in Token Ring. There is always a transition


halfway between the conditioned transitions.
1 keeps level constant
0 forces a transition
The desire to increase the data speed or decrease the required bandwidth has resulted in the creation
of many schemes. The goal is to increase the number of bits per baud by encoding a pattern of m
data elements into a pattern of n signal elements. We only have two types of data elements (Os
and 1s), which means that a group of m data elements can produce a combination of 2m data
patterns.
1: Dicode NRZ: change in data represents change in polarity 0 otherwise.
2: Dicode RZ: Change in level represents half duration pulse with change in polarity 0
otherwise.
Lab # 06 (Tasks)
Task 1:

Write code for Bi-Phi-L, Bi-Phi-M, Bi-Phi-S

Task 2:

Write code for Dicode NRZ, Dicode RZ


University of Engineering and Technology, Taxila
Department of Telecom Engineering
Subject: Digital Communication
Lab#07
Title:

Introduction to Simulink

Lab#08
Title:

Implementation of Sampling, Aliasing and Signal Reconstruction, Quantization


Error Associated With Analog-To-Digital Conversion Using Simulink

Objective:

• To examine signal sampling, aliasing and signal reconstruction.


• To investigate the quantization error associated with analog-to-digital conversion.

Equipment List:
Pc with Matlab and Simulink.

Description:
Sampling

The time division Multiplexer (TDM MUX) module is used to recombine two analog signals
into one data stream. The input A is connected to the OUT connector for a period T (T = 1/fs).
During the next period, input B is connected to the OUT connector. The process then repeats.
It should be obvious that each input, input A (or B) is “Sampled” at a rate equal to ½ fs as set
by the Master clock.

NOTE: The actual waveform sampling rate = ½ fs as set by the “DATA/Sampling RATE”, output,
mentioned above (e.g. to sample a 1kHz cosine, using this equipment at the Nyquist rate then
fs would have to be set to 4 kHz)
Next the fs were set to 10 kHz and the function generator frequency was set to 1 kHz. The
output signal OUT was observed on a scope and was also compared with the input on a dual
channel scope. The value of fs was slightly adjusted for a stable display. The scope was moved
to the sample-and-hold (S & H) output. We see that the amplitude variations during the
sampled period are now replaced with a constant “flat top”.

Figure: Sampling using Sample and Hold

The input signal looks like the one shown in figure below

Figure: input of the sampling using sample and hold method


Figure: Output of the Sample and hold circuit

The result when the input is overlapped with the output is what is shown below.

Next the function generator was connected to both the inputs A and B. at the OUT connector of the
TDM MUX, the generator’s signal appears undistorted. We see that after moving the scope to the S &
H connector the signal is now being sampled at fs.
Figure: Time Division Multiplexing - Implementation

Time division Multiplexing – Input signal

Figure: Time division Multiplexing, Output


The output spectrum of the S & H output is observed. Values of f and fs are varied
and the effects of aliasing observed.
Effect of filtering: The sampled signal was reconstructed by feeding through a 4th
order LPF to remove the aliasing frequencies.

A. Although multiplexing not classified as “data acquisition,” we shall make use of TDM
modules at this time. Two sine waves were prepared to be multiplexed by setting the
two VCO’s in open loop to 1 kHz and 2 kHz. Connect the 1 kHz sine wave to the A input
and 2 kHz since wave to the B input (see figure 7c). Set fs for 10kHz. The output OUT
and S & H outputs in time and frequency domain were observed. Yes, we can say that
sampling frequency for the TDM system is fs/2. (i.e half the time you sample A and
half the time you sample B)

B. The S & H signal was connected to the TDM DEMUX. Internal timing connects the TDM
DEMUX input signal to the A output when the A input signal is selected by the MUX.
Similarly, the B output is connected to the DEMUX input when the MUX selects input B.
Thus, the TDM signal becomes “demultiplexed”. The Dual LPF was used to reconstruct the
S & H DEMUX output waveforms. All the waveforms observed are attached.

Figure: Output of Signal 1 of TDM


Figure: Implementation of 2 signal TDM

Figure: Output of the two signal TDM

III A/D conversion


A. Now the conversion of analog to digital pulse is considered. This conversion is
part of the pulse code modulation (PCM) system.
B. There is an inherent noise component in the system due to the quantization of
the signal in the PCM encoding and decoding. This noise is the error between the
actual value of the analog input and the decoded analog signal from the PCM-
ANALOG module. If we were to subtract the resulting quantified signal from the
original signal, a noise voltage would result. This could then be used to form a
quantization signal-to-noise power ratio.
Figure: The pulse code modulation with variable quantization

Figure: Input signal


The quantized signal is given below

Figure: Quantized signal


The input file is quantified using the PCM encode and de-quantified using the PCM decode block.
The block parameters are shown below:

Figure: Quantizer parameters

Figure: DE- Quantizer parameters

The output of the decoder is fed to a subtractor block, which takes the difference of the input signal
from the output and gives the signal noise generated. The noise generated and the numeric value is:
Figure: Difference – Noise of the PCM

The output of the de-quantized block is further filtered.

Figure: Quantization recovered value


The output as compared to the input looks somewhat like below

Figure: Input and Output compared


Lab # 9 to 16
Hardware based Labs Using
Communication Trainer
CT-3000
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#09
Title:

Familiarization with CT-3000.


• Measurement of AF, RF and Clock
• Base Unit socket understanding
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#10
Title:

To study the Sampling Theorem.


• Data generator NRZ data pattern
• 4 phase clock 0°, 90°, 180° and 270°
• Sampling and sample and Hold signals
• Signal recovery after sampling
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#11
Title:

To study Pulse Time Modulations.


• Pulse Width Modulation
• Sample and Hold waveform
• SAW Tooth waveform generation by Integration
• Comparator
Pulse Position Modulation
• Differentiator
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#12
Title:

To study two channel TDM System.


➢ Time Division Multiplexing
• Two Channel TDM
• Measurement of clock phases 0° and 180°
➢ Time Division Demultiplexing
• 500Hz/1KHz Audio signal effect
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#13
Title:

To study the FSK Modulation.


➢ XR2206 FSK Modulator
• Frequency measurement for mark and space
➢ XR2211 FSK Demodulator
• Mean frequency adjustment
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#14
Title:

To study the PSK and ASK Modulations.

• PSK Modulator
• ASK Modulator
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#15
Title:

To study PSK/ASK Demodulation.

➢ PSK/ASK Demodulation by using balance modulator


• Synchronous Detection
• Demodulation of four different NRZ data patterns
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#16 (a)
Title:

To study PCM Encoder.

➢ PCM Encoder
• Analog to Digital Convertor
• Bit Encoder
• Parallel to serial converter
University of Engineering and Technology, Taxila
Department of Telecom Engineering

Subject: Digital Communication

Lab#16 (b)
Title:

To Study PCM Decoder

➢ PCM Decoder
• Serial to parallel converter
• Digital to Analog Converter

You might also like