You are on page 1of 42

Chapter 4: Sampling and Quantization

A First Course in Digital Communications


Ha H. Nguyen and E. Shwedyk

February 2009

A First Course in Digital Communications

1/42

Chapter 4: Sampling and Quantization

Introduction
Though many message sources are inherently digital in nature, two of the most common message sources, audio and video, are analog, i.e., they produce continuous time signals. To make analog messages amenable for digital transmission sampling, quantization and encoding are required.
Sampling: How many samples per second are needed to exactly represent the signal and how to reconstruct the analog message from the samples? Quantization: To represent the sample value by a digital symbol chosen from a nite set. What is the choice of a discrete set of amplitudes to represent the continuous range of possible amplitudes and how to measure the distortion due to quantization? Encoding: Map the quantized signal sample into a string of digital, typically binary, symbols.
A First Course in Digital Communications 2/42

Chapter 4: Sampling and Quantization

Ideal (or Impulse) Sampling


m(t )

m s (t ) =

n =

s (t ) =

Ts is the period of the impulse train, also referred to as the sampling period. The inverse of the sampling period, fs = 1/Ts , is called the sampling frequency or sampling rate. It is intuitive that the higher the sampling rate is, the more accurate the representation of m(t) by ms (t) is. What is the minimum sampling rate for the sampled version ms (t) to exactly represent the original analog signal m(t)?
A First Course in Digital Communications 3/42

n =

(t nTs )

m(nTs ) (t nTs )

I V IX
M (0) Ts

RQP V I T S T U V IW
Ms( f )

V IXW

