Dcom Manual Lab 07
Dcom Manual Lab 07
Introduction:
The goal of the lab is to present the students with first essential signal processing step, formatting, which is to a transform an analog signal from a source into digital symbols. The information in analog form is first transformed into a digital format by means of sampling and quantization. The process of transforming an analog waveform into a form that is compatible with a digital communication system starts with sampling the waveform to produce a discrete pulse-amplitude-modulated waveform, as described below.
Sampling:
To sample a continuous-time signal x(t) is to represent x(t) at a discrete number of points, t = nTs, where T s is the sampling period. The sampling theorem states that a band-imited signal x(t) with a bandwidth W can be reconstructed from its sample values x(n)= x (nT s) if the sampling frequency f s= 1/T s is greater than twice the bandwidth W of x(t). Otherwise, aliasing would result in x(t) . The minimum sampling rate of 2fs for an analog band-limited signal is called the Nyquist rate.
Quantization:
In order to process the sampled signal digitally, the sample values have to be quantized to a finite number of levels, and each value can then be represented by a string of bits. For example, if the signal is quantized to N different levels, then log2(N) bits per sample are required. Notice that to quantize a sample value is to round it to the nearest point among a finite set of permissible values. Therefore, a distortion will inevitably occur. This is called quantization noise (or error). Quantization can be classified as uniform and non-uniform. In the case of uniform quantization, the quantization regions are chosen to have equal length. However, in non-uniform quantization, regions of various lengths are allowed. Non-uniform quantization can be implemented through compression-expansion (or companding) of the signal, and this is commonly used (as in telephony) to maintain a uniform signal-to-quantization noise ratio over the full dynamic range of the signal (refer to your textbook for more details).
Procedure:
Lab Manual: Digital Communication Department of Electrical Engineering, WEC Mohsin Mushtaq (UW-07-EE-015)
Lab#7
Code :
clc clear all close all t=0:0.1:10; m=length(t); a=sin(2*pi*0.1*t); n=8; amax=max(abs(a)); b=a+amax; c=(n-1)*(b/(2*amax)); d=round(c); a_quan=2*amax.*d/(n-1)-amax; a_error=a-a_quan; square_a=a.*a; square_a_error=a_error.*a_error; S=0; N=0; for i=1:length(square_a) S=S+square_a(i); end S for p=1:length(square_a_error) N=N+square_a_error(p); end N SQNR=10.*log10(S/N) binary=dec2bin(SQNR) for n=8 output is S = 50.0000 : N =0.6104 : SQNR =19.335 binary =10011 For n=16 output is S =50.0000 : N =0.1423 binary =11001 : SQNR =25.4561
Quantization
Lab#7
Sine Wave
Quantizer1
Figur e3 4.1 Change the quantization step size (Quantization interval) and note the changes in the diagram. By changing the step size output quantized width increases ; in other words your output binary gets changed 4.2 Change the scaling factor in the logarithmic quantization and note the effect of it. By changing lorathimic quantization amplitude, phase & shape of quantized signal changes .
4.3 Generate a sine wave using t=0:0.01:2*pi; then quantize the signal using the following: > key function quantiz par =
Lab Manual: Digital Communication Department of Electrical Engineering, WEC Mohsin Mushtaq (UW-07-EE-015)
Lab#7
clc par =[-3.5000 -2.5000 -1.5000 -0.5000 0.5000 1.5000 2.5000]; code =[-3.5000 -2.5000 -1.5000 -0.5000 0.5000 1.5000 2.5000 3.5000]; T=0 : 0.01 : 2*pi ; Y=sin(T); [index,x] = quantiz(Y,code,par); q=quantizer([3 0]); m=num2bin(q,x) plot(x) hold on plot(Y,'+')
-3.5000 -2.5000 -1.5000 -0.5000 0.5000 1.5000 2.5000; code = -3.5000 -2.5000 -1.5000 -0.5000 0.5000 1.5000 2.5000 3.5000; Example: T=0 : 0.01 : 2*pi ; Y=sin(t); [index,quantY] = quantize(y,code,par); Now convert the index into binary using the command num2bin. Use quantizer=([3,0]); % 3 for total number of bit, % 0 for total number of bits Used for decimal points Code :
1.5
0.5
-0.5
-1
100
200
300
400
500
600
700
subplot 321 plot(t,a) title('graph1') xlabel('time axis') ylabel('a') subplot 322 Lab Manual: Digital Communication Department of Electrical Engineering, WEC Mohsin Mushtaq (UW-07-EE-015)
Lab#7 plot(t,b) title('graph2') xlabel('time axis') ylabel('b') subplot 323 plot(t,c) title('graph3') xlabel('time axis') ylabel('c') subplot 324 plot(t,d) title('graph4') xlabel('time axis') ylabel('d') subplot 325 plot(t,a_quan) title('graph5') xlabel('time axis') ylabel('a-quan') subplot 326 plot(t,a) hold on plot(t,a_quan) title('graph6') xlabel('time axis') ylabel('a-error')
graph2
10
1 0 -1 0 5 time axis 10