Lab02 (R)
Lab02 (R)
Islamabad
Remarks: ……………………………………………
1. Objective
1.1 To understand the process of quantization
1.2 To compare the signal to quantization noise ratio for different quantization levels
1.3 To implement the PCM
3) Understand the trade-off between the bandwith required and the distortion minimized.
2. Introduction
An analog source emits a message waveform x(t) that is first sampled while ensuring the Nyquist
criterion. These samples are then quantized in amplitude and encoded. One type of simple
encoding is to represent each discrete amplitude level by a sequence of binary digits.
The process of quantization usually prevents the quantized output from being reconstructed
exactly into the analog values being quantized. Thus quantization inherently involves the
question of distortion - quantizing more finely typically reduces the distortion, but increases the
bandwidth required to represent the sampled signal. By “distortion” we mean some measure of
the difference between the actual source samples and the corresponding quantized values.
2.1 Quantization
Quantization is the process of approximating a continuous range of values (or a very large set
of possible discrete values) by a relatively-small set of discrete symbols or integer values. More
specifically, a signal can be multi-dimensional and quantization need not be applied to all
dimensions. Discrete signals (a common mathematical model) need not be quantized, which can
be a point of confusion.
A common use of quantization is in the conversion of a discrete signal (a sampled continuous
signal) into a digital signal by quantizing. Both of these steps (sampling and quantizing) are
performed in analog-to-digital converters with the quantization level specified in bits. A specific
example would be compact disc (CD) audio which is sampled at 44,100 Hz and quantized with
16 bits (2 bytes) which can be one of 65,536 (i.e. 216) possible values per sample.
The quantizer input is x[n] and the output is . The output can be expressed by the
following equation: = x[n] + e[n] where e[n] is termed the quantization noise or
quantization error. The noise sequence, e[n], is uncorrelated with the sequence x[n]. After
quantization, actual information about the noise is forgotten. However, the statistics of the noise
is known. The noise is between −Δ/2 and Δ/2 and is uniformly distributed. The probability
density function of the noise or error, e[n], is given by Fig. Below
Now, let us show the relationship between the Signal to Quantization Noise ratio and the number
of bits per samples required. First of all we make a Quantization scale from Vmin to Vmax as
shown below: Next we divide them into quantization levels “N” determined from the system
specs.
Vmin
Vmax
Analog Digital
3. MATLAB Simulation
amax=max(abs(a));
a_quan=a/amax;
b_quan=a_quan;
d=2/n;
q=d.*[0:n-1];
q=q-((n-1)/2)*d;
for i=1:n
a_quan(find((q(i)-d/2 <= a_quan) & (a_quan <= q(i)+d/2)))=...
q(i).*ones(1,length(find((q(i)-d/2 <= a_quan) & (a_quan <= q(i)+d/2))));
b_quan(find( a_quan==q(i) ))=(i-1).*ones(1,length(find( a_quan==q(i) )));
end
a_quan=a_quan*amax;
stem(a_quan);
nu=ceil(log2(n));
sqnr=10*log10(2^(2*nu));
Now generate different sampled signals and quantized them using u_pcm(x,n) function. Where
‘x’ is the input signal and ‘n’ represents the no. of quantization levels used.
For example,
now quantized this signal using u_pcm(x,n) function and increase the no. of quantization levels
ans see the effect on SQNR.
In this task you are required to generate a message signal which is actually a Sinusoidal signal of
Fundamental Frequency defined by the user, sampled at 10 x (Fundamental Frequency) Samples
per sec.
2) Call the u_pcm function in main module and plot the quantized signal for different values of
quantization levels.
3) By increasing the number of quantization levels see the effect this on SQNR and write the
results in the given table below:
Task # 02 QUANTIZATION
Now, input the Signal to Quantization Noise ratio value from the user and quantize the message
signal generated in the previous task.
1) Show the quantized Signal compared to the Original Signal and assign the PCM bits to the
sampled values.
2) Observe and show the PCM bits per sample value calculated along with the Quantization
model table to the instructors.