t srfcq pihgfe ddcba`Y 01( 3 )@ 37654 3 ) 2 3 )8 3 )98  03765( 0 )('     


M ( 0)

EDCBA " ! $# % !& !  

Illustration of Ideal Sampling


Chapter 4: Sampling and Quantization

A First Course in Digital Communications

M(f )

4/42

EFC BG H

Chapter 4: Sampling and Quantization

Spectrum of the Sampled Waveform

ms (t) = m(t)s(t) Ms (f ) = M (f ) S(f ) 1 Ts

Ms (f ) = M (f )

(f nfs ) =
n= S(f )

1 Ts

M (f nfs ).
n=

If the bandwidth of m(t) is limited to W Hertz, m(t) can be completely recovered from ms (t) by an ideal lowpass lter of bandwidth W if fs 2W . When fs < 2W (under-sampling), the copies of M (f ) overlap and it is not possible to recover m(t) by ltering aliasing.
A First Course in Digital Communications 5/42

Chapter 4: Sampling and Quantization

Reconstruction of m(t)

Ms (f ) = F {ms (t)} =
n=

m(nTs )F {(t nTs )} =


n=

m(nTs )exp(j2nf Ts )

M (f ) = m(t)

Ms (f ) 1 = fs fs

m(nTs )exp(j2nf Ts ),
n=

W f W.

= F 1 {M (f )} =
W

M (f )exp(j2f t)df

=
W

1 fs

m(nTs )exp(j2nf Ts )exp(j2f t)df


n= W

= =

1 fs

m(nTs )
W

exp[j2f (t nTs )]df

n=

m(nTs )
n=

sin[2W (t nTs )] n = m fs (t nTs ) 2W n=

sinc(2W t n)
6/42

A First Course in Digital Communications

Chapter 4: Sampling and Quantization

Sampling Theorem

Theorem A signal having no frequency components above W Hertz is completely described by specifying the values of the signal at periodic time instants that are separated by at most 1/2W seconds. fs 2W is known as the Nyquist criterion, the sampling rate fs = 2W is called the Nyquist rate and its reciprocal called the Nyquist interval. Ideal sampling is not practical Need practical sampling methods.

A First Course in Digital Communications

7/42

Chapter 4: Sampling and Quantization

Bandlimited Interpolation
Example of Bandlimited Signal Reconstruction (Interpolation)
1

x(t)

0.5 0 5 1 0.5 0 5 1 4 3 2 1 0 1 2 3 4 5 4 3 2 1 0 1 2 3 4 5

x (t)

x[n]=x(nT )

s r

0.5 0 5 4 3 2 1 0 1 2 3 4 5

Normalized time (t/Ts)


A First Course in Digital Communications 8/42

Chapter 4: Sampling and Quantization

Natural Sampling

m(t )

m s (t ) =

n =

p (t ) =

n =

In the above, h(t) = 1 for 0 t and h(t) = 0 otherwise. The pulse train p(t) is also known as the gating waveform. Natural sampling requires only an on/o gate.

A First Course in Digital Communications

yxw

h (t nTs )

m(t )h (t nTs )

9/42

Chapter 4: Sampling and Quantization

Illustration of Natural Sampling

P( f )
0 1 2

(D ) (D ) (D )

Ms( f )

A First Course in Digital Communications

| |

10/42

l gs l nm l g jih l g l g po k q rq

~} | |

xwvut fed fe

xyv uz {

M(f )
M ( 0)

Chapter 4: Sampling and Quantization

Signal Reconstruction in Natural Sampling


Write the periodic pulse train p(t) in a Fourier series as:

p(t) =
n=

Dn exp(j2nfs t),

Dn =

sinc Ts

n Ts

ejn /Ts .

The sampled waveform and its Fourier transform are

ms (t) = m(t)
n=

Dn exp(j2nfs t).

Ms (f ) =
n=

Dn F{m(t)exp(j2nfs t)} =
n=

Dn M (f nfs ).

The original signal m(t) can still be reconstructed using a lowpass lter as long as the Nyquist criterion is satised.
A First Course in Digital Communications 11/42

Chapter 4: Sampling and Quantization

Flat-Top Sampling
Flat-top sampling is the most popular sampling method and involves two simple operations: sample and hold.

h(t )

n =

n =

n =

A First Course in Digital Communications

s (t ) =

(t nTs )

m(t )

m( nTs ) (t nTs )

m s (t ) =


m(nTs )h(t nTs )
12/42

Chapter 4: Sampling and Quantization

Spectrum of ms (t) in Flat-Top Sampling

ms (t) = m(t)
n=

(t nTs ) h(t). 1 H(f ) M (f nfs ), Ts n=


Ms( f )

Ms (f ) = F

m(t)
n=

(t nTs ) F {h(t)} =

M(f )

H( f )

A First Course in Digital Communications


Ms( f )


13/42

where H(f ) = F {h(t)} = sinc(f )exp(jf ).

Chapter 4: Sampling and Quantization

Equalization
Not possible to reconstruct m(t) using an lowpass lter, even when the Nyquist criterion is satised. The distortion due to H(f ) can be corrected by connecting an equalizer in cascade with the lowpass reconstruction lter. Ideally, the amplitude response of the equalizer is |Heq | = Ts Ts = |H(f )| sinc(f )

H eq =

A First Course in Digital Communications

14/42

m s (t )


sinc( f )
Ts

m(t )

Chapter 4: Sampling and Quantization

Pulse Modulation
In pulse modulation, some parameter of a pulse train is varied in accordance with the sample values of a message signal. Pulse-amplitude modulation (PAM): amplitudes of regularly spaced pulses are varied.
PAM transmission does not improve the noise performance over baseband modulation, but allows multiplexing, i.e., sharing the same transmission media by dierent sources. The multiplexing advantage oered by PAM comes at the expense of a larger transmission bandwidth.

Pulse-width modulation (PWM): widths of the individual pulses are varied. Pulse-position modulation (PPM): position of a pulse relative to its original time of occurrence is varied. Pulse modulation techniques are still analog modulation. For digital communications of an analog source, quantization of sampled values is needed.
A First Course in Digital Communications 15/42

Chapter 4: Sampling and Quantization

PWM & PPM Waveforms with a Sinusoidal Message


1 0.5 m(t) 0 0.5 1 0 2 1.5 1 0.5 0 0
2 1.5 1 0.5 0 0 2 1.5 1 0.5 0 0 0.2 0.4 t 0.6 0.8 1 (d) 0.2 0.4 t 0.6 0.8 1 (c)

(a)

0.2

0.4 t

0.6

0.8

(b)

0.2

0.4 t

0.6

0.8

A First Course in Digital Communications

16/42

Chapter 4: Sampling and Quantization

Quantization
    
17/42

Quantization is to transform m(nTs ) into a discrete amplitude m(nTs ) taken from a nite set. If the spacing between two adjacent amplitude levels is suciently small, then m(nTs ) can be made practically indistinguishable from m(nTs ). There is always a loss of information associated with the quantization process, no matter how ne one may choose the nite set of the amplitudes Not possible to completely recover the sampled signal from the quantized signal.

A First Course in Digital Communications

{m(nTs )}

{m(nTs )}

Chapter 4: Sampling and Quantization

Memoryless Quantization
m(nTs ) m( nTs )
# &% $# '    # &% $# # "  "!

Tl 1
Dl 1

Tl Dl
Dl +1

Tl +1 m( nTs )
Dl +2

m( nTs )

Quantization of current sample value is independent of earlier/later samples. The lth interval is determined by the decision levels (also called the threshold levels) Dl and Dl+1 : Il : {Dl < m Dl+1 }, l = 1, . . . , L. Signal amplitudes in Il are all represented by one amplitude Tl Il (target level or reconstruction level).
A First Course in Digital Communications 18/42

Chapter 4: Sampling and Quantization

Uniform Quantizer
Step-size is the same and the target level is in the middle of D +D the interval: Tl = l 2 l+1 . Midtread and midrise input/output characteristics:
m( nTs )

T7 T7

T6
T6

T5 D4 D1 D2 D3
D5 T3

D4 D1 D2 D3
T3 D6 D7

D6

D7

D8

m( nTs )

D8

D9

T2 T2 T1
T1

A First Course in Digital Communications

EF GF E DCBA@

EF GF E DCBDCH
m(nTs )

Q PI

34 54 3 210)(

34 54 3 210216 987

T8

m( nTs )

19/42

Chapter 4: Sampling and Quantization

Input and Output of A Midrise Uniform Quantizer


cb a `YXWV UT SR
mmax m (t )
5Ts
A First Course in Digital Communications

