Sunteți pe pagina 1din 33

Chapter 3

Quantization
Nguyen Thanh Tuan, Click
M.Eng.
to edit Master subtitle style
Nguyen Khanh Loi, M.Eng.
Department of Telecommunications (113B3)
Ho Chi Minh City University of Technology nkloi@hcmut.edu.vn
Email: nttbk97@yahoo.com
1. Quantization process

Fig: Analog to digital conversion

❖ The quantized sample xQ(nT) is represented by B bit, which can take


2B possible values.

❖ An A/D is characterized by a full-scale range R which is divided


into 2B quantization levels. Typical values of R in practice are
between 1-10 volts.

Digital Signal Processing 2 Quantization


1. Quantization process

Fig: Signal quantization


R
❖ Quantizer resolution or quantization width (step) Q =
2B
R R
❖ A bipolar ADC −  xQ (nT ) 
2 2
❖ A unipolar ADC 0  xQ (nT )  R

Digital Signal Processing 3 Quantization


1. Quantization process

❖ Quantization by rounding: replace each value x(nT) by the nearest


quantization level.

❖ Quantization by truncation: replace each value x(nT) by its below


nearest quantization level.
❖ Quantization error: e(nT ) = xQ ( nT ) − x( nT )

Q Q
❖ Consider rounding quantization: − e
2 2

Fig: Uniform probability density of quantization error


Digital Signal Processing 4 Quantization
1. Quantization process

Q /2 Q /2
1
❖ The mean value of quantization error e =  ep(e)de =  e de =0
− Q /2 − Q /2
Q
Q /2 Q /2 2
1 Q
❖ The mean-square error  q 2 = e2 =  (e − e )2 p(e)de =  e 2 de =
Q 12
(power) − Q /2 − Q /2

Q
❖ Root-mean-square (rms) error: erms =  q = e2 =
12
❖ R and Q are the ranges of the signal and quantization noise, then
the signal to noise ratio (SNR) or dynamic range of the
quantizer is defined as
  x2  R
SNR dB = 10log10  2  = 20log10   = 20log10 (2 B ) = 6 B dB
  Q
 q
which is referred to as 6 dB bit rule.
Digital Signal Processing 5 Quantization
1. Quantization process

❖ The increase in the number of quantization levels leads to the


decrease of distortion.

Digital Signal Processing 6 Quantization


Example 1

❖ In a digital audio application, the signal is sampled at a rate of 44


KHz and each sample quantized using an A/D converter having a
full-scale range of 10 volts. Determine the number of bits B if the
rms quantization error must be kept below 50 microvolts. Then,
determine the actual rms error and the bit rate in bits per second.

Digital Signal Processing 7 Quantization


2. Digital to Analog Converters (DACs)

❖ We begin with A/D converters, because they are used as the building
blocks of successive approximation ADCs.

Fig: B-bit D/A converter


❖ Vector B input bits : b=[b1, b2,…,bB]. Note that bB is the least
significant bit (LSB) while b1 is the most significant bit (MSB).
❖ For unipolar signal, xQ є [0, R); for bipolar xQ є [-R/2, R/2).

Digital Signal Processing 8 Quantization


2. DACs

Rf
❖ Full scale R=VREF, B=4 bit
I i

2Rf 4Rf 8Rf 16Rf xQ=Vout


MSB
bB
b1
LSB
-VREF
Fig: DAC using binary weighted resistor

 b1 b2 b3 b4 
 REF  2 R 4 R 8R 16 R
I = V  + + + 
 f f f f 
 b1 b2 b3 b4 
xQ = VOUT =  I  R f = VREF  + + + 
 2 4 8 16 
xQ = R 2−4 ( b1 2−3 + b2 2−2 + b3 2−1 + b4 20 ) = Q ( b1 2−3 + b2 2−2 + b3 2−1 + b4 20 )

Digital Signal Processing 9 Quantization


2. DACs

❖ Unipolar natural binary xQ = R(b1 2−1 + b2 2−2 + ... + bB 2− B ) = Qm

where m is the integer whose binary representation is b=[b1, b2,…,bB].


m = b1 2 B −1 + b2 2 B − 2 + ... + bB 20

❖ Bipolar offset binary: obtained by shifting the xQ of unipolar natural


binary converter by half-scale R/2:
−1 −2 R −B R
xQ = R(b1 2 + b2 2 + ... + bB 2 ) − = Qm −
2 2
❖ Two’s complement code: obtained from the offset binary code by
complementing the most significant bit, i.e., replacing b1 by b1 = 1 − b1 .
−1 −2 R −B
xQ = R(b1 2 + b2 2 + ... + bB 2 ) −
2
Digital Signal Processing 10 Quantization
Example 2

