0% found this document useful (0 votes)
78 views12 pages

PCM in Digital Communications

(a) The reconstructed signal is very close to the original signal with some quantization noise. The quality improves with increase in number of quantization levels. (b) Without DC, the reconstructed signal matches closely with the original sinusoidal signal. (c) With increase in number of quantization levels from 4 to 8 to 16, the reconstructed signal quality improves with reduction in quantization noise and matches closely with original signal. Task2: Repeat the above problem by changing: (a) Sampling frequency to 40 Hz (b) Message frequency to 4 Hz

Uploaded by

Jessi Hanna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views12 pages

PCM in Digital Communications

(a) The reconstructed signal is very close to the original signal with some quantization noise. The quality improves with increase in number of quantization levels. (b) Without DC, the reconstructed signal matches closely with the original sinusoidal signal. (c) With increase in number of quantization levels from 4 to 8 to 16, the reconstructed signal quality improves with reduction in quantization noise and matches closely with original signal. Task2: Repeat the above problem by changing: (a) Sampling frequency to 40 Hz (b) Message frequency to 4 Hz

Uploaded by

Jessi Hanna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Digital Communications Lab KLEF Deemed to be University.

Department of ECE
Digital Communications Lab (22EC2208L) AY2023-23

Lab-4: Pulse Code Modulation and


Demodulation

In modern communication, real world analog signals are converted into digital signals using
sampling and quantization operations (collectively called analog-to-digital conversion, or ADC).
Sampling is the process of converting a continuous time signal into a discrete time signal by
measuring the signal's amplitude at regular intervals of time. These discrete signals are
processed by digital signal processors, and the processed signals are converted into analog
signals back using a reconstruction operation (called digital-to-analog conversion or DAC).

Objectives:
(a) Understand the basic theory of Pulse Code Modulation and Demodulation and their
elements.
(b) Development of Matlab codes to generate and display the results of Pulse Code
Modulation and Demodulation systems.
(c) Evaluate the performance of Pulse Code Modulation and Demodulation systems.

Learning Outcomes:
After the successful completion of this experiment, students will be able to:
1. Understand the PCM modulation and demodulation process.
2. Develop MATLAB code for PCM modulation and demodulation process.
3. Computing the quantization error
4. Observing the effect of reconstructed signal quality.

Brief theory:

A digital signal is superior to an analog signal because it is more robust to noise


and can easily be recovered, corrected and amplified. For this reason, the tendency
today is to change an analog signal to digital data. Pulse-code modulation (PCM) is a
method used to digitally represent sampled analog signals, which was invented by

1
Alec Reeves in 1937. It is the standard form for digital audio in computers and
various Blu-ray, Compact Disc and DVD formats, as well as other uses such as
digital telephone systems. A PCM stream is a digital representation of an analog
signal, in which the magnitude of the analogue signal is sampled regularly at
uniform intervals, with each sample being quantized to the nearest value within a
range of digital steps.

Fig1 Illustrate the PCM encoder that consist off sampling, quantization and

reconstruction process. PCM consists of three steps to digitize an analog signal as


shown below:
1. Sampling
2. Quantization
3. Binary encoding

Sampling: The first step in the PCM encoding process is sampling the analog signals, sample every Ts
secs, where Ts is referred to as the sampling interval that satisfies the Nyquist theorem. Usually a flat-
top sampling process is used.
Quantization: Sampling results in a series of pulses of varying amplitude values ranging between two

limits: and . The amplitude values are infinite between the two limits. It needs to map the
infinite amplitude values onto a finite set of known values. This is achieved by dividing the distance

between and into L zones, each of height .

The midpoint of each zone is assigned a value from 0 to L-1 (resulting in L values). Each sample falling
in a zone is then approximated to the value of the midpoint. The higher the value of L, the less distorted a
signal is recovered.
Binary encoding: The quantized sequence is encoded into binary stream with appropriate
number of bits.

2
Fig1: Illustration of sampling, quantization and reconstruction process.
PCM Decoder: To recover an analog signal from a digitized signal we follow the following
steps and illustrated in the following Fig2.:

Fig2: Illustration of sampling, quantization and reconstruction


process.

Pre lab Session:


(a) Prior to the lab experiment, understand the basic theory required for the experiment.
(b) Execute the Matlab codes prepared for the worked examples in each stage, observe the
results and show to concerned lab faculty.
(c) Work out all the project tasks and show the results.
(d) Note the results and store the necessary figures and data for the lab report.

Worked Example:

3
Consider the following data for PCM modulation and demodulation:
(a) A sinusoidal signal with unit amplitude and frequency of 2 Hz. Consider sampling rate
20 Samp/sec. Add a DC voltage of say 1.1 V to this signal.
(b) A pulse train with pulse duration of 10 msec and repletion frequency of 40.
Development of Matlab codes to generate:
(i) A message signal with given parameters and its plot.
(ii) A rectangular pulse train and its plot.
(iii) Sampled signal from the above message signal and pulse train and its plot. Compare
the sampled signal with the original message signal and its plot.
(iv) Quantized signal and display for a given number of bits. Compare with the sampled,
original signals and its plot.
(v) Encoded signal and its plot.
(vi) Decoded signal and its plot.
(vii) Recovered signal and its plot.
(viii) Evaluate the effect of various sampling rates and number of bits.

Solution: The Matlab code for the given problem is illustrated below:

% ============
% PCM ENCODING
% ============
clear; close all; clc;
% Creating sampling to define time index
fss = 1.e4; Tss = 1/fss;

% Message signal parameters


A = 1; % Amplitude
f = 2; % Frequency

% Select the sampling rate


fs = 20; % 10 times selected
Ts = 1/fs; % Sampling interval

t = 0:Tss:2-Tss; % Time index


