0% found this document useful (0 votes)
9 views35 pages

Chapter 4 - p1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views35 pages

Chapter 4 - p1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Chapter 4

Changing the Sampling Rate in DSP


► Downsampling and decimation
► Upsampling and interpolation
► Noninteger rate change
► Multi-rate processing

2
Downsampling
Downsampling by an integer factor M is equivalent to sampling the discrete-time signal x[n]
with sampling period M .
x[n] xd[n] = x[Mn]
M
X (ej ω ) X d(ej ω )

Downsampling

To understand what happens in the frequency domain, we can think that we’re sampling the
original continuous-time signal x c (t) with sampling period Td = MT :

xd[n] = x[M n] = xc (nM T )

3
Downsampling: frequency domain interpretation
Sampling x c (t) with sampling period Td = M T results in

Conclusion: X(e jω ) is stretched by a factor of M (ω/M), and there will be replicas of the spectrum
with period 2π/M. 4
Downsampling: frequency domain interpretation
Example of downsampling with M = 2 i.e., Td = 2T.
Impulse sampling interpretation:
X c (jΩ)

− Tπ π
T

−ΩN ΩN Ω
X (ej ω )
1
T
Sampling period T

− Tπ π
T

− 2π −ΩN ΩN 2π Ω
T T

X d (e )

1
= 1 Downsampled by 2
Td MT
Td = M T

− Tπd π
Td

− 2π
Td
−ΩN ΩN 2π
Td

5
After downsampling spectrum replicas appear with period 2π/Td
Downsampling: frequency domain interpretation
Same example of downsampling with M = 2 i.e., Td = 2T.
Discrete-time interpretation:
X c (j Ω)

−ΩN ΩN Ω
X (ej ω )
1
T Oversampled by 2

−π π
− 2π − ΩN T ΩN T 2π ω = ΩT
X d (ej ω )
1
= 1
Downsampled by 2
Td MT

−π π
− 2π − ΩN Td ΩN Td 2π ω = ΩTd = ΩM T

To obtain the spectrum we discrete time, we just need to use the change of variables ω = ΩT
6
and ω = ΩTd
Downsampling: frequency domain interpretation
Downsampling may lead to spectrum overlapping (aliasing distortion).
Example of downsampling with M = 3 i.e., Td = 3T.
Xc(jΩ)

−ΩN ΩN Ω
X (ej ω )
1
T Oversampled by 2

−π π
− 2π − ΩN T ΩN T 2π ω = ΩT

X d (ej ω )
1 = 1
Td MT
Downsampled by 3

− 2π − Ω N Td −π π Ω N Td 2π ω = ΩT d

7
Decimation
Similarly to sampling, it is common to employ an anti-aliasing filter before downsampling in order to
minimize aliasing.
Pre-filtering followed by downsampling is called decimation.

x[n] Lowpass filter x˜[n] xd[n] = x̃[M n]


Gain = 1 M
Cutoff = π/M

Anti-aliasing filter Downsampling

Decimator∞
j ΩT 1 2πk
x[n] ⇐⇒X(e )= � X c (j Ω − ) (from sampling)
T k=− ∞ T

x̃[n] ⇐⇒ X̃ ( ej ΩT ) = H ( ej ΩT ) X ( ej ΩT ) (LTI output)


M −1
1
x d[n] = x̃[nM ] ⇐⇒ � X˜ ( e j (ΩT −2π T )/M ) (downsampling by M )
M m =0 8
Decimation: frequency domain interpretation
Decimation with M = 3 i.e., Td = 3T .
X (ej ω )
1
T Oversampled by 2

−π π
− 2π − ΩN T ΩN T 2π ω = ΩT

H(ejω )
1

− 2π − π/M π/M 2π ω = ΩT
X̃ (ej ω )
1
T

−π π
− 2π − π/M π/M 2π ω = ΩT
X d (ej ω )
1
= 1
Td MT
Downsampled by 3

