R T D S P: EAL IME Igital Ignal Rocessing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

Eng. Julian S.

Bruno

REAL TIME
DIGITAL
SIGNAL
PROCESSING
UTN-FRBA
2011
www.electron.frba.utn.edu.ar/dplab
Frequency Analysis
Discrete Time Fourier Transform

UTN-FRBA 2011 Eng. Julian S. Bruno


Discrete Time Fourier Transform
+∞
1 π DTFT
x[n] =
2π ∫π

X (e jω )e jωn dω X ( e jω ) = ∑ x[ n
n = −∞
]e − j ωn

Discrete Time
Continuos Frequency
Aperiodic in Time
Periodic in Frequency

UTN-FRBA 2011 Eng. Julian S. Bruno


Discrete Time Fourier Series

~ 1 ~
N −1 DFS
~ N −1
~
x [ n] =
N
∑ X [k ] ⋅ e
k =0
jk ( 2π / N ) n
↔ X [ k ] = ∑ x [ n] ⋅ e
n =0
− jk ( 2π / N ) n

Discrete Time
Discrete Frequency
Periodic in Time
N Periodic in Frequency

UTN-FRBA 2011 Eng. Julian S. Bruno


Discrete Fourier Series (II)

~ ~
N −1
Analysis equation : X [k ] = ∑ x [n] ⋅ WN
kn

n =0

~ 1 ~
N −1
Synthesis equation : x [n] =
N
∑ X [ k ] ⋅ WN
k =0
− kn

− j ( 2π / N )
Twiddle Factor : WN = e

Consider a sequence ~
x[n] that is periodic with period N
UTN-FRBA 2011 Eng. Julian S. Bruno
Discrete Fourier Series (III)

DTFT of periodical signal DFS coefficients

This can be done by interpreting the Fourier transform of a periodic


signal to be an impulse train in the frequency domain with the impulse
values proportional to the DFS coefficients for the sequence. Specifically,
if ~
x is periodic with period N and the corresponding discrete Fourier
[n]
~ , then the Fourier transform of ~
series coefficients are X x
[k] [n]
is defined to be the impulse train.
UTN-FRBA 2011 Eng. Julian S. Bruno
Discrete Fourier Transform (I)
x[m] is an
Sampling aperiodic sequence

ωk=2πk/N

DFS

UTN-FRBA 2011 Eng. Julian S. Bruno


Discrete Fourier Transform (II)

UTN-FRBA 2011 Eng. Julian S. Bruno


Discrete Fourier Transform (III)
N −1
Analysis equation : X [k ] = ∑ x[n] ⋅ WNkn 0 ≤ k ≤ N −1
n =0

1 N −1
Synthesis equation : x[n] =
N
∑ X
k =0
[ k ] ⋅ W − kn
N 0 ≤ n ≤ N −1

Twiddle Factor : WN = e − j ( 2π / N )

The inherent periodicity is always present


Circular Shift of a Sequence
Circular Convolution
UTN-FRBA 2011 Eng. Julian S. Bruno
Sampling the Fourier Transform

DTFT

DFT
Sampling

DFS

UTN-FRBA 2011 Eng. Julian S. Bruno


Interpreting the DFT

UTN-FRBA 2011 Eng. Julian S. Bruno


Fourier Series

UTN-FRBA 2011 Eng. Julian S. Bruno


Fourier Transform

UTN-FRBA 2011 Eng. Julian S. Bruno


Discrete Time Fourier
Transform (DTFT)

UTN-FRBA 2011 Eng. Julian S. Bruno


Discrete Fourier Transform
(DFT)

UTN-FRBA 2011 Eng. Julian S. Bruno


DFT Propierties
Circular Shift of a Sequence Circular Convolution

The circular convolution corresponding to X1[k]X2[k] is identical to the linear convolution


corresponding to X1(ejw)X2(ejw) if N, the length of the DFTs, satisfies N ≥ L + P - 1 .
UTN-FRBA 2011 Eng. Julian S. Bruno
Understanding the DFT Equation
N −1
X [k ] = ∑ x[n] ⋅ e − j ( 2πkn / N )
n =0

N −1
X [k ] = ∑ x[n] ⋅ cos(2πkn / N ) − x[n] ⋅ j sin( 2πkn / N )
n =0

 In this example we have a


4 samples signal and we
use DFT to get its
frequency representation.
 The result for each
frequency component is
obtained after computing 8
real sums and
multiplications.
UTN-FRBA 2011 Eng. Julian S. Bruno
DFT example (I)
 Consider a signal formed
with 2 sinusoidal, one of 1
KHz and the other of 2
KHz and a phase shift of
¾π.
 N = 8 samples.
 Fs = 8000 samples/s.
 Fs/N = 1Khz
 First computations are
showed in detail.