% =================
% Analog message Signal
% =================
m = sin(2*pi*f*t)+1.1;

% Spectrum of mesage signal


N = length(m);

4
figure(1);
plot(t,m,'b','LineWidth',2);
title('Original Signal');
xlabel('Time -->'); ylabel('Amplitude');
axis([0 2 0 2.25]);grid on;

% =================
% Pulse Train Signal
% =================
% Generation of pulse train
D = 40;
d = Ts/D:Ts:2+Ts/D;
p = pulstran(t,d,'rectpuls',1/(fs*D));

figure(2);
plot(t,p,'k','LineWidth',2);
title('Pulsetrain Signal');
xlabel('Time -->'); ylabel('Amplitude');
axis([0 2 0 1.15]);grid on;

5
% =================
% Sampled signal
% =================
ms = m.*p;

figure(3);
plot(t,ms,'m','LineWidth',2);
hold on;plot(t,m,'b--','LineWidth',2);
hold off;
title('Sampled Signal');
xlabel('Time -->'); ylabel('Amplitude');
axis([0 2 0 2.15]);grid on;

6
figure(4);
subplot(3,1,1);plot(t,m,'b','LineWidth',2);
title('Original Signal');
xlabel('Time -->'); ylabel('Amplitude');
axis([0 2 0 2.25]);grid on;

subplot(3,1,2);plot(t,p,'k','LineWidth',2);
title('Pulsetrain Signal');
xlabel('Time -->'); ylabel('Amplitude');
axis([0 2 0 1.15]);grid on;

subplot(3,1,3);plot(t,ms,'m','LineWidth',2);
hold on;plot(t,m,'b--','LineWidth',2);
hold off;
title('Sampled Signal');
xlabel('Time -->'); ylabel('Amplitude');
axis([0 2 0 2.15]);grid on;

% =================
% Quantized Msg
% =================
qm = quant(ms,2/16);

figure(5);
stem(t,qm,'m','filled','LineWidth',2);
hold on;plot(t,ms,'b','LineWidth',2);
% hold on;plot(t,m,'k--','LineWidth',2);
hold off;
title('Sampled Signal');
xlabel('Time -->'); ylabel('Amplitude');

7
axis([0 2 0 2.15]);grid on;
legend('Quantized','Sampled');

% =================
% ENCODING MSG
% =================
em = 8*(qm);
% x = zeros(size(qm));
j = 1;
for i=1:length(em)
if ((((i>1)&&(em(i)~=em(i-1)))||(i==1))&&(em(i)~=0))
x(j) = em(i)-1;
j=j+1;
end
end

z = dec2bin(x,5);
z = z';
z = z(:);
z = str2num(z);

s = 2*(z')-1;

Tb = 2/length(s);
fb = 0.5/Tb;
BL = Tb/Tss;
y = ones(BL,1);
bit = 5*y*s;

8
bit = bit(:);
bit = bit'; % Polar NRZ bit stream

figure()
plot(t,bit,'b','LineWidth',2)
xlabel('t -->');
ylabel('Amplitude');
title('POLAR NRZ ENCODED');
grid;
axis([0 0.5 -5.25 5.25]);

% =============
% PCM Demodulation
% =============
% PCM Decoding
rb = bit(ceil(Tb/(Tss)):(Tb/Tss):length(bit));
rb = (rb+5)/10;
l = length(rb);

for i = 1:l/5
q = rb((5*i)-4:5*i);
q = num2str(q);
x1(i) = bin2dec(q);

9
e(i) = x1(i)+1;
end

e = e/8;
y1 = ones(1,ceil((Ts/D)/Tss));
y2 = zeros(1,(Ts/Tss)-length(y1));
y3 = [y1 y2];
y3 = y3';

ms1 = y3*e; % Sampled signal from Encoded Signal


ms1 = ms1(:);

% =============
% Recovery of samples signals from encoded data
% =============
figure()
plot(t,ms1,'b','LineWidth',2);
title('Recovered Sampled Msg')
grid;
xlabel('t -->');
ylabel('Amplitude');
axis([0 2 0 2.25]);

% =============
% Recovery of Message signal from sampled signal
% =============
% Filtering Sampled Signal

[n,w] = buttord(f/fss,(f+1)/fss,.6,4);
[a,b] = butter(n,w,'low');
rm = filter(a,b,ms1);
rm = rm*50; % Recieved Orignal Signal

figure();

10
plot(t,rm,'m','LineWidth',2);
hold on; plot(t,m,'k--','LineWidth',2); hold off;
title('Recovered Analog Msg')
grid;
xlabel('t -->');
ylabel('Amplitude');
axis([0 2 0 2.25]);

Assignment Tasks:
Task1: (a) Comment on the reconstructed signal.
(b) Repeat the above problem without dc 1.1 V.
(b) Repeat the above problem with uniform quantizing levels of (i) 4 (ii) 8 (iii)
16.
(c) Repeat the above problem with different sampling rates.

Task2: Consider a sinusoidal signal consisting of 1 Hz and 3Hz frequency


components. Develop a Matlab code to perform Pulse Code Modulation and
Demodulation with uniform quantizing levels of (i) 4 (ii) 8 (iii) 16. Use suitable
data.

Viva Questions:

1. What will happen when the sampling rate is greater than Nyquist rate?
2. Differentiate between sampling and quantizing processes.
3. Which type of sampling (ideal, natural or flat top) and why?

11
4. Is the quantization error is positive or negative?
5. Mention some applications of PCM.

Post Lab Session:


(a) Complete the lab work in all aspects in the scheduled lab time.
(b) Answer the given viva questions.
(c) Submit the project report to the lab in-structure and get the signature in time.
(d) Type the complete description of commands used in this project.

12

You might also like