Академический Документы
Профессиональный Документы
Культура Документы
LAB CONTENTS
10
SSUET/QR/114
Digital Communications (TE331) Lab Manual
11
12
13
14
1
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
LABORATORY EXERCISE 1
OBJECTIVE
THEORY
The matrix data type includes vectors, for the case when either of the number of rows or the number
of column equals to 1; and it includes scalars when both the number of rows and columns equal 1.
Furthermore, matrices can be either real-valued or complex valued, which is the most general case.
HELPWIN is used in the same manner as help, but it opens a separate window with advance
search facilities and links to related topics.
HELPDESK uses a window of an installed web browser to display the help texts.
If the name of a command is not exactly known, the LOOKFOR function helps by seeking
through the first comment line of all available functions and listing all functions where a
desired expression is found.
2
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
Variable names:
Must start with a letter
May contain only letters, digits, and the underscore _
Matlab is case sensitive, i.e. one & OnE are different variables.
Matlab only recognizes the first 31 characters in a variable name.
1.2.1 Workspace:
The contents of all the variables are stored in the MATLAB workspace. This is the memory region
allocated for variable(s).
The command WHO lists all variable which currently exist in the workspace.
WHOS additionally lists the size and amount of allocated memory along with the variable
names
The entire workspace or single variable can be cleared by using the CLEAR command or by clc
command.
3
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
matrices where the imaginary parts of all matrix elements are zero. The following essentials must be
known to deal with complex-valued matrices:
The variables i and j are assigned, by default, the value i -1 . This is used to define
the complex values. For example,
5 j *10
generates a complex-valued variable.
The real part of a complex-valued matrix can be extracted by using the function REAL and
imaginary part can be extracted by using the function IMAG. Both functions deliver the real-
valued matrices as outputs.
The special character generates the complex conjugate transpose of a matrix, the hermitian
matrix. This character is written after an expression or variable.
For example, the hermitian of a matrix A can be obtained through:
A
1.4 Elementary operations on Matrices:
MATLAB contains a number of arithmetic, relational, and logical operations on matrices.
Algebraic expressions can be formed by the following basic operations:
Transpose of a vector/matrix can be produced by: .
For example: B.
+ is used to add two vectors/matrices of identical size, or a vector/matrix and a scalar. For
example:
[1 2;3 4] + [5 6;7 8]
- subtracts two vectors/matrices of identical size, or a vector/matrix and a scalar. For example:
2B
Parts of matrices can be extracted by subscripting these elements, using braces () to specify the
4
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
subscripted elements. MATLAB distinguishes three methods of subscription, here explained for the
example of a matrix B
1.6 M-files:
MATLAB can execute a sequence of statements stored in a file. Such files are called M-files because
they have .m extension as the last part of their file name.
There are two types of M-types:
Script files
Function files
5
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
LAB Task:
Task1:
Try all help methods to get help for any MATLAB Command.
Task2:
Generate a Row Vector A with values from 0 to 9.
Task 3:
Assign a 3x3 Matrix to B by using Magic command.
Task 4:
Assign a 3x3 Matrix to C without printing its output on Screen.
Task 5:
Check what variables you currently have e in workspace. Clear variable C.
Task 6:
Investigate the difference between Matrix Multiplication and Element-wise Multiplication.
Task7:
Explore and use the following Command with suitable example. Ones, Zeros, and eye.
Task 8:
Generate a Matrix C through magic command of size 3then extracts:
i. Elements of 3rd row and 1st column
ii. All elements of 2nd column
iii. All elements of 3rd row
iv. 1st and 2nd elements of column 2
v. 1st and 3rd elements of 2nd and 3rd column
Task 9:
Explore and use the following Command with suitable example. Real, Imag, and Conj.
Task 10:
Generate a complex valued matrix z=ones(1,5)+i(1:5) and calculate the absolute square of each
element.
Task 11:
Explore and use the following Command with suitable example. Plot, semilogy, stem and subplot.
Task 12:
Explain the difference between Script and function file.
6
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
LABORATORY EXERCISE 2
OBJECTIVE
To familiarized with different Types of Pulse Modulation schemes (PAM, PPM and PWM). Write
MATLAB programs to simulate the modulation process for all types.
THEORY
2. Pulse Modulation:
The process of transmitting signals in the form of pulses (discontinuous signals) by using special
techniques is known as Pulse Modulation. It consists essentially of sampling analog information signals
and then converting those samples into discrete pulses and transporting the pulses from a source to a
destination over a physical transmission medium.
PAM is a modulation scheme where the message is encoded in the amplitude of a series of amplitude
pulses. Its an analog modulation scheme in which the amplitudes of a train of carrier pulses are varied
according to the amplitude of message signal. In the pulse amplitude modulation, the message signal is
sampled at regular periodic or time intervals and this each sample is made proportional to the magnitude
of the message signal. These sample pulses can be transmitted directly using wired media or we can use
a carrier signal for transmitting through wireless.
Example: A two-bit modulator (PAM-4) will take two bits at a time and will map the signal amplitude
to one of four possible levels, for example 3 volts, 1 volt, 1 volt, and 3 volts. There are two types of
sampling techniques for transmitting messages using pulse amplitude modulation, they are
7
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
It is a type of analog modulation. In pulse width modulation or pulse duration modulation, the width of
the pulse carrier is varied in accordance with the sample values of message signal or modulating signal
or modulating voltage. In pulse width modulation, the amplitude is made constant. We can vary the
pulse width in three ways
By keeping the leading-edge constant and vary the pulse width with respect to leading edge
By keeping the tailing constant.
By keeping the center of the pulse constant.
In the pulse position modulation, the position of each pulse in a signal by taking the reference signal is
varied according to the sample value of message or modulating signal instantaneously. In the pulse
position modulation, width and amplitude is kept constant.
8
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
Lab Exercise:
Construct a time array from 0 to (2/fm-1/fs) sec with 1/fs intervals. Name it t.
Find the size of the array t. Use length function. Name the size n.
Construct signal array x. Signal is a sinewave with 0.4 amplitude, 0.5 phase shift and 200
angular frequency.
Take carrier frequency 1000 and sampling frequency 10000.
Use MATLAB modulate command to modulate the signal and carrier for PPM.
Show the output with proper labelled diagrams through subplot command.
Task4:
Task5:
Generate square wave, rectangular pulse and sawtooth waveform without using MATLAB built-in
commands.
9
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
LABORATORY EXERCISE 3
OBJECTIVE
To familiarized with Pulse Code Modulation. Write MATLAB code to understand the fundamentals of
PCM
THEORY
Pulse code modulation is a method that is used to convert an analog signal into a digital signal, so that
modified analog signal can be transmitted through the digital communication network. PCM is in binary
form, so there will be only two possible states high and low (0 and 1). We can also get back our analog
signal by demodulation. The Pulse Code Modulation process is done in three steps Sampling,
Quantization, and Coding. Using PCM, it is possible to digitize all forms of analog data, including full-
motion video, voices, music, telemetry, and virtual reality (VR).
In sampling, we are using PAM sampler that is Pulse Amplitude Modulation Sampler which converts
continuous amplitude signal into Discrete-time- continuous signal (PAM pulses). Basic block diagram
of PCM is given below for better understanding.
3.1. Sampling
10
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
Sampling frequency, Fs is the number of average samples per second also known as Sampling rate.
According to the Nyquist Theorem sampling rate should be at least 2 times the upper cutoff frequency.
Sampling frequency, Fs>=2*fmax to avoid Aliasing Effect. If the sampling frequency is very higher
than the Nyquist rate it become Oversampling, theoretically a bandwidth limited signal can be
reconstructed if sampled at above the Nyquist rate. If the sampling frequency is less than the Nyquist
rate it will become Under sampling. Basically, two types of techniques are used for the sampling
process. Those are 1. Natural Sampling and 2. Flat- top Sampling.
3.2. Quantization
In quantization, an analog sample with an amplitude that converted into a digital sample with an
amplitude that takes one of a specific defined set of quantization values. Quantization is done by
dividing the range of possible values of the analog samples into some different levels, and assigning the
center value of each level to any sample in quantization interval. Quantization approximates the analog
sample values with the nearest quantization values. So almost all the quantized samples will differ from
the original samples by a small amount. That amount is called as quantization error. The result of this
quantization error is we will hear hissing noise when play a random signal. Converting analog samples
into binary numbers that is 0 and 1.
In most of the cases we will use uniform quantizers. Uniform quantization is applicable when the sample
values are in a finite range (Fmin, Fmax). The total data range is divided into 2n levels, let it be L
intervals. They will have an equal length Q. Q is known as Quantization interval or quantization step
size. In uniform quantization, there will be no quantization error.
11
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
3.3. Encoding
The encoder does the digitization of analog signal. It designates each quantized level by a binary code.
The sampling done here is the sample-and-hold process. Encoding is the process of representing the
sampled values as a binary number in the range 0 to n. The value of n is chosen as a power of 2,
depending on the accuracy required. Increasing n reduces the step size between adjacent quantization
levels and hence reduces the quantization noise. The down side of this is that the amount of digital data
required to represent the analogue signal increases.
12
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
Lab Exercise:
Task1: Generate cosine wave with unit amplitude and 110 Hz frequency. Perform sampling of
generated signal with following:
o Nyquist rate
o Fs>2fm
o Fs<2fm
Take t=0:0.0005:0.2. Plot analog signal along with its sampled output and explain your observation for
above three conditions.
Task2: Generate cosine wave with unit amplitude and 110 Hz frequency. Perform sampling and
quantization of generated signal with following Matlab commands:
o Round
o Ceil
o floor
Plot analog signal, sampled output and quantized output. Explain results.
Task3:
By taking number of digits after decimal to be retained from user repeat task 2. Plot analog signal,
sampled output and quantized output. Explain results.
( 10())
=
10()
Task4:
write a program to quantize the signal x(n)=cos(2*pi*f*t) using truncation to 64,128,256 quantization
levels. In each case plot x(n), Xq(n) and Xe(n) and compute corresponding SQNR.
= cos(2 )
log( 1)
=
2
q=digits to be retained
N=sub Intervals
( 10^())
=
10^()
= 10log( )
13
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
LABORATORY EXERCISE 4
OBJECTIVE
THEORY
4. Baseband Transmission:
4.1. Waveform Representation of Binary Digits (Line Coding)
We have studied in lab 4 that how analog waveforms are transformed into binary digits via the use of
PCM. There is nothing "physical" about the digits resulting from this PCM process. Digits are just
abstractions- a way to describe the message information. Thus, we need something physical that will
represent or "carry" the digits. We will represent the binary digits with electrical pulses to transmit them
through a baseband channel. Thus, a sequence of electrical pulses having some can be used to transmit
the information in the PCM bit stream, and the process is known as line coding.
When pulse modulation is applied to a binary symbol, the resulting binary waveform is called a pulse-
code modulation (PCM) waveform. There are several types of PCM waveforms that are described
below, in telephony applications, these waveforms are often called line codes. When pulse modulation
is applied to a nonbinary symbol, the resulting waveform is called an M-ary pulse-modulation
waveform. The PCM waveforms fall into the following four groups.
1. Nonreturn-to-zero (NRZ)
2. Return-to-zero (RZ)
3. Phase encoded
4. Multilevel binary
The NRZ group is probably the most commonly used PCM waveform. It can be partitioned into the
following subgroups:
4.2.1.1. NRZ-L
NRZ-L is used extensively in digital logic circuits. A binary one is represented by one voltage level and
a binary zero is represented by another voltage level. There is a change in level whenever the data
change from a one to a zero or from a zero to a one.
4.2.1.2. NRZ-M
With NRZ-M, the one, or mark, is represented by a change in level, and the zero, or space, is represented
by no change in level. This is often referred to as differential encoding. NRZ-M is used primarily in
magnetic tape recording.
14
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
4.2.1.3. NRZ-S
NRZ-S is the complement of NRZ-M: A one is represented by no change in level, and a zero is
represented by a change in level.
The RZ waveforms consist of unipolar-RZ, bipolar-RZ. and RZ-AMI. These codes find application in
baseband data transmission and in magnetic recording. With unipolar-RZ, a one is represented by a
half-bit-wide pulse, and a zero is represented by the absence of a pulse. With bipolar-RZ, the ones and
zeros are represented by opposite-level pulses that are one-half bit wide. There is a pulse present in each
bit interval. RZ-AMI (AMI for "alternate mark inversion") is a signaling scheme used in telephone
systems. The ones are represented by equal-amplitude alternating pulses. The zeros are represented by
the absence of pulses.
15
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
Lab Exercise:
Task1:
Generate Message signal (Binary Data that was output of PCM) by creating a Function [q]=bitgen(m,n)
which generates a matrix A of size m,n with random values with equal probabilities. Use the MATLAB
function RAND, which generates uniformly distributed pseudo random numbers.
Task2:
Task3:
Write a function [xL]=bit2sym(q,A), Which converts a vector of bits, Q, into a vector X of transmit
symbols, according to the binary transmit symbol alphabet specified by the 2-element vector A = [a0;
a1] by using NRZ-L Line coding scheme. (Hint: Take A= [-1 1] for NRZ-L Scheme and q is the output
of task1).
Task4:
Write a function [xM]=bit2sym(q,A), Which converts a vector of bits, Q, into a vector X of transmit
symbols, according to the binary transmit symbol alphabet specified by the 2-element vector A = [a0;
a1] by using NRZ-M Line coding scheme. (Hint: Take A= [-1 1] for NRZ-M Scheme and q is the output
of task1).
Task5:
Write a function [xS]=bit2sym(q,A), Which converts a vector of bits, Q, into a vector X of transmit
symbols, according to the binary transmit symbol alphabet specified by the 2-element vector A = [a0;
a1] by using NRZ-S Line coding scheme. (Hint: Take A= [-1 1] for NRZ-S Scheme and q is the output
of task1).
16
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
LABORATORY EXERCISE 5
OBJECTIVE
To find the effect of channel impaiments and Implementation of complex valued Gaussian Noise on
Transmitted signal.
THEORY
5. Channel Impairments:
In the case of baseband signaling, the received waveforms are already in a pulse like form. One might
ask, why the n, is a demodulator needed to recover the pulse waveforms? The answer is that the arriving
baseband pulses are not in the form of ideal pulse shapes hence There are two primary causes for error-
performance degradation. The first is the effect of filtering at the transmitter, channel, and receiver.
Another cause for error-performance degradation is electrical noise and interference produced by a
variety of sources, such as galaxy and atmospheric noise, switching transients, intermodulation noise,
as well as interfering signals from other sources.
With proper precautions, much of the noise and interference entering a receiver can be reduced in
intensity or even eliminated. However, there is one noise source that cannot be eliminated, and that is
the noise caused by the thermal motion of electrons in any conducting media. This motion produces
thermal noise in amplifiers and circuits, and corrupts the signal in an additive fashion. The primary
statistical characteristic of thermal noise is that the noise amplitudes are distributed according to a
normal or Gaussian distribution,
17
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
LAB EXERCISES:
Task1:
Use MATLAB command conv to find the effect of channel on transmitted information by performing
convolution of input signal with ideal channel impulse response.
Write a function [v]=chanres(x,h) where x is the transmitted symbols and h is the channel response.
Plot the output signal using STEM command.
Task2:
Display all signals using the STEM function. Which part of the output signal must be out to obtain a
time alignment of input and output signals?
Task3:
Real-valued Gaussian noise can be produced using the built-in MATLAB function RANDN. This
produces pseudo-random numbers following a zero-mean Gaussian distribution with variance 1.
Task4:
Generate Received signal by adding noise into signal coming from the channel (v). Test the function by
producing a SCATDIAG plot of transmitted and received symbols.
18
DIGITAL COMMUNICATION (TE-331) SSUET/QR/114
19