U` i` U hg Vf Ve` d U` i` U W`srqp

m (t )

3Ts 2Ts Ts
0

t (sec)
Ts

2Ts

3Ts

4Ts

5Ts

mmax

20/42

Chapter 4: Sampling and Quantization

Illustration of Quantization Error


1 0.8 Normalized amplitude (volts/ mmax) 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1 Normalized error 5 0 5 4 3 2 1 0 t/ T 1 2 3 4 5 4 3 2 1 0 1 2 3 4 5

A First Course in Digital Communications

21/42

Chapter 4: Sampling and Quantization

Signal-to-Quantization Noise Ratio (SNRq )


Model the input as a zero-mean random variable m with some pdf fm (m). Assume the amplitude range of m is mmax m mmax max the quantization step-size is = 2mL . Let q = m m be the quantization error, then /2 q /2. If is suciently small (L is suciently large), q is approximately uniform over [/2, /2]: fq (q) = 0,
1 ,

< q 2 otherwise

The mean of q is zero, while its variance is:


2 q = /2 /2

q 2 fq (q)dq =

/2 /2

q2

dq =

2 m2 = max . 12 3L2
22/42

A First Course in Digital Communications

Chapter 4: Sampling and Quantization

With L = 2R , where R is the number of 2bits needed to mmax 2 represent each target level, then q = 322R
2 The average message power is m = mmax mmax

m2 fm (m)dm.

The signal-to-quantization noise ratio is SNRq =


2 3m m2 max

22R =

3 22R . F2

F is called the crest factor of the message, dened as, F = Peak value of the signal mmax = . RMS value of the signal m

SNRq increases exponentially with the number of bits per sample R and decreases with the square of the messages crest factor.

A First Course in Digital Communications

23/42

Chapter 4: Sampling and Quantization

Expressed in decibels, SNRq is 10 log 10 SNRq = 6.02R + 10 log10


2 m + 4.77 m2 max = 6.02R 20 log10 F + 4.77

An additional 6-dB improvement in SNRq is obtained for each bit added to represent the continuous signal sample (6-dB rule).

