Fundamentals of Digital Signal Processing

photohomoeopathAI and Robotics

Nov 24, 2013 (3 years and 6 months ago)

48 views

Fundamentals of Digital Signal Processing

Fourier Transform of continuous time signals










dt
e
t
x
t
x
FT
F
X
Ft
j

2
)
(
)
(
)
(








dF
e
F
X
F
X
IFT
t
x
Ft
j

2
)
(
)
(
)
(
with
t

in sec and
F

in Hz (1/sec).

Examples:







0
0 0
sinc
t
T
FT rect T FT





0
2
0
F
F
e
FT
t
F
j












0
2
1
0
2
1
0
2
cos
F
F
e
F
F
e
t
F
FT
j
j












Discrete Time Fourier Transform of sampled signals










n
fn
j
e
n
x
n
x
DTFT
f
X

2
]
[
]
[
)
(






2
1
2
1
2
)
(
)
(
]
[
df
e
f
X
f
X
IDTFT
n
x
fn
j

with
f
the digital frequency (no dimensions).

Example:



0
2
0
( )
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
(
)
(


f
X
f
X
2
1
2
1



f


f
1
1
2
1
2

1

)
(
f
X


we only define it on one period

f
1
2

)
(
f
X
1
2
t
F
j
e
t
x
0
2
)
(


n
j
s
s
F
F
e
nT
x
n
x
0
2
)
(
]
[



s
s
T
F
/
1

Sampled Complex Exponential: no aliasing

0
F
F
)
(
F
X
f
( )
X f
2
1

1
2
1. No Aliasing

2
0
s
F
F

2
s
F

2
s
F
0
f
s
F
F
f
0
0

digital frequency

t
F
j
e
t
x
0
2
)
(


n
j
s
s
F
F
e
nT
x
n
x
0
2
)
(
]
[



s
s
T
F
/
1

Sampled Complex Exponential: aliasing

0
F
F
)
(
F
X
f
( )
X f
2
1

1
2
2. Aliasing

0
2
s
F
F

2
s
F

2
s
F
0
f
0 0
0
s s
F F
f round
F F
 
 
 
 
digital frequency

t
F
j
e
t
x
0
2
)
(


0
2
[ ] ( )
j f n
s
x n x nT e

 
s
s
T
F
/
1

Mapping between Analog and Digital Frequency











s
s
F
F
round
F
F
f
0
0
0
Example

t
j
e
t
x
1000
2
)
(


kHz
F
s
3

Then:



analog frequency



FT:



digital frequency



DTFT: for

)
1000
(
)
(


F
F
X
FT

Hz
F
1000
0





0 0
1 1 1
0
3 3 3
s s
F F
F F
f round round
    


3
1
)
(


f
f
X
DTFT

2
1
|
|

f
Example

t
j
e
t
x
2000
2
)
(


kHz
F
s
3

Then:



analog frequency



FT:



digital frequency



DTFT: for

)
2000
(
)
(


F
F
X
FT

Hz
F
2000
0



3
1
)
(


f
f
X
DTFT

2
1
|
|

f




0 0
2 2 1
0
3 3 3
s s
F F
F F
f round round
     
Example

t
j
j
t
j
j
e
e
e
e
t
t
x






8000
1
.
0
2
1
8000
1
.
0
2
1
)
1
.
0
8000
cos(
)
(






kHz
F
s
3

Then:



analog frequencies



FT:



digital frequencies




DTFT

)
4000
(
)
4000
(
)
(
1
.
0
2
1
1
.
0
2
1





F
e
F
e
F
X
j
j
FT




0 1
4000,4000
F Hz F Hz
  
2
1
|
|

f




3
1
1
.
0
2
1
3
1
1
.
0
2
1
)
(





f
e
f
e
f
X
j
j
DTFT






4 4 4 1
0
3 3 3 3
1
f round
    


4 4 4 1
1
3 3 3 3
( 1)
f round
         
Linear Time Invariant (LTI) Systems and z
-
Transform

]
[
n
x
]
[
n
y
]
[
n
h
If the system is LTI we compute the output with the convolution:








m
m
n
x
m
h
n
x
n
h
n
y
]
[
]
[
]
[
*
]
[
]
[
If the impulse response has a finite duration, the system is called FIR
(Finite Impulse Response):

]
[
]
[
...
]
1
[
]
1
[
]
[
]
0
[
]
[
N
n
x
N
h
n
x
h
n
x
h
n
y















n
n
z
n
x
n
x
Z
z
X
]
[
]
[
)
(
Z
-
Transform

Facts:

)
(
)
(
)
(
z
X
z
H
z
Y

]
[
n
x
]
[
n
y
)
(
z
H
Frequency Response of a filter:

f
j
e
z
z
H
f
H

2
)
(
)
(


Digital Filters

)
(
z
H
]
[
n
x
]
[
n
y
Ideal Low Pass Filter

f
2
1
2
1

)
(
f
H
f
2
1
2
1

)
(
f
H

P
f
P
f
passband

constant magnitude
in passband…

… and linear phase

A
Impulse Response of Ideal LPF







P
P
f
f
fn
j
fn
j
ideal
df
Ae
df
e
f
H
n
h


2
2
2
1
2
1
)
(
]
[
Assume zero phase shift,




n
f
sinc
Af
n
h
P
P
ideal
2
2
]
[

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.1
1
P
f
A


Non Ideal Ideal LPF

The good news is that for the Ideal LPF

0
]
[
lim



n
h
ideal
n
n
]
[
n
h
L

L
n
L
2
L
]
[
n
h
Frequency Response of the Non Ideal LPF

P
f
STOP
f
pass

stop

stop

f
transition region

attenuation

ripple

|
)
(
|
f
H
1
1


1
1


2

LPF specified by:



passband frequency



passband ripple or



stopband frequency



stopband attenuation or

P
f
1

dB

R
P
1
1
1
1
10
log
20





STOP
f
2

dB

R
2
S

10
log
20

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.

1
f
2
f
2
1
attenuation

ripple

|
)
(
|
f
H
1
1


1
1


2









1 2 3 3 1 2
,0,,,/,1,1,0,0,,
h firpm N f f f f w w

impulse response



]
[
],...,
0
[
N
h
h
h

1
f
2
f
2
1
3

f
0
Linear Interpolation

1
1
/
w

2
/
w

The total impulse response length
N
+1 depends on:



transition region



attenuation in the stopband

1
f
2
f
|
)
(
|
f
H
2

1
2
f
f
f





N
f
1
~
22
)
(
log
20
2
10


Example
:

we want

Passband: 3kHz

Stopband: 3.5kHz

Attenuation: 60dB

Sampling Freq: 15 kHz

Then
: from the specs

We determine the order the filter


30
1
0
.
15
0
.
3
5
.
3




f
82
30
~
22
60


N
Frequency response

0
0.1
0.2
0.3
0.4
0.5
-100
-80
-60
-40
-20
0
20
magnitude
digital frequency
dB
0
0.1
0.2
0.3
0.4
0.5
-120
-100
-80
-60
-40
-20
0
20
magnitude
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
20
magnitude
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
f
0
0.1
0.2
0.3
0.4
0.5
-80
-70
-60
-50
-40
-30
-20
-10
0
10
magnitude
digital frequency
dB
OK!!!

General FIR Filter of arbitrary Frequency Response

]
,...,
,
[
]
,...,
,
,
0
[
1
0
2
1
M
M
H
H
H
H
f
f
f
f


0
1
f
2
f
3
f
1

M
f
2
1

M
f
0
H
1
H
2
H
3
H
1

M
H
M
H
Weights for Error:

1
w
2
w
2
/
)
1
(

M
w
]
,...,
,
[
2
/
)
1
(
2
1


M
w
w
w
w
Then apply:



,/,,
M
h 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.2
f
 
( ) 0
H f

0.25 0.5
f
 
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 magnitudes

Df
=0.25
-
0.2;


% transition region

N
=ceil(A/(22*
Df
));
% first guess of order

h=firpm(
N
, [
fp
,
fs
]/0.5,
M
);
% impulse response


40
A dB

0
0.1
0.2
0.3
0.4
0.5
0
0.2
0.4
0.6
0.8
1
1.2
1.4
magnitude
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
37
N

To improve it:

1.
Increase order

2.
Add weights

0
0.2
0.25
0.5
f
40
A dB

1
w

0.2
w

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.5
0
0.2
0.4
0.6
0.8
1
1.2
1.4
magnitude
digital frequency
0
0.1
0.2
0.3
0.4
0.5
-160
-140
-120
-100
-80
-60
-40
-20
0
20
100
N

dB