π
9
− 2π −π 2π ω = ΩTd
Interpolation
Interpolation is used to increase the sampling rate by an integer factor L.
x[n] x e[n] Lowpass filter x i [n]
L Gain = L
Cutoff = π/L
Upsampling Interpolation filter
x[n/L], 0,± L, ± 2L, ...
x e[n] = ( (after upsampling)
0, otherwise
In the frequency domain:

X e ( ej ω ) = � 𝑥𝑥𝑒𝑒 [𝑛𝑛]𝑒𝑒 −𝑗𝑗𝜔𝜔𝑛𝑛 (definition of DTFT)
𝑘𝑘=−∞

=� 𝑥𝑥[𝑛𝑛/𝐿𝐿]𝑒𝑒 −𝑗𝑗𝜔𝜔𝑛𝑛 (from xe[n] equation above)


𝑛𝑛=0,±𝐿𝐿,±2𝐿𝐿,…

� 𝑥𝑥[𝑘𝑘]𝑒𝑒 −𝑗𝑗𝜔𝜔𝑘𝑘𝑘𝑘
= 𝑘𝑘=−∞ (change of variable: k = n/L)
10
= X( e j ω L ) (from DTFT equation with ωL)
Interpolation: frequency domain
interpretation
Example of interpolation with L = 2
X (ej ω )
1
T

−π π
− 2π − ΩN T ΩN T 2π ω = ΩT
X e (ej ω ) = X (ej ωL )
1
T
Upsampled by 2

− 2π −π − ΩN T ΩN T π 2π
2 2 ω= ΩT
L
H(ejω )
1

− 2π − π/L π/L 2π ω= ΩT
L

X i (ej ω ) = H (ej ω )X e (ej ω )


L
T

− 2π − ΩN T ΩN T 2π ω= ΩT
2 2 L 11
Practical interpolation filters

► Similarly to what we saw in reconstruction (D-to-C), the ideal lowpass filter is not
practical. Hence, we must use practical interpolation filters such as ZOH, linear
interpolator, or cubic spline.
► One important difference: The interpolation filter used in reconstruction to convert
from discrete-time to continuous-time was an analog filter (a continuous-time filter). The
interpolation filter used for upsampling is realized in discrete-time (in DSP). Therefore, we
have more flexibility.

12
Example of interpolation
► The original signal has maximum frequency Ω N = 1 rad/s.
► From the Nyquist-Shannon theorem, we need Ωs > 2Ω N in order to be able to achieve perfect
reconstruction. Or equivalently, T < π s.
► Sampling period is T = π

Samples
ZOH
Linear interp.
Truncated sinc

Upsampled
by L = 2
13
Example of interpolation
Same example as before, but now sampling period is T = 0.4π.

Samples
ZOH
Linear interp.
Truncated sinc

Upsampled
by L = 2

14
Truncated sinc filter had 11 coefficients, while ZOH had 2 and linear interpolator had 3.
► In the first example the continuous-time signal was sampled at the Nyquist rate, whereas in the
second example the continuous-time signal was oversampled by 2.5.
► In both cases, we upsample by a factor of 2 and use practical reconstruction filters: ZOH, a linear
interpolator, and a truncated sinc with 11 samples.
► The ZOH filter only has two coefficients, the linear interpolator has three coefficents, and the
truncated sinc has 11 coefficients.
► Although we use the same filters in both examples, the interpolated sequences are much closer to the
original continuous-time signal in the second example. This illustrates how oversampling can help
the interpolation filters.
► In these examples, the linear interpolator offers that best performance vs complexity trade-off, as it
achieves performance close to the truncated sinc, but only uses 3 samples.
► Even with high oversampling, we see that the truncated sinc filter didn’t achieve perfect
reconstruction. This is a consequence of the Gibbs phenomenon, discussed in lecture 1. Recall
that a truncated sinc will produce a DTFT that is different from the ideal lowpass filter.
Specifically, the DTFT of the truncated sequence will have oscillations, which will affect the
signal and will not suppress the spectrum replicas centered at multiples of 2π. Using an even larger
sequence (sinc with more samples) would not help much, since the ripples would only become
more rapid, but their amplitude would not decrease. 15
In Matlab
Sampled signal with period T
>> T = 0.5*pi
>> t = -20:T:20
>> x = cos(t/2) - s i n ( t ) + cos(t/2-pi/4) - sin(t/4-deg2rad(154)); % Sampled
s igna l
Upsample
>> xu = upsample(x, L) % Upsample
Interpolation filters
>> hZOH = [1 1] % ZOH
>> h l i n = [1/2 1 1/2] % Linear interpolator
>> hsinc = s inc (- (5:5)/ 2) % truncated s inc with 11 samples
Interpolate
>> yzoh = fil ter( hZ OH, 1 , xu)
>> y l i n = f i l t e r ( h l i n , 1 , xu)
>> ysinc = f i l t e r ( h s i n c , 1 , xu)
% since these f i l t e r s are FIR we could also have used the conv command
16
Interpolation/Decimation by a non-integer factor
► We have seen how to increase the sampling period by an integer factor M and how to decrease
the sampling period by an integer factor L
► By cascading interpolation and decimation we can change the sampling period by a non-
integer factor M/L.
Cascading interpolation and decimation

x[n] Lowpass filter Lowpass filter x̃[n] y[n]


x u [n] x i [n]
L Gain = L Gain = 1 M
Cutoff = π/L Cutoff = π/M

Interpolator Decimator
T T T T TM
Sampling L L L L

Period

Equivalent diagram
Lowpass filter
x[n] xu [n] Gain = L x˜u[n] y[n]
L Cutoff = M
min(π/L, π/M )
Sampling T T TM 17
T
Period L L L
Example
► Let’s combine the examples we saw earlier with L = 2 and M = 3. Recall that with
M = 3, there would be aliasing if we didn’t use the anti-aliasing filter.
► The filter cutoff is min(π/2, π/3) = π/3.
X (ej ω )
1
T

−π π
− 2π − ΩN T ΩN T 2π ω = ΩT

X u (ej ω ) = X (ej ωL )
1
T Upsampled by 2

− 2π −π ΩN T ΩN T π 2π
− 2 ω= ΩT
2 L


H(e )
L

− 2π − π/3 π/3 2π ω= ΩT
L 18
Example
continuing...
X̃u (ej ω )
L
T

−π π
− 2π − π/3 π/3 2π ω= ΩT
L


Y (e )
L
M T Downsampled by 3

− 2π −π π 2π ω= ΩTM
L

The resulting signal has sampling period MT/L = 3T/2. Note that aliasing was prevented by selecting
19
the cutoff frequency min(π/2, π/3) = π/3.
Multirate processing
In practice, it is common to have parts of the system operating at one sampling rate and other parts
operating at a different sampling rate.
► Interchanging filtering and downsampling
► Interchanging filtering and upsampling
► Multi-stage decimation
► Multi-stage interpolation
► Polyphase decomposition

20
Interchanging filtering and downsampling
These two systems are equivalent i.e., y1[n] = y2[n]

x[n] x1[n] y1[n]


M H(z)

Downsampling Filter

x[n] x2[n] y2[n]


H (zM ) M

Filter Downsampling

To move the filter before downsampling by M , we must stretch its frequency response by a
factor of M : H ( zM ) H ( ej ωM ) .
𝑧𝑧 = 𝑒𝑒 j ω 21
Proof:
Staring with the second system: X 2 (e jω ) = H(e j ω M )X(e j ω ). Now we can apply the equation for
downsampling to obtain Y2(ejω )
M −1
1
Y2(e j ω) = � X 2(e j (ω/M −2π m ) )
M m =0
M −1
1
= � X ( e j (ω/M −2π m ) ) H ( ej(ω−2πm) )
M m =0
M −1
1
= H(e j ω) � X ( e j (ω/M −2π m ) )
M m =0
(periodicity of the DTFT =⇒ H(e j(ω−2πm) ) = H(e jω ))
M −1
1
= H(e j ω) � X ( e j (ω/M −2π m ) )
M m =0

= H ( ej ω ) X 1( ej ω ) = Y1( ej ω )
22
Comments on stability:
Note that if H(z) is a rational z-transform with poles {p1,p2,...,pN } and zeros
{ z1,z2,...,zR } :

Then H ( zM ) will be

If H(z) is stable and causal, the poles of H(z M ) will lie inside the unit circle, and therefore
H ( zM ) will also be stable.
Similarly, if H(z) is anti-causal and stable, the poles of H(z M ) will lie outside the unit circle, and
therefore H(z M ) will also be stable.

23
Interchanging filtering and interpolation
These two systems are equivalent i.e., y1[n] = y2[n]

x[n] x1[n] y1[n]


H ( z) L

Filter Upsmapling

x[n] x2[n] y2[n]


L H(zL)

Upsampling Filter

Proof:
Top diagram:
Y1(ejω ) = X 1 (e j ω L ) = X(e j ω L ) H( e j ω L )
Bottom diagram:
Y2(ejω ) = X 2 (e jω )H(e j ω L ) = X(e j ω L ) H( e j ω L )
24
Multi-stage decimation
Suppose we want to decimate by a factor M = 20. The cutoff frequency of the lowpass filter would be
π/20.
higher complexity
Sharp filter =⇒ long impulse response =⇒ higher cost
higher power consumption
It’s more efficient to use several decimation stages

x[n] H1 (z) H2 (z) y[n]


M1 M2

Decimator 1 Decimator 2

Interchanging filter and downsampling results in the equivalent system:

x[n] y[n]
H 1(z)H 2(zM 1 ) (M 1 M 2 )

► The equivalent downsampling factor is M = M 1 M 2 .


► Design H 1 (z) and H 2 (z) so that H 1 (z)H 2 (z M 1 ) has the desired frequency response. 25
Multi-stage interpolation
The same rationale applies to interpolation

x[n] y[n]
L1 H 1 (z) L2 H 2 (z)

Interpolator 1 Interpolator 2

Interchanging filter and downsampling results in the equivalent system:

x[n] y[n]
(L 1 L 2 ) H 1(zL 2 )H 2(z)

► The equivalent upsampling factor is L = L1L2.


► Design H 1 (z) and H 2 (z) so that H 1 (z L 2 )H 2 (z) has the desired frequency response.
26
Polyphase decomposition
What if the filter is placed before downsampling?

x[n] x˜[n] y[n]


H(z) M

► To interchange filter and downsampling in this case, we’d need to express H(z) as some
G( zM ) . Generally not easy.
► Practical problem: this implementation wastes computation. All samples of the output of H(z)
are calculated, but only 1 out of M is used after downsampling.
► If H(z) is FIR of length N , there are N multiplications per sample. Downsampling by M
discards M − 1 samples every M samples.

27
Polyphase decomposition
We can decompose any given sequence h[n] into M subsequences such that

h[n + k], n integer multiple of M


h k[n] = ( ,k = 0,1,...,M − 1
0, otherwise

It follows that
M −1 M −1
−k
h[n] = � h k[n − k] ⇐⇒ H(z) = � H k(z)z
k=0 k=0

28
Polyphase decomposition
Example of decomposition with M = 2
h[n]

h1[n]

h2[n]

29
Polyphase decomposition
We can downsample hk[n] in order to discard the zero samples
ek [n] = hk[M n] ⇐⇒ E k( 𝑧𝑧 𝑀𝑀 ) = Hk ( z) (upsamling by M)
The subsequences ek[n] are called the polyphase components of h[n]
h[n]

e1 [n] = h1 [2n]

e2 = h2[2n]

30
Polyphase decomposition
How to recover h[n] from e0[n], ...,eM −1[n]?
1. Upsample ek [n] by M , and we’re back with hk[n]
2. Delay by k and add
In terms of the z-transform:
M −1
H ( z) = � E k (z M)z −k

k=0

x[n] E 0( zM )

z−1
y[n]
E 1( zM ) +
z−1
..
z−1
E M − 1( zM )

31
H ( z)
Polyphase decimation
Back to the original problem: how to interchange filter and downsampling?

x[n] x̃[n] y[n]


H ( z) M

Using the polyphase decomposition of H(z)

x[n] E 0( zM )

z−1
y[n]
E 1( zM ) + M
z−1
..
z−1
E M − 1( zM )
32
H ( z)
Polyphase decimation
First interchange sum and downsampling:

x[n] E 0( zM ) M

z−1
y[n]
E 1( zM ) M +
z−1
.. ..
z−1
E M − 1( zM ) M

33
Polyphase decimation
Now it is easy to interchange E k( z M ) with downsampling resulting in the filters E k( z )

x[n] M E 0 (z)

z−1
y[n]
M E 1 (z) +
z−1
..
z−1
M E M − 1( z)

Computation: Each polyphase filter Ek (z) requires N/M multiplications, which are realized at the
lower rate (higher sampling period) T M .
Similarly for polyphase interpolation (Textbook section 4.7.5) 34
Summary
► Downsampling by an integer factor M stretches the discrete-time spectrum by a factor M and causes
replicas of the spectrum to appear at 2π/M . The amplitude of the spectrum is attenuated by M
► It’s often easier to think of downsampling as sampling the original continuous-time signal with a
sampling period Td = MT
► Anti-aliasing filtering followed by downsampling is called decimation
► Upsampling by an integer factor L compresses the discrete-time spectrum by a factor L. The
interpolation filter is assumed to have gain L, so the spectrum amplitude is scaled by L
► We can achieve non-integer sampling rate changes by cascading interpolation and
decimation stages
► For large downsampling/uspsampling factors, it’s generally more efficient to realized
multistage decimation/interpolation
► Polyphase decomposition allows efficient implementation of filtering followed by
downsampling and upsampling followed by filtering.

35

You might also like