UTN-FRBA 2011 Eng. Julian S. Bruno


DFT example (II)

UTN-FRBA 2011 Eng. Julian S. Bruno


DFT example (III)

UTN-FRBA 2011 Eng. Julian S. Bruno


DFT example (IV)

 Here we show the final result in both representations formats.


 The complex DFT outputs for m=1 to m=(N/2)-1 are redundant with
frequency output values form m>(N/2)
 We can see an even symmetry in Magnitude and Real representations,
while an odd symmetry in Imaginary and Phase. Fixed point DSP
 It can be verified the amplitude and phase relationship between the
sinusoidal components, but absolute values?
UTN-FRBA 2011 Eng. Julian S. Bruno
DFT Leakage (I)
Leakage is an unavoidable fact of life
when we perform the DFT on real
world finite-length time sequences

Input - Fs=64 N=64 Input - Fs=64 N=64


1 1

0.5 0.5

0 0

input freq =3 input freq =3


-0.5 R analy sis freq =3 -0.5 R analy sis freq =3
I analy sis freq =3 I analy sis freq =3

-1 -1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

DFT output m agnitud DFT output m agnitud


35 30
30
25
25
20
20
15
15

10 10

5 5

0
-32 -28 -24 -20 -16 -12 -8 -4 0 4 8 12 16 20 24 28 31 0
-32 -28 -24 -20 -16 -12 -8 -4 0 4 8 12 16 20 24 28 31

fS
f res =
N
 If there are frequency components that are not integer
multiples of fres, we got leakage.
 Leakage evidences the effect of sampling during finite (and
rectangular) time window.
UTN-FRBA 2011 Eng. Julian S. Bruno
DFT Leakage (II)

 As can be seen, the sinc function is always present, but only


evidenced when frequency components are not integer
multiples of fres.
 The DFT output is a sampled version of the continuous spectral
UTN-FRBA 2011 Eng. Julian S. Bruno
Time Windowing (I)
Comparación de Ventanas

The only fact of


1
Rectangular

 0.9
Hanning
Hamming

considering a finite length


FlatTop
0.8

time sequence, is
0.7

0.6

Módulo (veces)
equivalent to convolve a 0.5

sinc with all frequency


0.4

0.3

samples. 0.2

If we use a window, we
0.1

 0
0 1 2 3 4 5 6 7 8

will convolve with the


Normalized Frequency (xFs/N)

Comparación de Ventanas
0

spectrum this window.


Rectangular
Hanning
Hamming
-20
FlatTop

 The net effect of -40

windowing is a better -60


Módulo (dB)

spectral estimation, -80

reducing leakage and -100

picket fence effect. -120

-140
0 1 2 3 4 5 6 7 8
UTN-FRBA 2011 Normalized Frequency (xFs/N) Eng. Julian S. Bruno
The window selection is a trade-off

Time Windowing (II)


between main lobe widening, first
sidelobe levels, and how fast the
sidelobes decrease with increased
frequency.

UTN-FRBA 2011 Eng. Julian S. Bruno


Time Windowing (III)
 Spectral analysis:
 Equivalent Noise Bandwith
 Processing Gain

 Overlap Correlation

 Scalloping Loos

 Coherent Gain

 Worst Case Processing Loss

 Minimun Resolution Bandwidth

UTN-FRBA 2011 Eng. Julian S. Bruno


Equivalent Noise Bandwith

UTN-FRBA 2011 Eng. Julian S. Bruno


Processing Gain
 There are two types of processing gain associated
with DFTs.
 People who use the DFT to detect signal energy
embedded in noise often speak of the DFT's
processing gain because the DFT can pull signals
out of background noise.
 This is due to the inherent correlation gain that
takes place in any N-point DFT.
 Additional integration gain is possible when
multiple DFT outputs are averaged.
UTN-FRBA 2011 Eng. Julian S. Bruno
Processing Gain
 The concept of the DFT having processing gain is
straightforward if we think of a particular DFT bin output as
the output of a narrowband filter.
 DFT output bin has the amplitude response of the sin(x)/x
function, that bin's output is primarily due to input energy
residing under, or very near, the bin's main lobe.
 It's valid to think of a DFT bin as a kind of bandpass filter
whose band center is located at mfs/N
 If the input signal frequency is not at bin center, leakage
will raise the effective background noise and reduce the
DFT's output SNR.
 In addition, any window being used will have some effect
on the leakage and, thus, on the output SNR.
UTN-FRBA 2011 Eng. Julian S. Bruno
Processing Gain

N=64

N=256

N=1024
 N 
SNRN = SNRN ' + 20 log10  

 N ' 
UTN-FRBA 2011 Eng. Julian S. Bruno
Processing Gain
 The increased FFT sensitivity, or
