www.iammanuprasad.
com
Performance of Waveform Coding using PCM
Objective
1. Generate a sinusoidal waveform with a DC offset so that it takes only positive amplitude
value.
2. Sample and quantize the signal using an uniform quantizer with number of representation
levels L. Vary L. Represent each value using decimal to binary encoder.
3. Compute the signal-to-noise ratio in dB.
4. Plot the SNR versus number of bits per symbol. Observe that the SNR increases linearly.
Software Used:
MATLAB R2018a MATLAB R2024b
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. 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. The transmitter section of a Pulse Code Modulator circuit consists of Sampling,
Quantizing and Encoding, which are performed in the analog-to-digital converter section. The low pass
filter prior to sampling prevents aliasing of the message signal. The basic operations in the receiver
section are regeneration of impaired signals, decoding, and reconstruction of the quantized pulse train.
Following is the block diagram of PCM which represents the basic elements of both the transmitter and
the receiver sections
IMPLearn
% Generate a sinusoidal waveform with a DC offset so that it takes only
% positive amplitude value
clear;% clearing the variables
close all;% closing any opened figures
% Plotting the offset sinusoidal signal
time = 0:.0005:.05;
freq_msg=100; %wave form frequency
dc_ofst=2; % signal offset
signal=sin(2*pi*freq_msg*time)+dc_ofst; %Generating the signal
% plotting the signal
figure;plot(time,signal)
xlabel('time')
ylabel('Amplitude')
title('Signal')
% Sampling the signal
freq_sample=15*freq_msg; % sampling frequency
samp_time=0:1/freq_sample:0.05; % sampling time
samp_signal=dc_ofst+sin(2*pi*freq_msg*samp_time);% generating the sampled
signal
hold on
plot(samp_time,samp_signal,'rx') % plotting the sampled signal
title('Sampled Signal')
legend('Original signal','Sampled signal');
% Uniform Quantizer
L=8; %No of Quantization levels
smin=round(min(signal));
smax=round(max(signal));
Quant_levl=linspace(smin,smax,L); % Length 8, to represent 9 intervals
codebook = linspace(0,smax,L+1); % Length 9, one entry for each interval
[index,quants] = quantiz(samp_signal,Quant_levl,codebook); % Quantize.
figure;plot(samp_time,samp_signal,'x',samp_time,quants,'.-')% plotting
sampled signal and quantization level
title('Quantized Signal')
legend('Original signal','Quantized signal');
figure;plot(samp_time,index,'.-')% plotting quantization levels of input
signal
title('Encoded Signal')
% % Quantization Levels plotting
% u = 0:0.01:1;
% y = uencode(u,4);
% figure;plot(u,y)
% title('Quantization Levels')
% Binary coding
for i=1:length(index)
bincode_sig{i}=dec2bin(round(index(i)),7);
end
disp('binary encoded signal')
disp(bincode_sig)
1
% SNR ratio calculation
noise=quants-samp_signal; % calculating noise
figure;plot(samp_time,noise,'.-') % plotting figure
title('Noise')
r=snr(index,noise);% SNR
snr1=['SNR :',num2str(r)];
disp(snr1)
binary encoded signal
Columns 1 through 5
{'0000100'} {'0000101'} {'0000111'} {'0000111'} {'0000111'}
Columns 6 through 10
{'0000111'} {'0000110'} {'0000101'} {'0000011'} {'0000010'}
Columns 11 through 15
{'0000001'} {'0000001'} {'0000001'} {'0000001'} {'0000011'}
Columns 16 through 20
{'0000100'} {'0000101'} {'0000111'} {'0000111'} {'0000111'}
Columns 21 through 25
{'0000111'} {'0000110'} {'0000101'} {'0000011'} {'0000010'}
Columns 26 through 30
{'0000001'} {'0000001'} {'0000001'} {'0000001'} {'0000011'}
Columns 31 through 35
{'0000100'} {'0000101'} {'0000111'} {'0000111'} {'0000111'}
Columns 36 through 40
{'0000111'} {'0000110'} {'0000101'} {'0000011'} {'0000010'}
Columns 41 through 45
{'0000001'} {'0000001'} {'0000001'} {'0000001'} {'0000011'}
Columns 46 through 50
{'0000100'} {'0000101'} {'0000111'} {'0000111'} {'0000111'}
Columns 51 through 55
{'0000111'} {'0000110'} {'0000101'} {'0000011'} {'0000010'}
Columns 56 through 60
2
{'0000001'} {'0000001'} {'0000001'} {'0000001'} {'0000011'}
Columns 61 through 65
{'0000100'} {'0000101'} {'0000111'} {'0000111'} {'0000111'}
Columns 66 through 70
{'0000111'} {'0000110'} {'0000101'} {'0000011'} {'0000010'}
Columns 71 through 75
{'0000001'} {'0000001'} {'0000001'} {'0000001'} {'0000011'}
Column 76
{'0000100'}
SNR :18.6833
3
4
Published with MATLAB® R2024b