Lab 09 PCS FA23

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

EEE351-Principles of Communication Systems

Lab Report-09

Name Abdul Wahab


Faiq Jhanzaib

FA20-BEE-010
Registration Number FA20-BEE-048

Class/Section BEE-5B

Instructor’s Name Sir Khan Afsar

Lab Assessment Marks

Ability to use software /1

Follow procedures /1
In Lab
Troubleshoot software /1 /4

Q&A /1

Presentation /2

Post-Lab Analysis /2 /6

Writing /2
LAB 09: 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.

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
1
transform of x(t,T). Then the periodogram of x(t,T) is defined as | 𝑋𝑋(𝑓𝑓, 𝑇𝑇)|2. The PSD of X(t) can
2𝑇𝑇

be expressed as
1
𝑆𝑆𝑋𝑋 (𝑓𝑓) = lim 𝑇𝑇 → 𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 𝐸𝐸 [ |𝑋𝑋(𝑓𝑓, 𝑇𝑇)|2 ] (9.1)
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.

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 0 0 0 1 1 0 1].
2. Define a pulse duration say 1msec and a high sampling time to approximate analog signals say
0.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.

Unipolar NRZ :
ts = 0.001;
t = 0:ts:0.05;
x = rand(1,101);
x1 = round(x);
subplot(3,1,1)
plot(x1)
title('Random Data')
y = [1 0 1 1 0 0 0 1 1 0 1]
subplot(3,1,2)
stairs(y)
x2=ones(1,length(t))
x3=zeros(1,length(t))
z=[];
for i=1:length(y);
if y(i)==1
z=[z x2]
else
z=[z x3]
end
end
t2=linspace(0,(0.001.*length(y)),length(z))
subplot(3,1,3)
xlabel('Time')
ylabel('Amplitude')
plot(t2,z,'linewidth',3)
title('UniPolar NRZ')
Bipolar NRZ :
ts = 0.001;
t = 0:ts:0.05;
x = rand(1,101);
x1 = round(x);
subplot(3,1,1)
plot(x1)
title('Random Data')
y = [1 0 1 1 0 0 0 1 1 0 1]
subplot(3,1,2)
stairs(y)
x2=ones(1,length(t))
x3=-ones(1,length(t))
z=[];
for i=1:length(y);
if y(i)==1
z=[z x2]
else
z=[z x3]
end
end
t2=linspace(0,(0.001.*length(y)),length(z))
subplot(3,1,3)
xlabel('Time')
ylabel('Amplitude')
plot(t2,z,'linewidth',3)
title('Bi-Polar NRZ')
Polar RZ :
ts = 0.001;
t = 0:ts:0.05;
x = rand(1,101);
x1 = round(x);
subplot(3,1,1)
plot(x1)
title('Random Data')
y = [1 0 1 1 0 0 0 1 1 0 1]
subplot(3,1,2)
stairs(y)
x2=ones(length(t))/2
x3=zeros(length(t))/2
x4=zeros(length(t))
x5=[x2 x3]
z=[];
for i=1:length(y);
if y(i)==1
z=[z x5]
else
z=[z x4]
end
end
t2=linspace(0,(0.001.*length(y)/2),length(z))
subplot(3,1,3)
xlabel('Time')
ylabel('Amplitude')
plot(t2,z,'linewidth',3)
title('Polar RZ')

Manchester RZ:
ts = 0.001;
t = 0:ts:0.05;
x = rand(1,101);
x1 = round(x);
subplot(3,1,1)
plot(x1)
title('Random Data')
y = [1 0 1 1 0 0 0 1 1 0 1]
subplot(3,1,2)
stairs(y)
x2=ones(length(t))
x3=-ones(length(t))
x4=[x2 x3]
z=[];
for i=1:length(y);
if y(i)==1
z=[z x4]
else
z=[z x3]
end
end
t2=linspace(0,(0.001.*length(y)/2),length(z))
subplot(3,1,3)
xlabel('Time')
ylabel('Amplitude')
plot(t2,z,'linewidth',3)
title('Manchester RZ')

Delay Modulation:
ts = 0.00001;
t = 0:ts:0.001;
x = rand(1,101);
x1 = round(x);
subplot(3,1,1)
plot(x1)
title('Random Data')
y = [1 0 1 1 0 0 0 1 1 0 1]
subplot(3,1,2)
stairs(y)
x2=ones(length(t))
z=[];
for i=1:length(y);
if y(i)==1
z=[z x2]
z=[z x2.*(-1)]
else
z=[z x2.*(-1)]
z=[z x2]
end
end
t2=linspace(0,(0.001.*length(y)),length(z))
subplot(3,1,3)
xlabel('Time')
ylabel('Amplitude')
plot(t2,z,'linewidth',3)
title('Delay Modulation')
POST LAB
1. Use Pwelch function with a window size say 30 to approximate the PSDs of different line codes.
Comment on there bandwidth efficiencies.

x=double(rand(1,101)>0.3);
y=[1 0 0 1 0 1 1 1 0 1 1];
ts=0.01
t=0:ts:0.05
[PSD,f]=pwelch(x,30,[],[],1000)
plot(f,PSD)
grid on
title('Power Spectral Density')
xlabel('Frequency(Hz)')
ylabel('Power')
Knowing that the PSD gives the spectrum of random signals (so the maximum frequency at which
the PSD of a signal is non–zero can be considered as the bandwidth of that signal), we see that for
a signal y to be transmitted properly through a channel, the bandwidth of the channel must at
least be as much as the bandwidth of the transmitted signal y.

2. 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.

Window Size 10 :

x=double(rand(1,101)>0.3);
y=[1 0 0 1 0 1 1 1 0 1 1];
ts=0.01
t=0:ts:0.05
[PSD,f]=pwelch(x,10,[],[],1000)
plot(f,PSD)
grid on
title('Power Spectral Density')
xlabel('Frequency(Hz)')
ylabel('Power')
Window Size 50 :

x=double(rand(1,101)>0.3);
y=[1 0 0 1 0 1 1 1 0 1 1];
ts=0.01
t=0:ts:0.05
[PSD,f]=pwelch(x,50,[],[],1000)
plot(f,PSD)
grid on
title('Power Spectral Density')
xlabel('Frequency(Hz)')
ylabel('Power')
Critical Analysis / Conclusion :

In this lab, we gained an understanding of line codes' significance and purposes.


Additionally, we learned about power spectral densities and created codes for
various PCM line codes. Initially, we generated PCM line codes and then analyzed
their Power Spectral Densities. Among different modulation techniques, Pulse Code
Modulation (PCM) is the digital modulation technique we focused on, producing a
sequence of numbers instead of a pulse train, hence recognized as a digital process.

You might also like

pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy