You are on page 1of 26

Fundamentals of Digital Signal Processing

Fourier Transform of continuous time signals


X ( F )  FT  x(t )   x (t ) e  j 2 Ft
dt


x(t )  IFT  X ( F )   X ( F ) e j 2 Ft
dF


with t in sec and F in Hz (1/sec).


Examples:

FT rect     T sinc  FT 
t
T0 0 0

FT e  F  F 
j 2 F0 t
0

FT  cos 2 F0t     12 e j   F  F0   12 e  j   F  F0 
Discrete Time Fourier Transform of sampled signals

X ( f )  DTFT  x[n]   x[ n ]e  j 2 fn

n  

x[n]  IDTFT  X ( f )   1 X ( f )e j 2 fn df
1
2

2

with f the digital frequency (no dimensions).

Example:



DTFT e j 2 f0n    ( f  f 0  k)
k 

since, using the Fourier Series,


 

  (t  k )   e
k  n 
j 2 nt
Property of DTFT

• f is the digital frequency and has no dimensions


• X ( f )  X ( f  1) is periodic with period f = 1.
X(f )

 
1
1 f
1 
2
1
2

• we only define it on one period  12  f  1


2
X(f )

f
1 1

2 2
Sampled Complex Exponential: no aliasing

F0
j 2 n
j 2 F0 t x[n]  x(nTs )  e Fs

x(t )  e
Fs  1 / Ts

Fs
1. No Aliasing F0 
2

X (F ) X(f )

Fs F0 Fs
F f


1 f0 1
2 2 2 2

F0
digital frequency f 0 
Fs
Sampled Complex Exponential: aliasing

F0
j 2 n
j 2 F0 t x[n]  x(nTs )  e Fs

x(t )  e
Fs  1 / Ts

Fs
2. Aliasing F0 
2

X (F ) X(f )

F
F
 s
Fs F0 1 f0 1
f
2 2 
2 2

F0 F 
digital frequency f0   round  0 
Fs  Fs 
Mapping between Analog and Digital Frequency

x(t )  e j 2 F0t x[n]  x(nTs )  e j 2 f0 n


Fs  1 / Ts

F0  F0 
f0   round  
Fs  Fs 
Example

x(t )  e j 2 1000t
Fs  3kHz

Then:
• analog frequency F0  1000 Hz

• FT: X FT ( F )   ( F  1000)
• digital frequency f0  F0
Fs  round  
F0
Fs
1
3  round  13   1
3

•DTFT: X DTFT ( f )    f  13  for | f |


1
2
Example

x(t )  e j 2 2000t
Fs  3kHz

Then:
• analog frequency F0  2000 Hz

• FT: X FT ( F )   ( F  2000)
• digital frequency
f0  F0
Fs  round  
F0
Fs
2
3  round  23    13

•DTFT: X DTFT ( f )    f  13  for | f | 1


2
Example

x(t )  cos(8000 t  0.1 )  12 e j 0.1 e j 8000 t  12 e  j 0.1 e  j 8000 t


Fs  3kHz

Then:
• analog frequencies F0  4000 Hz , F1   4000 Hz

• FT: X FT ( F )  12 e j 0.1  ( F  4000)  12 e  j 0.1  ( F  4000)

• digital frequencies
f 0  43  round  43   43  1  1
3

f1   43  round   43    43  (1)   13

•DTFT X DTFT ( f )  12 e j 0.1   f  13   12 e  j 0.1   f  13  | f | 1


2
Linear Time Invariant (LTI) Systems and z-Transform

x[n] y[n]
h[n]

If the system is LTI we compute the output with the convolution:



y[n]  h[n] * x[n]   h[m]x[n  m]
m  

If the impulse response has a finite duration, the system is called FIR
(Finite Impulse Response):

y[n]  h[0]x[n]  h[1]x[n  1]  ...  h[ N ]x[n  N ]


Z-Transform

X ( z )  Z  x[n]   x[ n ] z n

n  

Facts:

x[n] y[n]
H (z )
Y ( z)  H ( z) X ( z)
Frequency Response of a filter:
H ( f )  H ( z ) z e j 2f
Digital Filters

x[n] y[n]
H (z )

Ideal Low Pass Filter


H( f ) A
constant magnitude  12 fP 1 f
2
in passband…

H( f )
fP

 12 1 f