❖ A 4-bit D/A converter has a full-scale R=10 volts. Find the quantized
analog values for the following cases ?
a) Natural binary with the input bits b=[1001] ?
b) Offset binary with the input bits b=[1011] ?

c) Two’s complement binary with the input bits b=[1101] ?

Digital Signal Processing 11 Quantization


3. A/D converters

❖ A/D converters quantize an analog value x so that is is represented


by B bits b=[b1, b2,…,bB].

Fig: B-bit A/D converter

Digital Signal Processing 12 Quantization


3. A/D converters

❖ One of the most popular converters is the successive approximation


A/D converter

Fig: Successive approximation A/D converter

❖ After B tests, the successive approximation register (SAR) will hold


the correct bit vector b.

Digital Signal Processing 13 Quantization


3. A/D converters

❖ Successive approximation algorithm

1 if x  0
where the unit-step function is defined by u ( x) = 
0 if x  0
This algorithm is applied for the natural and offset binary with
truncation quantization.

Digital Signal Processing 14 Quantization


Example 3

❖ Consider a 4-bit ADC with the full-scale R=10 volts. Using the
successive approximation algorithm to find offset binary of
truncation quantization for the analog values x=3.5 volts and x=-1.5
volts.

Test b1b2b3b4 xQ C = u(x – Test b1b2b3b4 xQ C = u(x – xQ)


xQ )
b1
b1 1000 0,000 1
1000 0,0 0 b2
b2 1100 2,500 1
0100 -2,5 1 b3
b3 1110 3,750 0
0110 -1,25 0 b4
b4 1101 3,125 1
0101 -1,875 1
1101 3,125
0101 -1,875
Digital Signal Processing 15 Quantization
3. A/D converter

❖ For rounding quantization, we ❖ For the two’s complement


shift x by Q/2: code, the sign bit b1 is treated
separately.

Digital Signal Processing 16 Quantization


Example 4

❖ Consider a 4-bit ADC with the full-scale R=10 volts. Using the
successive approximation algorithm to find offset and two’s
complement of rounding quantization for the analog values x=3.5
volts.

Digital Signal Processing 17 Quantization


Oversampling noise shaping

❖ Because the white noise is equally distributed over the Nyquist


interval with an unchanged total average power, the noise
power per unit frequency interval will be reduced if the
Nyquist interval is enlarged.

Xs(f)

See(f)

-fs/2 fs/2

Xs(f)

See(f)

-fs/2 fs/2

Digital Signal Processing 18 Quantization


Oversampling noise shaping

Digital Signal Processing 20 Quantization


Oversampling noise shaping

Digital Signal Processing 21 Quantization


Oversampling noise shaping

Digital Signal Processing 22 Quantization


Uniform and non-uniform quantization

Digital Signal Processing 24 Quantization


Mid-riser and mid-tread quantization

Digital Signal Processing 25 Quantization


Bonus 2.1

❖ Write a program to simulate DAC.

MSB
b1
b2
b3
xQ
DAC

bB
LSB
R (full-scale range)

Digital Signal Processing 26 Quantization


Bonus 2.2

❖ Write a program to simulate ADC.


MSB
b1
b2
x(n) b3
ADC

bB
LSB
R (full-scale range)

Digital Signal Processing 27 Quantization


Projects

Arduino ADC:
- Changing the value of variable resistor → changing current → changing output LED
- Changing different types of ADC
- https://www.youtube.com/watch?v=ysqyytTWi4k
Arduino DAC:
- http://www.instructables.com/id/Stereo-Audio-with-Arduino/
Sampling and reconstruction using Matlab:
- https://www.youtube.com/watch?v=b-zbYaTPmkE
Some exercises:
http://paloalto.unileon.es/ts/first/chapters/4samplin/homework/overview.htm
http://www.mathworks.com/matlabcentral/fileexchange/38829-matlab-solutions-
introduction-to-digital-signal-processing-a-computer-laboratory-
textbook/content/Chapter%204/ex421.m
http://www.dspguide.com/

Digital Signal Processing 28 Quantization


Review

❖Các thông số cơ bản của quá trình lượng tử hóa?


❖Quan hệ giữa các nguyên tắc lượng tử?
❖Quan hệ giữa các nguyên tắc mã hóa?
❖Tính chất của sai số lượng tử?
❖Hiệu quả của lấy mẫu dư và định dạng nhiễu?
❖Hiệu quả của dither?
❖Giải thuật test bit?
❖Xác định mức lượng tử và các bit lượng tử?
❖Xác định dung lượng cần lưu trữ?
❖Xác định tốc độ xử lý yêu cầu của chip DSP?

Digital Signal Processing 29 Quantization


Homework 1

❖ Cho bộ lượng tử và mã hóa nhị phân tự nhiên B = 5 bit hoạt động


