Homework Digital
Homework Digital
Homework
Pulse Code Modulation
(PCM)
Uniform Quantization :
Function: uniform_pcm :
This function, given next, takes as its input a sequence of sampled values
(m_samp) and the number of desired quantization levels (L) and finds the
quantized sequence (m_quan), the encoded sequence (code), and the
resulting SQNR (sqnr) in dB. It is used in uniform quantization and it is
also used with other functions in nonuniform quantization.
function [sqnr,m_quan,code]=uniform_pcm(m_samp,L)
global q
%UNIFORM_PCM uniform PCM encoding of a sequence
% [sqnr,m_quan,code]= uniform_pcm(m_samp,L)
% m_samp = input sampled sequence.
% L = number of quantization levels (even).
% sqnr = output SQNR (in dB). %
% idx_quan = index of quantized output.
% m_quan = quantized output before encoding.
% code = the encoded output.
m_max = max(abs(m_samp)); % Find the maximum value of m_samp.
m_quan = m_samp/m_max; % Normalizing m_samp.
idx_quan = m_quan; % Quantization index.
MATLAB
delta = 2/L; % Quantization step.
q = delta.*[0:L-1]; % Define quantization regions.
CODE
hold on
legend('original signal','sampled signal'); 0
CODE
Waveforms
Representation:
The second figure represents:
•Normalized Values: These correspond to the red sampled points in the normalized signal graph (Figure 2).
•Quantization Levels: Quantization levels are based on the ranges defined by the green dashed lines in
Figure 2 (e.g., -1 to -0.8 for Level 1, and so on).
•Code Words: Unique binary code words are assigned to each quantization level.
Case study II:
In this part, we will use the above developed code to generate a sinusoidal signal
with amplitude =4. Using uniform quantization, the samples sequence is
quantized using 8 and 16 quantization levels. Its plots the original signal and the
quantized signal on the same axes.
% MATLAB script for Illustrative Example uniform_ex2.m legend('Original', 'Quantized (L=8)', 'Quantized
clc; clear; close all (L=16)', 'Location', 'SouthEast');
echo on % pause % Press a key to see the first 5 samples,
t_samp = [0:0.01:10]; corresponding quantized
m_samp = sin(t_samp);
% % values, and corresponding codewords with
[sqnr_8L, m_quan_8L, code_8L] = uniform_pcm(m_samp, 8);
8 quantization levels
[sqnr_16L, m_quan_16L, code_16L] = uniform_pcm(m_samp,
16); % m(1:5)
pause % Press a key to see the SQNR for L = 8. % m_quan_8L(1:5)
sqnr_8L; % code_8L(1:5)
pause % Press a key to see the SQNR for L = 16. % pause % Press a key to see the first 5 samples,
sqnr_16L; corresponding quantized
pause % Press a key to see the plot of the signal and % % values, and corresponding codewords with
its quantized versions. 16 quantization levels
t = t_samp; m = m_samp; % m(1:5)
plot(t, m, 'linewidth', 2, ... % m_quan_16L(1:5)
t, m_quan_8L, '-.', ...
% code_16L(1:5)
t, m_quan_16L, '-', ...
echo off
t, zeros(1, length(t)));
1) Determine the sampling frequency used in this example:
For L=16L :
b=log2(16)=4 bits.
SQNR≈6.02⋅4+1.76=25.84 dB.
Comparison:
•The SQNR for L=16L = 16L=16 is higher than for L=8L = 8L=8. This is
expected because increasing the number of quantization levels reduces
quantization noise, thereby improving the SQNR.
•SQNR for L=8L : Approximately 19.82 dB.
•SQNR for L=16L : Approximately 25.84 dB.
•Justification: A larger number of quantization levels improves the resolution and reduces
quantization error, leading to a higher SQNR.
3) View the Matlab figure generated in full screen and observe the
nature of the two quantization signals. Relate your observation to the
SQRN values obtained above.
•Observation: The quantized signal for L=16L is smoother and closer to the original
signal compared to L=8L .
•Relation: The improved quality for L=16L aligns with the higher SQNR obtained, as
more quantization levels reduce the quantization noise.
Homework2:
1- A telephone signal with cut-off frequency of 4 khz is digitzed into bit
PCM, sampled
•Sampling at nyquist
rate (Nyquist rate): rate. Calculate
fs = 2 × fc baseband
= 2 × 4000 =transmission
8000 Hz.
bandwidth and quantization
•Baseband transmission S/N ratio:
bandwidth (BW):
The transmission bandwidth is: BW= fs/2 = 4000 Hz
•Quantization S/N ratio:
For a PCM signal with nnn bits per sample, the quantization SNR is:
SNR=6.02n+1.76 dB.
Assuming n=8 bits (standard for telephone PCM), we have:
SNR=6.02×8+1.76=49.92 dB
2- A telephone signal band limited to 4 kHz is to be transmitted by PCM.
The signal to quantization noise is to be at least 40 db. Find the number of
levels into which the signal has to be encoded. Also find the bandwidth of
transmission.
o Number of quantization levels (LLL):
Using the SNR formula: SNR=6.02n+1.76
For SNR=40 dB: 40=6.02n+1.76 ⟹ n = ≈ 6.36.40
Rounding up, n=7 bits. The number of quantization levels is: L===128
levels.
o Transmission bandwidth:
The transmission bandwidth is equal to the sampling rate, so:
BW=fs=2×fc=8000 Hz
3- An audio signal has its spectral components limited to the frequency
band of 0.3 to 3.3 kHz. A PCM signal is generated with sampling rate of
8000 samples/sec. the required output signal to quantizing noise is 30 dB.
Minimum number of quantization levels (LLL):
Using the SNR formula: SNR=6.02n+1.76 and 30=6.02n+1.76
Solving for nnn: n = ≈ 4.7
Rounding up, 𝑛=5 bits per sample. The number of levels is: L===32.
12- A binary baseband communication system uses the signal set consisting of
s0 (t)=s(t) and s1 (t)=-s(t) with equal probability, where
The channel is AWGN channel with double sided noise power spectral
desnity N0/2.
a) Minimum Error Probability:
The minimum error probability for a binary AWGN system is: Pe=Q()
where Esis the signal energy, and N0is the noise spectral density.
b) Impulse Response of the Receiving Filter:
The impulse response h(t)of the matched filter is matched to s(t):
h(t)=s(T−t) where T is the signal duration.
c) Optimum Sampling Time and Threshold:
•Sampling Time: The optimal sampling time is at t=T, where the filter output is
maximized.
•Threshold: The threshold for detection is typically set to zero, assuming equal
probability and symmetric signals: Threshold=0
13- A multi-level digital communication system sends one of 32 possible
levels over a channel every 0.8 milliseconds.
a) Number of Bits per Level:
The number of bits per level is: b=log2(M),
where M=32 b=log2(32)=5 bits
b) Baud Rate:
The baud rate is the symbol rate, which is the reciprocal of the symbol duration:
Baud rate =
where Ts=0.8 ms = 0.8 × s
Baud rate =
c) Bit Rate:
The bit rate is the product of the baud rate and the number of bits per symbol:
Bit rate = Baud rate×b = 1250×5= 6250bps.
14-An analog signal has time variation f(t) = 3 + 0.2 cos (8000π t) -
0.3 sin (4000π t) .
1.Minimum Sampling Rate (Nyquist):
Identify the highest frequency component: 8000π rad/s ⟹ = =
4000 H
The Nyquist sampling rate is: ≥ 2×=2×4000 = 8000 Hz