noise variance reduction, due to
multiple FFT averaging is also
called integration gain.
 The random noise fluctuations in
an FFT's output bins will
decrease, while the magnitude
of the FFT's signal bin output
remains constant when multiple
FFT outputs are averaged.
 There are two types of FFT
averaging integration gain:
incoherent and coherent.

UTN-FRBA 2011 Eng. Julian S. Bruno


Overlap Correlation

UTN-FRBA 2011 Eng. Julian S. Bruno


Scalloping Loos

Magnitude Normalized curves

UTN-FRBA 2011 Eng. Julian S. Bruno


Coherent Gain

1 N −1
Coherent Gain = ∑ win[n]
N n =0
Coherent Gain = Win[0]

UTN-FRBA 2011 Eng. Julian S. Bruno


Implementing Linear Time-Invariant Systems
Using the DFT

x[n] h[n] y[n] = x[n] * h[n]

UTN-FRBA 2011 Eng. Julian S. Bruno


Overlap-add
method

yr[n] = xr[n] * h[n]

UTN-FRBA 2011 Eng. Julian S. Bruno


Overlap-save
method

yr[n] = xr[n] * h[n]

UTN-FRBA 2011 Eng. Julian S. Bruno


Goertzel Algorithm
The Goertzel algorithm is a digital signal processing technique for identifying
frequency components of a signal, published by Dr. Gerald Goertzel in 1958
N −1
f tonne
X(m) = ∑ x(n)e
− j 2Nπnm
m= fs / N
n =0

Method Real Real


multiplies additions
Single-bin DFT 4N 2N

FFT 2Nlog2N Nlog2N

Goertzel N+2 2N+1

If you implement the Goertzel algorithm L


times to detect L different tones, Goertzel
is more efficent than FFT when L< log2N
UTN-FRBA 2011 Eng. Julian S. Bruno
Goertzel Algorithm Implementation

UTN-FRBA 2011 Eng. Julian S. Bruno


Sliding DFT

Method Real Real


multiplies additions
Single-bin DFT 4N 2N

FFT 2Nlog2N Nlog2N

Goertzel N+2 2N+1

Siliding DFT 4 4

Compute Xm(n+1)

UTN-FRBA 2011 Eng. Julian S. Bruno


Sliding DFT
 Once an Xm(n) is obtained, the number of
computations to compute Xm(n+1) is fixed and
independent of N.
 The SDFT's N can be any positive integer giving us
greater flexibility to tune the SDFT's center frequency
by defining integer m such that m = Nfi/fs, when fi is a
frequency of interest in Hz.
 The SDFT requires no bit-reversal processing as
does the FFT.
 Like the Goertzel algorithm, the SDFT is especially
efficient for narrowband spectrum analysis.
UTN-FRBA 2011 Eng. Julian S. Bruno
Zoom FFT

UTN-FRBA 2011 Eng. Julian S. Bruno


Zero Stuffing
 Zero stuffing is a way
of increasing
frequency resolution.
 The spectrum
visualized corresponds
to the convolution of a
sinusoidal and a
rectangular signal.
 Thus, the underlying
spectrum of the
sinusoidal is distorted
by a sinc.
UTN-FRBA 2011 Eng. Julian S. Bruno
Zero Stuffing (II)
Fsig = 16Hz , Fs= 512 , N=128 , ∆f = 4
0 zeros DFT Magnitude
1 20

0 10

-1 0
0 0.05 0.1 0.15 0.2 0.25 0 5 10 15 20 25 30

16 zeros DFT Magnitude


1 20

0 10

-1 0
0 0.1 0.2 0.3 0.4 0.5 0 5 10 15 20 25 30
32 zeros DFT Magnitude
1 20

0 10

-1 0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0 5 10 15 20 25 30
48 zeros DFT Magnitude
1 20

0 10

-1 0
0 0.2 0.4 0.6 0.8 1 0 5 10 15 20 25 30
UTN-FRBA 2011 Eng. Julian S. Bruno
Recommended bibliography
 RG Lyons, Understanding Digital Signal Processing 3th ed. Prentice
Hall. 2011.
 Ch3: The Discrete Fourier Transform.
 F. Harris, On the use of windows for harmonic analysis with the discrete
Fourier transform.

 The Fundamentals of FFT-Based Signal Analysis and Measurement.


Nationals Instruments. Application Note 041.

 Reducing FFT Scalloping Loss Errors Without Multiplication [DSP Tips


and Tricks]. Signal Processing Magazine, IEEE. March 2011

 Oppenheim & Schafer

 Proakis & Manolakis


UTN-FRBA 2011
.
NOTE: Many images used in this presentation were extracted from the recommended bibliography
Eng. Julian S. Bruno
Questions?

Thank you!

Eng. Julian S. Bruno UTN-FRBA 2011

You might also like