A First Course in Digital Communications

24/42

Chapter 4: Sampling and Quantization

Optimal Quantizer
Uniform quantizer is not optimal in terms of minimizing the signal-to-quantization noise ratio. In general, the decision levels are constrained to satisfy: D1 = mmax , DL+1 = mmax , Dl Dl+1 , for l = 1, 2, . . . L. The average quantization noise power is
L Dl+1 Dl

Nq =
l=1

(m Tl )2 fm (m)dm.

To obtain the optimal quantizer that maximizes the SNRq , one needs to nd the set of 2L 1 variables {D2 , D3 , . . . , DL , T1 , T2 , . . . , TL } to minimize Nq .
A First Course in Digital Communications 25/42

Chapter 4: Sampling and Quantization

Dierentiate Nq with respect to Dj and set the result to 0: Nq = fm (Dj ) (Dj Tj1 )2 (Dj Tj )2 = 0, j = 2, 3, . . . L. Dj Tl1 + Tl , l = 2, 3, . . . L. 2 The decision levels are the midpoints of the target values! Dierentiate Nq with respect to Tj and set the result to 0: Dlopt = Nq = 2 Tj
Dj+1

(m Tj )fm (m)dm = 0, j = 1, 2, . . . L.
Dj Dl+1 mfm (m)dm Dl , Dl+1 fm (m)dm Dl

Tlopt =

l = 1, 2, . . . , L.

The target value for a quantization region should be chosen to be the centroid of that region.
A First Course in Digital Communications 26/42

Chapter 4: Sampling and Quantization

Example of Optimal Quantizer Design (Problem 4.6)


fm (m) (1/volts)
1

T1

1/3
1 4

1
T1 =

1 D1 4

0
=

m (volts)
D1
1/4 0 1 4

T2
1 3

1
D1 mdm 1/4 1 1 4 3

T2 2D1 T1

= = =

D1 mfm (m)dm 0 D1 fm (m)dm 0 1 D1 mfm (m)dm 1 D fm (m)dm


1

mdm +

+ D1

2 1 + 8D1 8 + 16D1

(1)

2 1 D1 1 + D1 = , 2(1 D1 ) 2

D1 =

T1 + T2 2

(2)

2 1 + 8D1 1 + D1 5 2 + 4D1 + D1 = 0 D1 = 0.4478 (3) 8 + 16D1 2 4 0.1717; T2 = 0.7239. (4) 27/42

A First Course in Digital Communications

Chapter 4: Sampling and Quantization

Lloyd-Max Conditions and Iterative Algorithm


Dlopt Tl1 + Tl = , 2 (5) Tlopt =
Dl+1 mfm (m)dm Dl . Dl+1 fm (m)dm Dl

(6)

l = 2, 3, . . . L
1

Start by specifying an arbitrary set of decision levels (for example the set that results in equal-length regions) and then nd the target values using (6). Determine the new decision levels using (5). The two steps are iterated until the parameters do not change signicantly from one step to the next.

2 3

The optimal quantizer needs to know pdf fm (m) and is designed for a specic mmax Prefer quantization methods that are robust to source statistics and changes in the signals power level.
A First Course in Digital Communications 28/42

Chapter 4: Sampling and Quantization

Robust Quantizers
When the message signal is uniformly distributed, the optimal quantizer is a uniform quantizer As long as the distribution of the message signal is close to uniform, the uniform quantizer works ne. For a voice signal, there exists a higher probability for smaller amplitudes and a lower probability for larger amplitudes it is more ecient to design a quantizer with more quantization regions at lower amplitudes and less quantization regions at larger amplitudes (i.e., nonuniform quantization). Robust method for performing nonuniform quantization is to use compander=compressor+ expander.
f e xyd w
29/42

A First Course in Digital Communications

xy u x uy

xy vxu

xu yxw vut

Chapter 4: Sampling and Quantization

-law and A-law Companders


y = ymax ymax A(|m|/mmax ) sgn(m), 1+lnA
1 0.9 =255 0.8 0.7 Output y/ymax 0.6 0.5 0.4 0.3 0.2 0.1 0 0
A First Course in Digital Communications
max

