Lab09
Lab09
LAB REPORT#09
Generation of PCM Line codes and analyzing their Power Spectral Density
using MATLAB
Class BEE-8R
LAB TASK:
TASK A:
MATLAB Code:
clc
clear all
close all
fs = 10000; %Sampling Frequency
f = 1000;
ts = 1/fs; %Sampling Time
t = linspace (0,1/f, fs/f);
time = linspace(0,2/f,2*fs/f);
test = [1 0 1 1 0 0 0 1 1 0 1]; %Test Data
r = [ones(1,length(t))];
subplot (3,1,1)
stem (t, r)
title('signal')
rd = (randi (1,100))'; %Random Data of 100 length
cd = (rd*r); %setting random data to '1'
cd = cd (:); %Give value '0' or'1'
t = linspace (0,100/length (rd)*fs/f);
subplot (3,1,2)
plot (t, cd)
title ('unipolar nrz for random data')
r = [r 1];
cd = (test.*r)';
t = linspace(0,10/length(cd));
subplot (3,1,3)
plot(t,cd)
title('unipolar nrz for test data')
OUTPUT
POST LAB
MATLAB Code:
clc
clear all
close all
fs = 100000;
f=1000;
ts = 1/f;
t=linspace(0,1/f,fs/f);
length(t)
time=linspace(0,2/f,2*fs/f);
testd=[1; 0; 1; 1; 0; 0; 0; 1; 1; 0; 1];
rdata=(randi(1,100))';
A=[1 -1]
rect1=[A(1)*ones(1,length(t)/2) -1*ones(1,length(t)/2)];
rect2=[-1*ones(1,length(t))];
subplot(3,1,1)
plot(t,rect1,'r')
title('signal','FontWeight','bold')
xlabel('timeperiod ')
ylabel('amplitude ')
subplot(3,1,2)
plot(t,rect2,'r')
title('signal','FontWeight','bold')
xlabel('timeperiod ')
ylabel('amplitude ')
code=[]
a=[1 -1]
if
testd(1)==0
code=[code(rect2)]
else
code=[code(rect1)]
end
for
i=2:11
if
testd(i)==0
if
testd(i-1)==0
rect2=-1*rect2
code=[code (rect2)]
else
rect2=rect2
code=[code (rect2)]
end
else
if
testd(i-1)==1
rect1=-1*rect1
code=[code (testd(i)*(rect1))]
else
rect1=[-1*ones(1,length(t)/2) A(1)*ones(1,length(t)/2)];
code=[code (rect1)]
end
end
end
code=code'
code=code(:)
code=code'
t=linspace(0,11/f,11*fs/f);
length(t)
subplot(3,1,3)
plot(t,code,'r')
title('delay modulation','FontWeight','bold')
xlabel('timeperiod')
ylabel('amplitude')
grid on
figure()
subplot(2,1,1)
h=spectrum.welch
hpsd=psd(h,code,'fs',fs)
plot(hpsd)
subplot(2,1,2)
h=spectrum.periodogram
hpsd=psd(h,code,'fs',fs)
plot(hpsd)
OUTPUT
Conclusion:
In this lab we generated PCM line codes and after generating these codes we analyzed their Power Spectral Densities.
There are many modulation techniques, which are classified according to the type of modulation employed. Of them all,
the digital modulation technique used is Pulse Code Modulation (PCM). Instead of a pulse train, PCM produces a series
of numbers or digits, and hence this process is called as digital. Each one of these digits, though in binary code,
represent the approximate amplitude of the signal sample at that instant. In Pulse Code Modulation, the message signal
is represented by a sequence of coded pulses. This message signal is achieved by representing the signal in discrete form
in both time and amplitude. In Unipolar scheme, all the signal levels are either above or below the axis. In polar
schemes, the voltages are on the both sides of the axis. Manchester encoding is somewhat combination of the RZ
(transition at the middle of the bit) and NRZ-L schemes. The duration of the bit is divided into two halves. The voltage
remains at one level during the first half and moves to the other level in the second half. The transition at the middle of
the bit provides synchronization. After the digital-to-analog conversion is done by the regenerative circuit and the
decoder, a low-pass filter is employed, called as the reconstruction filter to get back the original signal. Hence, the Pulse
Code Modulator circuit digitizes the given analog signal, codes it and samples it, and then transmits it in an analog form.
This whole process is repeated in a reverse pattern to obtain the original signal.