Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital signal processing ETI265
Chapter 6
Sampling
We will more closely look into the sampling process. Specially, we look into the spectrum before and after sampling.
Digital Signal Processing
ETI265 Low passfilter
Digital sign. process.
A/D
Low passfilter
D/A
Chapter 6 Digital circuit
Sampling
Sampling
Reconstruction
We sample the input signal a time instants
t = nT = n
LTH September 2011
1 FT
T is the time between the samples and FT is the sampling rate (sampling frequency)
Bengt Mandersson Department of Electrical and Information Technology
Lund University
TV :
FT = 50 images / s
CD :
FT = 44100 Hz
Phone :
FT = 8000
Hz
1
2
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Example
Sampling.
x(t ) = cos(2π 400 {t )
Fs = 1000
F0
pages 385-386
gives x(n) = cos(2π
Sample the time continuous signal with a rate of Fs Hz by setting
t =n
T = 20 ms (48000 in studio equipment )
1 =n T FS
x ( n ) = x (t ) |
t =n
400 n)=cos(2π 0.4n) 1000 {
F0 = f 0 =0.4 Fs
1 FS
But also
x(n) =cos(2π 0.4n) = cos(2π (1 +0.4)n)= = cos(2π (−1 + 0.4)n) etc
The sampling Theorem If the highest frequency component in signal x(t) is Fmax, , and if we choose the sample rate Fs >2 Fmax, then we can reconstruct the frequency exact.
3
due to that n is an integer
⎧ 0 .4 + k We have the frequencies f 0 = ⎨ ⎩ − 0 .4 + k
4
k integer
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Example continued
What's happen if we choose to low sample rate
The spectra before sampling (the analog signal)
We try to illustrate this with the example below Now we assume two cosine terms in the input
Amplitude spectrum |X(F)| 1/2
- 1000
x(t ) = cos(2π 400t ) + 0.5cos(2π 800t ), Fs = 1000 400
- 500 - 400
F
1000
500
gives x(n)=cos(2π 0.4n)+ 0.5cos(2π 0.8n) 14243 cos( 2π ( −0.2 )n )
and after the sampling (the time-discrete signal) Amplitude spectrum
⎧ ± 0.4 + k The periodicity gives the frequencies ⎨ k integer ⎩ ± 0.2 + k
| X( f )|
1/2
-1
- 0.5
0.4
- 0.4
1
0.5
f=
One period
F Fs
The spectrum of the analog signal is (before sampling) Amplitude spectrum |X(F)| 1/2
Notice:
- 1000
The spectrum for a digital signal is periodic with the
500
F
1000
and after sampling (see also next page)
ω = 2π
f = 1,
400
- 500 - 400
Amplitude spectrum
| X( f )|
1/2
-1
- 0.5
0.4
- 0.4
0.5
1
One period
Aliasing distortion: We have a false peak at and in real frequency at
f=
F Fs
f = ±0.2
F = ± 200 Hz
5
6
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Conclusion
Illustration of the periodicity in the example above
We have peaks at all multiples of 1, i.e. , |X(F)|
fi , ± 1 + fi , ± 2 + fi , ± 3 + fi , ,
1/2
-
-
400
-
F
500
i.e.
|X(F+Fs)|
f i ± k , k integer
1/2
-
-
400
-
This is as we have seen before a general properties for time discrete signals. .
F
500
|X(F-Fs)| 1/2
-
-
400
-
F
500
Sum the figures above gives
Notice:
| X( f )| 1/2
-1
-
0.4
-
One period
7
0.5
1
F f= Fs
Spectrum of a time discrete signal is periodic with the period in frequency
f =1 ω=2π
in frequency i n angular frequency
8
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
We try to formulate this mathematically Definition of Fourier transform of a analogous signal
If we take care of all frequency components in the analog signal, we can argue that the total spectrum is
∞
∫ x ( t )e
X (F ) =
− j2π F t
dt
X ( f ) = FS ⋅ [... + X a (F + FS ) + X a (F) + X a (F − FS ) + ...]
t = −∞
We sample the signal
x ( n ) = x (t ) |
t =n
= FS ⋅
1 FS
X (F ) ≈
∑ x (n) e
− j 2π
F n Fs
n = −∞
144 42444 3 F X( ) =X( f ) FS
a
k =−∞
S
Of course, the Fourier transform must exist.
and approximate the integral with a sum ∞
∞
∑ X (F − k ⋅ F )
Notice: The spectrum is normally a complex function so the above sum is a sum of complex parts.
Δ {t 1 FS
We illustrate the spectra after sampling with some examples.
i.e.
X ( f ) = FS ⋅ X ( F ) Then, of course we have to make it periodical
9
10
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Example with aliasing distortion and phase addition Example with aliasing distortion and phase addition
continued
We must take care of the phase when we make the addition of the parts of the spectra
The spectra before sampling (the analog signal) Amplitude spectrum
0.5
Now we have to signals, one cosine and one sine. 0.5 e j π / 2
x (t ) = cos(2π 400t ) + sin(2π 600t ) = =
1 j 2π 400 t 1 − j 2π 400 t 1 1 − j 2π 600 t e + e + e j 2π 600 t − e 2 2 2j 2j { { 0.5 e − j π / 2
0 .5 e j π / 2
- 1000
|X(F)|
0 .5
0.5 e − j π / 2
1/2
- 500
400
- 400
1000 F
500
and after sampling (the time discrete signal ) Amplitude spectrum
gives after sampling with FS = 1000
0.5 + 0.5 e − j π / 2 =
2 − j π /4 e 2
0.5 + 0.5 e j π / 2 =
0.5 + 0.5 e j π / 2
x (n )=cos(2π 0.4n )+ sin(2π 0.6n ) 142 4 43 4 sin( 2π ( −0.4 )n ) = = − sin( 2π 0.4n )
-1
1 j 2π 0.4 n 1 − j 2π 0.4 n 1 j 2π 0.4 n 1 − j 2π 0.4 n e + e − e + e = 2 2 2j 2j 1 1 1 1 = e j 2π 0.4 n + e − j 2π 0.4 n + e j π / 2 e j 2π 0.4 n + e − j π / 2 e − j 2π 0.4 n 2 2 2 2424 123 1 3
0.5 + 0.5 e − j π / 2
-0.5
0.4
- 0.4
1 f
0.5
komplex amp
x(n)=cos(2π 0.4n)+ sin(2π 0.6n) 142 4 43 4 sin( 2π ( −0.4 )n ) = = − sin( 2π 0.4n )
=
1 j 2π 0.4 n 1 − j 2π 0.4 n 1 j π / 2 j 2π 0.4 n 1 − j π / 2 − j 2π 0.4 n e + e + e e + e e = 2 2 2 23 2424 1 1 3 complex amp
We still draw a figure with the magnitude spectra but add the phase in the figure (next page)
complex amp
1 1 1 1 = ( + e j π / 2 ) e j 2π 0.4 n + ( + e− j π / 2 ) e − j 2π 0.4 n = 2 42 24 1 42 43 4 1 42244 3 2 jπ / 4 e 2
2 − jπ / 4 e 2
= 2 cos( 2 π 0.4 n + π / 4) 11
2 j π /4 e 2
We have
=
komplex amp
|X(f)|
12
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Reconstruction (DA-conversion) (ideal reconstruction) page 387-388, 395-397
Ideal reconstruction, Block diagram (see also formula table)
The spectrum is periodic and then we must choose one period when we should make the analog signal. Chose
− 0.5 < f < 0.5
−π < ω < π
Y (F ) =
F F − s < F < s ( Hz ) 2 2
X( f )
We chose one period of
1 ⋅ X ( f ), FS
y (t )
Low pass filter.
1 ⋅ X ( f ), FS
FS F < F< S 2 2
i Hz
Block diagram over ideal reconstruction
Chose frequencies up to Fs/2.
Y (F ) =
− 0.5 < f < 0.5 −
using a low pass filter med (see formula table).
x ( n ) |n = FS ⋅t
by the low pass filter
− 0.5 < f < 0.5 −
FS F < F< S 2 2
i Hz
Then we have
Ya ,ut ( F ) =
1 X ( f ) H LP ( F ) Fs
This is a convolution and can be written (see appendix)
y (t ) =
sin(
∞
∑
n = −∞
x( n ) |n = FS t
π
T
π T
( t − n T ))
(t − nT ) 13
14
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Reconstruction using a sample-and-hold circuit
We end this chapter by showing one practical application
In practical D/A-conversion, a so called sample-and hold circuit is included and then we have a staircase signal after the D/A conversion.
Example (increasing the sampling rate, interpolation) x ( n ) = sin(2 π f 0 n ) = {... x ( −1) x (0) x (1) x (2) ...}
Given:
with f 0 = 0.4
We have now a new block diagram
Make y ( n ) = {... x ( −1) 0 x (0) 0 x (1) 0 x ( 2) ...}
Task:
and determine Y ( f ) . We put in a zeros between every sample (x-value).
Reconstruction using a sample-and-hold circuit
Solution: Start with the definition of the Fourier transform.
Y ( f ) = ∑ y ( n) e − j 2 π f
n
= { y (2n) = x(n), n = ...0,1,2,3..., let n' = n / 2, n = 2n'} =
n
= ∑ x ( n' ) e − j 2 π f
2 n'
= X (2 f )
n'
We have rescaling of the frequency axis. One period of Y(f) corresponds to two periods of X(f). | X( f )|
Amplitude spectrum 1/2
We have the output signal spectrum -1
Ya ,ut ( F ) = X ( f ) H SH ( F ) H LP ( F ) 1442443
- 0.5
Amplitude spectrum 1/2
The total analog filter is
Htotal (F ) = HSH (F ) HLP (F ) H SH ( F ) = T
s in π F T − e π FT 15
1
0.5
One period
H total ( F )
with
0.4
- 0.4
j2 π F
- 0.5
- 0.25 - 0.2
0.2
0.25
0.5
One period
T 2
Then, we have
y (n ) = sin(2 π 0.2 n ) + sin(2 π 0.3 n ) 16
|Y ( f ) |
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Appendix A, chapter 6 continued
Appendix A, chapter 6
Case 1: No aliasing:
Determining the spectrum after sampling
First we assume band limited signal Definition of sampling is Assume the frequency band of the input are bounded as
≡
xa (t) |t=nT =n / FT
F f = FT
x[n]
We now want to get a relation between the Fourier transforms of left and right sides.
Then, we have the same integration interval in both sides (left and right)
Put in the definition of inverse transform in both sides.
FT / 2 ∞
∫
X a (F ) e
n j 2π F FT
1/ 2
∫
dF =
F = −∞ j 2π F
X a (F ) e
n FT
FT / 2
∫
dF =
F = −∞
X a (F ) e
F = − FT / 2
n FT
1 dF = FT
FT / 2
∫
j 2π F
X(f ) e
j 2π F
X a (F ) e
F = −∞
X( f ) e
F = − FT / 2
n FT
1 dF = FT
FT / 2
j 2π
∫
X(f ) e
X (e j 2 π f ) = X (e j 2 π F / FT ) = FT X a ( F )
F n FT
dF
| F |≤
FT 2
Example |Xa(F)|
1
F = − FT / 2 -FT
-FT/2
The only difference between left and right sides is the integration interval. We now look at two cases.
0
FT/2
-1
-1/2
FT
F
|X(f)|
FT
0
1/2
17
1
f
18
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Appendix A, chapter 6 continued
Appendix A, chapter 6 continued
Case 2: Aliasing.
i.e.
X ( f ) = FT
No we assume that the signal is not band limited, i.e. now we have
X a ( F ) ≠ 0 for | F |≥
FT 2
∞
∑
k = −∞
X a ( F − K FT ) =
= FT ( ... X a ( F + FT ) + X a ( F ) + X a ( F − FT )...)
F = −∞ to F = ∞ . We divide this into subintervals. F = − FT / 2 to F = FT / 2
Integration in the left side is from
∞
∫
j 2π F
X a (F ) e
n FT
dF =
F =−∞
1 FT
FT 2
∫
X (e j 2 π F / FT ) e
j 2π
F n FT
dF
|Xa(F)|
F =− FT 2
Write left side as a sum of subintervals FT 2
∞
∑ ∫
k=−∞ F=−FT 2
FT 2
n FT
and identification gives the relation
dF FT
j 2π f n
F = − FT / 2
∞
∫
∫
X ( f ) e j 2π f n df
j 2π F
f = −1 / 2
∞
∫
FT 2
X a ( F ) = 0 for | F |≥
Xa (F − k FT ) e
∞
∫ ∑
F =−FT 2 k =−∞
j 2π ( F−k FT )
Xa (F − k FT ) e
j 2π F
n FT
n FT
dF =
dF =
1 FT
FT 2
∫
X(e j 2π F / FT ) e
F n FT
-FT
-FT/2
0
FT/2
dF
FT
1 FT
FT 2
∫
X (e j 2π F / FT ) e
F =−FT 2
j 2π
F n FT
dF
-1
-1/2
If X a ( F ) ≠ 0 for | F |≥
0
1/2
1
FT 2 then the terms in the sum will be
overlapped. This is called aliasing distortion. This can only be avoided by a pre-filter before the A/D-conversion. F / FT
) = FT
19
F
|X(f)|
F=−FT 2
and identification gives
X (e j 2 π f ) = X ( e j 2 π
j 2π
∞
∑
k = −∞
X a ( F − K FT )
20
f
dF
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Appendix A, chapter 6 continued Ideal reconstruction mathematically. j 2π f ) and compute the inverse transform. Select one period of X (e F j2 π ⎧1 X (e FT ) ⎪ ⎪ Ya ( F ) ≡ ⎨ FT ⎪ ⎪⎩0
| F |≤
FT 2
| F |>
FT 2
Inverse transform gives FT 2
ya (t ) =
∫
FT 2
∫
X a ( F )e j 2π F t dF =
F =− FT 2
F =− FT
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Appendix B Quantization error due to A/D conversion
F
j2 π 1 X (e FT ) e j 2π F t dF = F 2 T
page 403-408 Quantization of a sinusoidal signal
analogous signal
quantified signal
x a ( t ) = A sin( Ω 0 t ) Use b bits resolution in the quantizer Number of levels 2b Maximum amplitude A Maximum range 2A
Δ=
Quantization step FT 2
=
∫
F =− FT
1 F 2 T
∑ x(n)e
− j 2 π F FT n
e
j 2π F t
dF =
Mean quantization power
n
Pq = 1 = FT
1 = FT
FT 2
∑ x(n) ∫ n
∑ x[n] n
j 2π F (t −n
e
1 ) FT
dF =
π (t − n
1 ) FT
1 ) FT
π
21
Digital Signal Processing, Department of Electrical and Information Technology, LTH, Lund University
Sampling and D/A. Read the copies of the slides The book: Sampling page 385-386 Figures pages 388 and 391 Quantization page 403-408 Reconstruction page 387-388, 395-397 Sessions 6.4, 6.5 and 6.6 not included
23
(variance of an rectangular
,
probability density function)
sin (t − nT ) T = ∑ x[n] T π (t − nT ) n
Reading help chapter 6
Δ2 12
Average signal power
F =− FT 2
sin π FT (t − n
2 A 2b
A2 Ps = 2 SQNR (dB )= 10 log
(sinusoids with amplitude A)
Ps = 1.76+ 6b ≈ 6 number of bits Pq 22