ln [1 + (|m|/mmax )] sgn(m), (-law) ln(1 + ) 0<


|m| mmax

1 A

y=

1+ln[A(|m|/mmax )] y sgn(m), max 1+lnA

, (A-law)
1 A < |m| mmax

<1

1 0.9 A=250 0.8 0.7 0.6 0.5 0.4 0.3 0.2 A=1 A=10 A=87.6

=1 =10

Output y/y

=0

(a) 0.5 Input m/mmax 1

0.1 0 0

(b) 0.5 Input m/mmax 1


30/42

Chapter 4: Sampling and Quantization

SNRq of Non-Uniform Quantizers


y

y max

y = g (m)

dy dm

yl

mmax

ml

mmax

y max

When L 1 , and l are small fm (m) is a constant fm (ml ) over l and ml is at the midpoint of the lth quantization region.
L ml + ml
l 2

Nq

=
l=1 L

l 2

(m ml )2 fm (m)dm
ml +
l 2

=
l=1

fm (ml )
ml

l 2

(m ml )2 dm =
l=1

3 l fm (ml ). 12
31/42

A First Course in Digital Communications

Chapter 4: Sampling and Quantization


y

y max

y = g (m)

dy dm

yl

mmax

ml

mmax

y max

dg(m) = l dm

Nq =
m=ml

2 12

fm (ml )
dg(m) dm m=ml

2 l .

l=1

Since L 1, approximate the summation by an integral to obtain Nq = 2 12


mmax mmax

fm (m) dg(m) dm

2 dm =

2 ymax 3L2

mmax mmax

fm (m) dg(m) dm

2 dm.

A First Course in Digital Communications

32/42

Chapter 4: Sampling and Quantization

SNRq of -law Compander


dg(m) ymax (1/mmax ) = . dm ln(1 + ) 1 + (|m|/mmax ) Nq =
2 ymax 3L2

ln2 (1 + ) 2 ymax mmax


mmax mmax

mmax 2

1+
mmax

|m| mmax |m| mmax


2

fm (m)dm

m2 ln2 (1 + ) max 3L2 2 Since


mmax mmax

1 + 2
m

|m| mmax

+ 2

fm (m)dm.

max 2 fm (m)dm = 1, mmax m2 fm (m)dm = m and mmax mmax |m|fm (m)dm = E{|m|}, then

Nq =

2 m2 ln2 (1 + ) E{|m|} max 1 + 2 + 2 2m . 3L2 2 mmax mmax


33/42

A First Course in Digital Communications

Chapter 4: Sampling and Quantization

SNRq =

2 2 m 3L2 2 (m /m2 ) max = 2 . 2 Nq ln (1 + ) 1 + 2(E{|m|}/mmax ) + 2 (m /m2 ) max


2 m , m2 max

2 Dene n =

then

E{|m|} m m mmax

E{|m|} m n .

Therefore,

2 SNRq (n ) =

2 3L2 2 n . 2 ln (1 + ) 1 + 2n E{|m|} + 2 n m 2

If 1 then the dependence of SNRq on the messages characteristics is very small and SNRq can be approximated as SNRq = 3L2 . ln (1 + )
2

For practical values of = 255 and L = 256, SNRq = 38.1dB.


A First Course in Digital Communications 34/42

Chapter 4: Sampling and Quantization

8-bit Quantizer for the Gaussian-Distributed Message


60 50 40 30 SNR (dB) 20 10 0 10 20 30 40 90 80 70 60 50 40 30 Relative signal level 20log ( /m
10 m

law compander =255

Uniform quantization (no compading)

max

20 ) (dB)

10

One sacrices performance for larger input power levels to obtain a performance that remains robust over a wide range of input levels.
A First Course in Digital Communications 35/42

Chapter 4: Sampling and Quantization

SNRq with 8-bit -law quantizer (L = 256, = 255)


40

30

20 SNR (dB)

10

0 Gaussian Laplacian Gamma Uniform 80 60 40 20 Normalized signal power 10log (2) (dB)
10 n

10

20 100

Insensitive to variations in input signal power and also insensitive to the actual pdf model Both desirable properties.
A First Course in Digital Communications 36/42

