Nothing Special   »   [go: up one dir, main page]

Lab 09

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

EEE-351 Principles of Communication Systems

Lab Report-09

Student Name ABBAS MEHDI


FATIMA BATOOL

FA21-BEE-001
FA21-BEE-049
Registration Number
BEE-5B

Class/Section
Sir Khan Afsar
Instructor’s Name

Lab Assessment Marks

In Lab /4
/10
Presentation /2
Post-Lab Analysis /2 /6
Writing /2
Lab # 9. Generation of PCM Line codes and analyzing
their Power Spectral Density using MATLAB

OBJECTIVES:
The students will be able to develop an understanding of what line codes are and why they are used.
They will be taught about the power spectral densities and will be able to develop codes regarding
different PCM line codes.

PRE_LAB:
Power Spectral Density:
Power Spectral Density (PSD) of a random process is defined as the Fourier transform of its
autocorrelation function. The area under a given frequency band of the PSD function gives the
amount of average power contained in that frequency band which makes PSD a very strong tool for
the analysis of random processes. The PSD of an Ergodic random process can be expressed in terms
of the Fourier transform of one of its sample function. Let X(t) be an ergodic random process, let
x(t,T) be one of its sample function which is observed in the interval [0,T]. Let X(f,T) be the Fourier
transform of x(t,T). Then the periodogram of x(t,T)
1
is defined as | X(𝑓𝑓, 𝑇)|2 . The PSD of X(t) can be expressed as
2𝑇

𝑆𝑋𝑋 (𝑓𝑓)
1
= lim 𝑇 → 𝑎𝑎𝑛𝑓𝑓𝑎𝑎𝑛𝑎𝑎𝑡𝑦 𝐸 [ |X(𝑓𝑓, 𝑇)|2 ]
2𝑇
Hence average of periodograms can be used to approximate the PSD of a random process.

PWELCH Function:
The pwelch function in MATLAB is used to approximate the PSD of a signal. The function divides
the input signal into overlapping segments and then computes their respective periodograms and
then finds the average, hence the output is an approximation of the PSD of the input signal. The
syntax of the pwelch function is

[pxx,f ] = pwelch(input_signal,window_size,overlap_size,FFTsize,sampling_freq).

Where pxx is the approximated PSD and f in the frequency vector against which PSD can be
plotted. A possible usage of pwelch maybe

[pxx,f] = pwelch(x,33,[ ],[ ],fs). The empty matrix is used so that pwelch may use its default values
for overlap and fft size and 33 specifies the length of the segment.

PCM Line Codes


There are different types of PCM line codes available for transmission of digitized data. Each line
code has its own advantages and disadvantages which make it suitable for some specific application.
In this lab we will generate five different line codes.

Polar NRZ:
In polar NRZ a ‘1’ is represented by a pulse of ‘+V volts’ and a ‘0’ is represented by a pulse of ‘-V volts’.

Unipolar NRZ:
In unipolar RZ a ‘1’ is represented by a pulse of ‘+V volts’ whereas a ‘0’ is represented by a pulse of ‘0 volts’.

Unipolar RZ:
In unipolar RZ a ‘1’ is represented by a pulse of ‘+V volts’ for half the bit duration and ‘0 volts’
for the rest of bit duration. A 0 is represented by ‘0 volts’ for complete bit duration.

Manchester Code:
In this type of coding a ‘1’ is represented by a pulse of ‘+V volts’ for first half of bit duration and
‘-V volts’ for the other half. A ‘0’ is represented by a pulse of ‘-V volts’ and ‘+V volts’ for the other
half.
Delay Modulation:
In delay modulation a ‘1’ is represented by a transition at the mid point of the bit duration whereas
a ‘0’ is represented by no transition unless it is followed by another ‘0’, in that case a transition is
placed at the end of bit interval of the first zero.

LAB TASK:
TASK A:
1. Define a random data of some length >100 containing 1s and 0s. Also define a test data [1 0 1
1 00 0 1 1 0 1].
2. Define a pulse duration say 1msec and a high sampling time to approximate analog signals
say0.1msec.
3. Convert the random data and test data into the line codes defined above.
4. Plot these line codes for the test data. Verify your implementation.
clc
clear all
t = 0:1e-4:1.1;
t1 = 0:1e-4:0.11;
sig = zeros(1,length(t));
sig1 = zeros(1,length(t1));
bit = ones(1,100);
N = 100;
D = rand(1,N);
r =0.5;
test = [1 0 1 1 0 0 0 1 1 0 1];
for y = 1:N
if (D(y)>r)
D(y)=1;
elseif(D(y)<r)
D(y)=0;
end
end
for i=1:N
if D(i)==1
sig(1,i*100-99:i*100)=bit;
end
end
plot(t,sig,'linewidth',1)
title('pulse')
xlabel('ms')
grid on;

Lab 04 2
for i=1:length(test)
if D(i)==1
sig1(1,i*100-99:i*100)=bit;
else
sig1(1,i*100-99:i*100)=bit2;
end
end
figure(2)
plot(t1,sig1,'linewidth',1)
title('polar NRZ')
grid on;

Lab 04 3
for i=1:length(test)
if D(i)==1
sig1(1,i*100-99:i*100)=bit;
end
end
figure(2)
plot(t1,sig1,'linewidth',1)
title('unipolar NRZ')
grid on;

Lab 04 4
for i=1:length(test)
if D(i)==1
sig1(1,i*100-99:(i*100)-50)=bit;
end
end
figure(2)
plot(t1,sig1,'linewidth',1)
title('unipolar RZ')
grid on;

Lab 04 5
1.
2.
3. for i=1:length(test)
4. if D(i)==1
5. sig1(1,i*100-99:i*100)=bit;
6. end
7. end
8. figure(2)
9. plot(t1,sig1,'linewidth',1)
10. title('Manchester')
11. grid on;

Lab 04 6
POST LAB
Use Pwelch function with a window size say 30 to approximate the PSDs of different line codes.
Comment on there bandwidth efficiencies.
Answer:
Use Pwelch function with different window sizes from 10 to 50 and comment on the accuracy
of the output as compared to the theoretical results.
Conclusion:
In this lab, we'll delve into the concept of line codes and explore the reasons behind their usage. You'll gain an
understanding of power spectral densities and learn how to create various Pulse Code Modulation (PCM) line
codes. Put simply, we're going to explore how signals are represented through codes and why these codes are
important in communication systems. By the end of the lab, you'll be equipped to design different PCM line codes
to effectively transmit information.

Lab 04 7
Lab 04 8

You might also like