2
… and linear phase
passband
Impulse Response of Ideal LPF
Assume zero phase shift,
1 fP
hideal [n]   1 H ( f )e j 2 fn
df   Ae j 2 fn df
2

2  fP

 hideal [n]  2 Af P sinc 2 f P n 


fp=0.1

h[n ] 0.2

0.15

f P  0.1
A 1
0.1

0.05

-0.05
-50 -40 -30 -20 -10 0 10 20 30 40 50
n

n
This has Infinite Impulse Response, non recursive and it is non-
causal. Therefore it cannot be realized.
Non Ideal Ideal LPF

The good news is that for the Ideal LPF


lim hideal [n]  0
n  

h[n]

n
L L
h[n]

n
L 2L
Frequency Response of the Non Ideal LPF

1  1 | H( f )|
ripple
1  1
2 attenuation
f P f STOP f

stop pass stop

transition region

LPF specified by:


• passband frequency fP
1 1
• passband ripple  1 or RP  20 log dB 10 1 1

• stopband frequency f STOP


• stopband attenuation  2 or RS  20 log10  2 dB
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  1 | H( f )|
ripple
1  1
2 attenuation
1
f1 f2 2

h  firpm  N ,  0, f1 , f 2 , f 3  / f 3 ,  1,1, 0, 0  ,  w1 , w2  

impulse response  / w1
h   h[0],..., h[ N ] 1  / w2

0 f1 f2 f3  1
2

Linear Interpolation
The total impulse response length N+1 depends on:
• transition region
• attenuation in the stopband
| H( f )|

Example:
2
we want f1 f 2
Passband: 3kHz
f  f 2  f1
Stopband: 3.5kHz
Attenuation: 60dB f ~  20 log10 ( 2 )
22
 1
N
Sampling Freq: 15 kHz
Then: from the specs f   301
3.5  3.0
15.0

We determine the order the filter N~ 60


22
 30  82
Frequency response magnitude
20

-20

N=82 -40

dB
-60

-80

-100
0 0.1 0.2 0.3 0.4 0.5
digital frequency
magnitude
20

-20

-40
N=98
dB

-60

-80

-100

-120
0 0.1 0.2 0.3 0.4 0.5
digital frequency
Example: Low Pass Filter

Passband f = 0.2
Stopband f = 0.25 with attenuation 40dB
Choose order N=40/(22*(0.25-0.20))=37

magnitude
20

| H( f ) | 0

-20
Almost 40dB!!!
-40
dB

-60

-80

-100

-120
0 0.1 0.2 0.3 0.4 0.5
digital frequency f
Example: Low Pass Filter

Passband f = 0.2
Stopband f = 0.25 with attenuation 40dB
Choose order N=40 > 37

magnitude
10

| H( f ) | 0

-10

-20

-30
OK!!!
dB

-40

-50

-60

-70

-80
0 0.1 0.2 0.3 0.4 0.5
digital frequency
f
General FIR Filter of arbitrary Frequency Response
w1
f  [0, f1 , f 2 ,..., f M ] H0 H1 H w2 w( M 1) / 2
2
HM
H  [ H 0 , H1 ,..., H M ] H3 H M 1

0 f1 f 2 f3 f M 1 f M  1
2
Weights for Error:

w  [ w1 , w2 ,..., w( M 1) / 2 ]

Then apply:

h  firpm  N , f / f M , H , w 

… and always check frequency response if it is what you expect!


Example:
H ( f )  1/ sinc( f ) for 0  f  0.2
H( f )  0 0.25  f  0.5

A  40dB
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
magnitude
1.4
not very good here!
1.2

0.8

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5 10
digital frequency
0

-10
dB -20

-30

N  37
-40

-50

-60

-70

-80

-90
0 0.1 0.2 0.3 0.4 0.5
To improve it:
1. Increase order
2. Add weights

A  40dB
0 0.2 0.25 0.5 f
w 1 w  0.2

w=[1*ones(1,length(fp)/2), 0.2*ones(1, length(fs)/2)];


h=firpm(N, [fp, fs]/0.5,M,w);
magnitude
1.4

1.2

0.8

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5
digital frequency
20

dB -20

N  100 -40

-60

-80

-100

-120

-140

-160
0 0.1 0.2 0.3 0.4 0.5

You might also like