Chapter 4: Sampling and Quantization

Dierential Quantizers
Most message signals (e.g., voice or video) exhibit a high degree of correlation between successive samples. Redundancy can be exploited to obtain a better SNRq for a given L, or conversely for a specied SNRq the number of levels L can be reduced:
1 2

Use the previous sample values to predict the next sample value and then transmit the dierence. Quantize and transmit the prediction error, e[n] = m[n] m[n].
onm lkji hg

m[n ]
oskr lqnop

e[ n ]

m[n ]

If |emax | = |mmax kmmax | = |1 k|mmax is less than mmax then the quantization noise power is reduced!
A First Course in Digital Communications 37/42

wi j} l| qnm lkjih wwi lkjnon   l~

osoon js lkr lqnop

wi j} l| { zypx qn wv uit

[ e n]

Chapter 4: Sampling and Quantization

Linear Predictor
z 1

m[n 1]

z 1

m[ n 2]

m[n p + 1]

m[n ]

...
w2

z 1

m[n p ]

m[n ]

Select {wi } to minimize the variance of p 2 e =E m[n] wi m[n i]


i=1 p p

wi E{m[n]m[n i]} +

prediction error: 2 = E{m2 [n]}


p

wi wj E{m[n i]m[n j]}.


38/42

i=1
A First Course in Digital Communications

i=1 j=1

...

w1

...

w p 1

wp

Chapter 4: Sampling and Quantization

Normal Equations (or the Yule-Walker Equations)


With Rm (k) = E{m[n]m[n + k]} the autocorrelation of {m[n]},
p 2 e p p

= Rm (0) 2
i=1

wi Rm (i) +
i=1 j=1

wi wj Rm (i j). wi

A First Course in Digital Communications

2 Take the partial derivative of e with respect to each coecient and set the results to zero to yield: Rm (0) Rm (1) Rm (2) Rm (p 1) Rm (1) Rm (0) Rm (1) Rm (p 2) Rm (2) Rm (1) Rm (0) Rm (p 3) . . . . .. . . . . . . . . . Rm (p + 1) Rm (p + 2) Rm (p + 3) Rm (0) w1 Rm (1) w2 Rm (2) w3 Rm (3) = . . . . . . .

wp

Rm (p)

39/42

Chapter 4: Sampling and Quantization

Reconstruction of m[n] from the Dierential Samples


Ignore the quantization error and look at the reconstruction of m[n] from the dierential samples e[n].
p

e[n] = m[n]
i=1 p 1 1 i

wi m[n i].
p 1

e(z

) = m(z

)
i=1

wi z m(z

) = m(z

) m(z

)
i=1

wi z i

1 = m(z 1 ) m(z 1 )H(z 1 ) m(z 1 ) = e(z 1 ). 1 H(z 1 )


e ( z 1 )
+

m ( z 1 )

e[ n ]

m[n ]

H ( z 1 )

A First Course in Digital Communications

m( z

+ m[n ]
H ( z 1 )
40/42

Chapter 4: Sampling and Quantization

Under quantization noise error, use DPCM to eliminate the eect of previous quantization noise samples.
e[ n ]

[ e n]

m[n ]

m[n ]

m[ n ]

+ +

m[n ]

m[n] = m[n] + e[n] = m[n] + (e[n] q[n]) = (m[n] + e[n]) q[n] = m[n] q[n].
A First Course in Digital Communications 41/42

[ e n]

m[n ]

Chapter 4: Sampling and Quantization

Pulse-Code Modulation (PCM)


A PCM signal is obtained from the quantized PAM signal by encoding each quantized sample to a digital codeword. In binary PCM each quantized sample is digitally encoded into an R-bit binary codeword, where R = log2 L + 1. Binary digits of a PCM signal can be transmitted using many ecient modulation schemes. There are several mappings: Natural binary coding (NBC), Gray mapping, foldover binary coding (FBC), etc.
D1 D2

D3

D4

D5

D6

D7

D8

D9

A First Course in Digital Communications

42/42

T1

T2

T3

T4

T5

T6

T7

T8

You might also like