theo nguyên tắc làm tròn gần nhất (rounding) với khoảng lượng tử
đều Q = 1.1 (biết 0 là giá trị lượng tử nhỏ nhất).
a) Xác định giá trị lượng tử lớn nhất?
b) Kiểm tra xem liệu giá trị 20.10 có là giá trị lượng tử hay không?
c) Xác định giá trị lượng tử tương ứng với từ mã 10011?
d) Xác định từ mã của mẫu tín hiệu ngõ vào 20.10?
e) Làm lại câu d trong trường hợp B = 8 bit?

Digital Signal Processing 30 Quantization


Homework 2

❖ Cho bộ lượng tử và mã hóa nhị phân tự nhiên 8 bit hoạt động theo
nguyên tắc làm tròn gần nhất (rounding) với khoảng lượng tử đều
Q = 0.4@ (biết 0 là giá trị lượng tử nhỏ nhất).
a) Xác định giá trị lượng tử lớn nhất?
b) Kiểm tra xem liệu giá trị 24.04 có là giá trị lượng tử hay không?
c) Xác định giá trị lượng tử tương ứng với từ mã 00111101?
d) Xác định từ mã của mẫu tín hiệu ngõ vào 20.13?
e) Dùng giải thuật test bit, xác định từ mã của mẫu tín hiệu ngõ vào
25.03?
f) Đề xuất 1 giải pháp để thực hiện lượng tử theo nguyên tắc rút bớt
(làm tròn xuống) trong trường hợp vẫn sử dụng bộ lượng tử và mã
hóa hoạt động theo nguyên tắc làm tròn trên?

Digital Signal Processing 31 Quantization


Homework 3

❖ Cho bộ lượng tử và mã hóa nhị phân tự nhiên 8 bit hoạt động theo
nguyên tắc làm tròn với khoảng lượng tử đều Q = 0.1@ (biết 0 là
giá trị lượng tử nhỏ nhất).
a) Xác định giá trị lượng tử lớn nhất?
b) Xác định giá trị lượng tử tương ứng với từ mã 11100011?
c) Xác định từ mã của mẫu tín hiệu ngõ vào 22.07?
d) Dùng giải thuật test bit, xác định từ mã của mẫu tín hiệu ngõ vào
9.05?
e) Giả sử tín hiệu phân bố đều trong tầm hoạt động, tính tỉ số công
suất tín hiệu trên nhiễu SNR của bộ lượng tử trên?

Digital Signal Processing 32 Quantization


Homework 4

❖ Cho bộ lượng tử lưỡng cực đối xứng hoạt động theo nguyên tắc
làm tròn với khoảng lượng tử đều Q = 0.2@ (biết 0 là một giá trị
lượng tử) và mã hóa nhị phân 8 bit dạng bù 2.
a) Xác định giá trị lượng tử lớn nhất và nhỏ nhất?
b) Xác định giá trị lượng tử tương ứng với từ mã 10001000?
c) Xác định từ mã của mẫu tín hiệu ngõ vào 1.64?
d) Dùng giải thuật test bit, xác định giá trị lượng tử của mẫu tín hiệu
ngõ vào 1.64?

Digital Signal Processing 33 Quantization


Homework 5

❖ Một tín hiệu rời rạc được lượng tử và mã hóa bằng bộ chuyển
đổi A/D 4 bit có tầm toàn thang R=1@ V dùng giải thuật xấp xỉ
liên tiếp làm tròn xuống (truncation).
a) Hãy xác định khoảng lượng tử Q?
b) Tìm giá trị lượng tử xQ cho giá trị rời rạc x=2.75 V và từ mã
b=[b1 b2 b3 b4] tương ứng cho mã offset?
c) Lặp lại câu b) cho mã bù hai?

Digital Signal Processing 34 Quantization


Homework 6

 2p
Dùng phương trình B = ( p + 0.5) log 2 L − 0.5log 2 ( )
2 p +1

a. Xác định tỷ số lấy mẫu dư L (tốc độ ban đầu 8kHz) để có độ


phân giải 16 bit dùng bộ lượng tử hóa 1 bit, ứng với bộ lượng tử
hóa định dạng nhiễu bậc 1, 2, 3. Tốc độ lấy mẫu dư cho âm thanh
số Lfs là bao nhiêu?

b. Trong một bộ mã hóa thoại mong muốn có độ phân giải 8bit ở


tốc độ 8kHz dùng bộ lưỡng tử hóa 1bit định dạng nhiễu. Ứng với
các bậc của bộ lưỡng tử p= 1,2,3, xác định tỉ lệ lấy mẫu dư tương
ứng L và tốc độ lấy mẫu dư Lfs theo Hz.

Digital Signal Processing 35 Quantization

S-ar putea să vă placă și