DCS Lab 2
DCS Lab 2
Lab Task – 2
Name: Harshith C S
Slot: L35+L36
Title: Pulse Code Modulation and Delta Modulation
Task No: 2
Date: 27/07/2020
Aim: To understand the different types of coding to convert analog signal to digital signal.
Specifically Pulse code modulation (PCM) and Delta Modulation (DM) and construct an algorithm to
perform the same on MATLAB for an input signal.
Theory:
Modulation is the process of varying one or more parameters of a carrier signal in accordance
with the instantaneous values of the message signal.
The message signal is the signal which is being transmitted for communication and the carrier
signal is a high frequency signal which has no data, but is used for long distance
transmission.
PCM
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).
A signal is pulse code modulated to convert its analog information into a binary sequence,
i.e., 1s and 0s. The output of a PCM will resemble a binary sequence. The following figure
shows an example of PCM output with respect to instantaneous values of a given sine wave.
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.
Delta Modulation
A delta modulation (DM or Δ-modulation) is an analog-to-digital and digital-to-analog signal
conversion technique used for transmission of voice information where quality is not of
primary importance. DM is the simplest form of differential pulse-code modulation (DPCM)
where the difference between successive samples are encoded into n-bit data streams.
Following are some of the features of delta modulation.
Programme:
1. PCM
clc;
close all;
clear all;
n=input('Enter n value for n-bit PCM system : ');
n1=input('Enter number of samples in a period : ');
L=2^n;
x=0:2*pi/n1:4*pi; % n1 nuber of samples have tobe selected
s=8*sin(x);
figure
plot(s);
title('Analog Signal');
ylabel('Amplitude');
xlabel('Time');
figure
stem(s);grid on;
title('Sampled Sinal');
ylabel('Amplitude');
xlabel('Time');
% Quantization Process
vmax=8;
vmin=-vmax;
del=(vmax-vmin)/L;
part=vmin:del:vmax; % level are between vmin and vmax with difference of del
code=vmin-(del/2):del:vmax+(del/2); % Contaion Quantized valuses
[ind,q]=quantiz(s,part,code); % Quantization process
% ind contain index number and q contain quantized values
l1=length(ind);
l2=length(q);
for i=1:l1
if(ind(i)~=0) % To make index as binary decimal so started from 0 to N
ind(i)=ind(i)-1;
end
i=i+1;
end
for i=1:l2
if(q(i)==vmin-(del/2)) % To make quantize value inbetween the levels
q(i)=vmin+(del/2);
end
end
figure
stem(q);grid on; % Display the Quantize values
title('Quantized Signal');
ylabel('Amplitude');
xlabel('Time');
% Encoding Process
figure
code=de2bi(ind,'left-msb'); % Cnvert the decimal to binary
k=1;
for i=1:l1
for j=1:n
coded(k)=code(i,j); % convert code matrix to a coded row vector
j=j+1;
k=k+1;
end
i=i+1;
end
subplot(2,1,1); grid on;
stairs(coded); % Display the encoded signal
axis([0 100 -2 3]); title('Encoded Signal');
ylabel('Amplitude');
xlabel('Time');
% Demodulation Of PCM signal
qunt=reshape(coded,n,length(coded)/n);
index=bi2de(qunt','left-msb'); % Getback the index in decimal form
q=del*index+vmin+(del/2); % getback Quantized values
subplot(2,1,2); grid on;
plot(q); % Plot Demodulated signal
title('Demodulated Signal');
ylabel('Amplitude');
xlabel('Time');
2. Delta Modulation
clc
clear all
close all
% define and plot the input signal
a=2;
t=0:2*pi/50:2*pi;
x=a*sin(t);
l=length(x);
plot(x,'ro-');
% define and plot the delta modulated signal
delta=0.2;
hold on
xn=0;
for i=1:l
if x(i)>xn(i)
d(i)=1;
xn(i+1)=xn(i)+delta;
else d(i)=0;
xn(i+1)=xn(i)-delta;
end
end
stairs(xn)
hold on
%recover the original signal (apply demodulation)
for i=1:d
if d(i)>xn(i)
d(i)=0;
xn(i+1)=xn(i)-delta;
else d(i)=1;
xn(i+1)=xn(i)+delta;
end
end
plot(xn,'b-');
legend ('Original Signal', 'Delta Modulated Signal', 'reconstructed signal');
Graphical Output (Captured Photo)
PCM
Delta Modulation
Result: The experiment was performed and the coding of the discrete signals using PCM and
Delta modulation was performed. The need for encoding the values before transmission was
also noted
Verification Signature