Fundamentals of Digital Signal Processing
description
Transcript of Fundamentals of Digital Signal Processing
Fundamentals of Digital Signal Processing
Fourier Transform of continuous time signals
dtetxtxFTFX Ftj 2)()()(
dFeFXFXIFTtx Ftj 2)()()(
with t in sec and F in Hz (1/sec).
Examples:
0 0 0sinct
TFT rect T FT
02 0 FFeFT tFj
021
021
02cos FFeFFetFFT jj
Discrete Time Fourier Transform of sampled signals
n
fnjenxnxDTFTfX 2][][)(
21
21
2)()(][ dfefXfXIDTFTnx fnj
with f the digital frequency (no dimensions).
Example:
020( )j f n
k
DTFT e f f k
since, using the Fourier Series,2( ) j nt
k n
t k e
Property of DTFT
• f is the digital frequency and has no dimensions
• is periodic with period f = 1. )1()( fXfX
21
21 f
f11
2
12
1
)( fX
• we only define it on one period
f12
)( fX
12
tFjetx 02)( nj
ssF
F
enTxnx02)(][
ss TF /1
Sampled Complex Exponential: no aliasing
0F F
)(FX
f
( )X f
21
12
1. No Aliasing20
sFF
2sF
2
sF0f
sFFf 0
0 digital frequency
tFjetx 02)( nj
ssF
F
enTxnx02)(][
ss TF /1
Sampled Complex Exponential: aliasing
0FF
)(FX
f
( )X f
21
12
2. Aliasing 0 2sF
F
2sF
2
sF0f
0 00
s s
F Ff roundF F
digital frequency
tFjetx 02)( 02[ ] ( ) j f nsx n x nT e
ss TF /1
Mapping between Analog and Digital Frequency
ss FFround
FFf 00
0
Example
tjetx 10002)( kHzFs 3
Then:
• analog frequency
• FT:
• digital frequency
•DTFT: for
)1000()( FFX FT
HzF 10000
0 0 1 1 10 3 3 3s s
F FF Ff round round
31)( ffX DTFT 2
1|| f
Example
tjetx 20002)( kHzFs 3
Then:
• analog frequency
• FT:
• digital frequency
•DTFT: for
)2000()( FFX FT
HzF 20000
31)( ffX DTFT 2
1|| f
0 0 2 2 10 3 3 3s s
F FF Ff round round
Example
tjjtjj eeeettx 80001.02180001.0
21)1.08000cos()(
kHzFs 3
Then:
• analog frequencies
• FT:
• digital frequencies
•DTFT
)4000()4000()( 1.0211.0
21 FeFeFX jj
FT
0 14000 , 4000F Hz F Hz
21|| f 3
11.021
311.0
21)( fefefX jj
DTFT
4 4 4 10 3 3 3 31f round
4 4 4 11 3 3 3 3( 1)f round
Linear Time Invariant (LTI) Systems and z-Transform
][nx ][ny][nh
If the system is LTI we compute the output with the convolution:
m
mnxmhnxnhny ][][][*][][
If the impulse response has a finite duration, the system is called FIR (Finite Impulse Response):
][][...]1[]1[][]0[][ NnxNhnxhnxhny
n
nznxnxZzX ][][)(
Z-Transform
Facts:
)()()( zXzHzY
][nx ][ny)(zH
Frequency Response of a filter:
fjezzHfH 2)()(
Digital Filters
)(zH][nx ][ny
Ideal Low Pass Filter
f21
21
)( fH
f21
21
)( fH
Pf
Pf
passband
constant magnitude in passband…
… and linear phase
A
Impulse Response of Ideal LPF
P
P
f
f
fnjfnjideal dfAedfefHnh 222
1
21
)(][
Assume zero phase shift,
nfsincAfnh PPideal 22][
This has Infinite Impulse Response, non recursive and it is non-causal. Therefore it cannot be realized.
-50 -40 -30 -20 -10 0 10 20 30 40 50-0.05
0
0.05
0.1
0.15
0.2
n
fp=0.1
[ ]h n
n
0.11
PfA
Non Ideal Ideal LPF
The good news is that for the Ideal LPF0][lim
nhidealn
n
][nh
L L
nL2L
][nh
Frequency Response of the Non Ideal LPF
Pf STOPf
passstop stop
f
transition region
attenuation
ripple
|)(| fH11
11
2
LPF specified by:
• passband frequency
• passband ripple or
• stopband frequency
• stopband attenuation or
Pf
1 dB RP 1
111
10log20
STOPf
2 dB R 2S 10log20
Best Design tool for FIR Filters: the Equiripple algorithm (or Remez). It minimizes the maximum error between the frequency responses of the ideal and actual filter.
1f 2f 21
attenuation
ripple
|)(| fH11
11
2
1 2 3 3 1 2, 0, , , / , 1,1,0,0 , ,h firpm N f f f f w w
impulse response ][],...,0[ Nhhh
1f 2f 21
3 f0
Linear Interpolation
11/ w
2/ w
The total impulse response length N+1 depends on:
• transition region
• attenuation in the stopband
1f 2f
|)(| fH
2
12 fff
N
f 1~ 22)(log20 210
Example:
we want
Passband: 3kHz
Stopband: 3.5kHz
Attenuation: 60dB
Sampling Freq: 15 kHz
Then: from the specs
We determine the order the filter
301
0.150.35.3 f
8230~ 2260 N
Frequency response
0 0.1 0.2 0.3 0.4 0.5-100
-80
-60
-40
-20
0
20magnitude
digital frequency
dB
0 0.1 0.2 0.3 0.4 0.5-120
-100
-80
-60
-40
-20
0
20magnitude
digital frequency
dB
N=82
N=98
Example: Low Pass Filter
0 0.1 0.2 0.3 0.4 0.5-120
-100
-80
-60
-40
-20
0
20magnitude
digital frequency
dB
Passband f = 0.2
Stopband f = 0.25 with attenuation 40dB
Choose order N=40/(22*(0.25-0.20))=37
| ( ) |H f
f
Almost 40dB!!!
Example: Low Pass Filter
Passband f = 0.2
Stopband f = 0.25 with attenuation 40dB
Choose order N=40 > 37
| ( ) |H f
f0 0.1 0.2 0.3 0.4 0.5
-80
-70
-60
-50
-40
-30
-20
-10
0
10magnitude
digital frequency
dB
OK!!!
General FIR Filter of arbitrary Frequency Response
],...,,[],...,,,0[
10
21
M
M
HHHHffff
01f 2f 3f 1Mf 2
1Mf
0H1H
2H
3H 1MH MH
Weights for Error:
1w2w
2/)1( Mw
],...,,[ 2/)1(21 Mwwww
Then apply:
, / , ,Mh firpm N f f H w
… and always check frequency response if it is what you expect!
Example: ( ) 1/ sinc( )H f f for 0 0.2f
( ) 0H f 0.25 0.5f
0 0.2 0.25 0.5 f
fp=0:0.01:0.2; % vector of passband frequencies
fs=[0.25,0.5]; % stopband frequencies
M=[1./sinc(fp), 0, 0]; % desired magnitudesDf=0.25-0.2; % transition regionN=ceil(A/(22*Df)); % first guess of orderh=firpm(N, [ fp, fs]/0.5,M); % impulse response
40A dB
0 0.1 0.2 0.3 0.4 0.50
0.2
0.4
0.6
0.8
1
1.2
1.4magnitude
digital frequency
0 0.1 0.2 0.3 0.4 0.5-90
-80
-70
-60
-50
-40
-30
-20
-10
0
10
not very good here!
dB
37N
To improve it:
1. Increase order
2. Add weights
0 0.2 0.25 0.5 f
40A dB
1w 0.2w
w=[1*ones(1,length(fp)/2), 0.2*ones(1, length(fs)/2)];
h=firpm(N, [fp, fs]/0.5,M,w);
0 0.1 0.2 0.3 0.4 0.50
0.2
0.4
0.6
0.8
1
1.2
1.4magnitude
digital frequency
0 0.1 0.2 0.3 0.4 0.5-160
-140
-120
-100
-80
-60
-40
-20
0
20
100N dB