ee480: digital signal processing

26
http://www.ee.unlv.edu/~b1morris/ee480/ Professor Brendan Morris, SEB 3216, [email protected] EE480: Digital Signal Processing Spring 2014 TTh 14:30-15:45 CBC C222 Frequency Analysis 15/04/28

Upload: others

Post on 15-Feb-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EE480: Digital Signal Processing

http://www.ee.unlv.edu/~b1morris/ee480/

Professor Brendan Morris, SEB 3216, [email protected]

EE480: Digital Signal Processing

Spring 2014

TTh 14:30-15:45 CBC C222

Frequency Analysis

15/04/28

Page 2: EE480: Digital Signal Processing

Outline

β€’ Fourier Series

β€’ Fourier Transform

β€’ Discrete Time Fourier Transform

β€’ Discrete Fourier Transform

β€’ Fast Fourier Transform

2

Page 3: EE480: Digital Signal Processing

Fourier Series β€’ Periodic signals

β–« π‘₯ 𝑑 = π‘₯(𝑑 + 𝑇0) β€’ Periodic signal can be represented as a sum of an

infinite number of harmonically-related sinusoids

β–« π‘₯ 𝑑 = π‘π‘˜π‘’π‘—π‘˜Ξ©0π‘‘βˆž

π‘˜=βˆ’βˆž β–« π‘π‘˜ - Fourier series coefficients

Contribution of particular frequency sinusoid β–« Ξ©0 = 2πœ‹/𝑇0 - fundamental frequency β–« π‘˜ – harmonic frequency index

β€’ Coefficients can be obtained from signal

β–« π‘π‘˜ =1

𝑇0 π‘₯ 𝑑 π‘’βˆ’π‘—π‘˜Ξ©0𝑑𝑇00

β–« Notice 𝑐0 is the average over a period, the DC component

3

Page 4: EE480: Digital Signal Processing

Fourier Series Example β€’ Example 5.1

β€’ Rectangular pulse train

β€’ π‘₯ 𝑑 = 𝐴 βˆ’πœ < 𝑑 < 𝜏0 𝑒𝑙𝑠𝑒

β€’ π‘π‘˜ =𝐴𝜏

𝑇0

sin π‘˜Ξ©0𝜏/2

π‘˜Ξ©0𝜏/2

β€’ 𝑇 = 1;

β€’ Ξ©0 = 2πœ‹ βˆ—1

𝑇= 2Ο€

β€’ Magnitude spectrum is known as a line spectrum

β–« Only few specific frequencies represented

4

-20 -10 0 10 20-0.2

0

0.2

0.4

0.6

0.8

1

1.2

frequency [rad/sec]

ck

-10 -5 0 5 10-0.2

0

0.2

0.4

0.6

0.8

1

1.2

frequency [Hz]

ck

Page 5: EE480: Digital Signal Processing

Fourier Transform β€’ Generalization of Fourier

series to handle non-periodic signals

β€’ Let 𝑇0 β†’ ∞

β–« Spacing between lines in FS go to zero

Ξ©0 = 2πœ‹/𝑇0

β€’ Results in a continuous frequency spectrum

β–« Continuous function

β€’ The number of FS coefficients to create β€œperiodic” function goes to infinity

β€’ Fourier representation of signal

β–« π‘₯ 𝑑 =1

2πœ‹ 𝑋 Ξ© π‘’π‘—Ξ©π‘‘π‘‘Ξ©βˆž

βˆ’βˆž

β–« Inverse Fourier transform

β€’ Fourier transform

β–« 𝑋 Ξ© = π‘₯ t π‘’βˆ’π‘—Ξ©π‘‘π‘‘π‘‘βˆž

βˆ’βˆž

β€’ Notice that a periodic function has both a FS and FT

β–« π‘π‘˜ =1

𝑇0𝑋(π‘˜Ξ©0)

β–« Notice a normalization constant to account for the period

5

Page 6: EE480: Digital Signal Processing

Discrete Time Fourier Transform

β€’ Useful theoretical tool for discrete sequences/signals

β€’ DTFT

β–« 𝑋 πœ” = π‘₯ 𝑛𝑇 π‘’βˆ’π‘—πœ”π‘›π‘‡βˆžπ‘›=βˆ’βˆž

β–« Periodic function with period 2πœ‹

Only need to consider a 2πœ‹ interval 0,2πœ‹ or [βˆ’πœ‹, πœ‹]

β€’ Inverse FT

β–« π‘₯ 𝑛𝑇 =1

2πœ‹ 𝑋 πœ” π‘’π‘—πœ”π‘›π‘‡πœ‹

βˆ’πœ‹π‘‘πœ”

β–« Notice this is an integral relationship

𝑋 πœ” is a continuous function

Sequence π‘₯(𝑛) is infinite length

6

Page 7: EE480: Digital Signal Processing

Sampling Theorem β€’ Aliasing – signal distortion

caused by sampling

β–« Loss of distinction between different signal frequencies

β€’ A bandlimited signal can be recovered from its samples when there is no aliasing

β–« 𝑓𝑠 β‰₯ 2π‘“π‘š , Ω𝑠 β‰₯ 2Ξ©π‘š

𝑓𝑠, Ω𝑠 - signal bandwidth

β€’ Copies of analog spectrum are copied at 𝑓𝑠 intervals

β–« Smaller sampling frequency compresses spectrum into overlap

7

Page 8: EE480: Digital Signal Processing

Discrete Fourier Transform β€’ Numerically computable transform used for

practical applications β–« Sampled version of DTFT

β€’ DFT definition

β–« 𝑋 π‘˜ = π‘₯ 𝑛 π‘’βˆ’π‘— 2πœ‹/N π‘˜π‘›π‘βˆ’1𝑛=0

β–« π‘˜ = 0, 1,… ,𝑁 βˆ’ 1 – frequency index β–« Assumes π‘₯ 𝑛 = 0 outside bounds [0, 𝑁 βˆ’ 1]

β€’ Equivalent to taking 𝑁 samples of DTFT 𝑋(πœ”) over the range [0, 2πœ‹] β–« 𝑁 equally spaced samples at frequencies πœ”π‘˜ = 2πœ‹π‘˜/𝑁

Resolution of DFT is 2πœ‹/𝑁

β€’ Inverse DFT

β–« π‘₯ 𝑛 =1

𝑁 𝑋 π‘˜ 𝑒𝑗 2πœ‹/N π‘˜π‘›π‘βˆ’1

π‘˜=0

8

Page 9: EE480: Digital Signal Processing

Relationships Between Transforms

9

Page 10: EE480: Digital Signal Processing

Relationships Between Transforms

10

Page 11: EE480: Digital Signal Processing

Relationships Between Transforms

11

Page 12: EE480: Digital Signal Processing

12

Page 13: EE480: Digital Signal Processing

DFT Twidle Factors β€’ Rewrite DFT equation using

Euler’s

β€’ 𝑋 π‘˜ = π‘₯ 𝑛 π‘’βˆ’π‘— 2πœ‹/N π‘˜π‘›π‘βˆ’1𝑛=0

β€’ 𝑋 π‘˜ = π‘₯(𝑛)π‘βˆ’1𝑛=0 π‘Šπ‘

π‘˜π‘› β–« π‘˜ = 0,1, … , 𝑁 βˆ’ 1

β–« π‘Šπ‘π‘˜π‘› = π‘’βˆ’π‘— 2πœ‹/𝑁 π‘˜π‘› =

cos2πœ‹π‘˜π‘›

π‘βˆ’ 𝑗 sin

2πœ‹π‘˜π‘›

𝑁

β€’ IDFT

β€’ π‘₯ 𝑛 =1

𝑁 𝑋 π‘˜ 𝑒𝑗 2πœ‹/N π‘˜π‘›π‘βˆ’1

π‘˜=0

β€’ π‘₯ 𝑛 =1

𝑁 𝑋(π‘˜)π‘βˆ’1

π‘˜=0 π‘Šπ‘βˆ’π‘˜π‘›,

β–« π‘˜ = 0,1, … , 𝑁 βˆ’ 1

β€’ Properties of twidle factors

β–« π‘Šπ‘π‘˜ - N roots of unity in

clockwise direction on unit circle

β–« Symmetry

π‘Šπ‘π‘˜+𝑁/2

= βˆ’π‘Šπ‘π‘˜ , 0 ≀ π‘˜ ≀

𝑁

2βˆ’ 1

β–« Periodicity

π‘Šπ‘π‘˜+𝑁 = π‘Šπ‘

π‘˜

β€’ Frequency resolution

β–« Coefficients equally spaced on unit circle

β–« Ξ” = 𝑓𝑠/𝑁

13

Page 14: EE480: Digital Signal Processing

DFT Properties β€’ Linearity

β–« 𝐷𝐹𝑇 π‘Žπ‘₯ 𝑛 + 𝑏𝑦 𝑛 = π‘Žπ‘‹ π‘˜ +π‘π‘Œ π‘˜

β€’ Complex conjugate

β–« 𝑋 βˆ’π‘˜ = π‘‹βˆ—(π‘˜)

1 ≀ π‘˜ ≀ 𝑁 βˆ’ 1 For π‘₯ 𝑛 real valued

β–« Only first 𝑀 + 1 coefficients are unique

β–« Notice the magnitude spectrum is even and phase spectrum is odd

β€’ Z-transform connection

β–« 𝑋 π‘˜ = 𝑋 𝑧 𝑧=𝑒𝑗 2πœ‹/𝑁 π‘˜

β–« Obtain DFT coefficients by evaluating z-transform on the unit circle at N equally spaced frequencies πœ”π‘˜ = 2πœ‹π‘˜/𝑁

β€’ Circular convolution

β–« π‘Œ π‘˜ = 𝐻 π‘˜ 𝑋(π‘˜)

β–« 𝑦 𝑛 = β„Ž 𝑛 ⨂π‘₯(𝑛)

β–« 𝑦 𝑛 = β„Ž π‘š π‘₯( 𝑛 βˆ’ π‘š π‘šπ‘œπ‘‘ 𝑁)π‘βˆ’1π‘š=0

Note: both sequences must be padded to same length

14

Page 15: EE480: Digital Signal Processing

Fast Fourier Transform

β€’ DFT is computationally expensive

β–« Requires many complex multiplications and additions

β–« Complexity ~4𝑁2

β€’ Can reduce this time considerably by using the twidle factors

β–« Complex periodicity limits the number of distinct values

β–« Some factors have no real or no imaginary parts

β€’ FFT algorithms operate in 𝑁 log2 𝑁 time

β–« Utilize radix-2 algorithm so 𝑁 = 2π‘š is a power of 2

15

Page 16: EE480: Digital Signal Processing

FFT Decimation in Time

β€’ Compute smaller DFTs on subsequences of π‘₯ 𝑛

β€’ 𝑋 π‘˜ = π‘₯(𝑛)π‘βˆ’1𝑛=0 π‘Šπ‘

π‘˜π‘›

β€’ 𝑋 π‘˜ =

π‘₯1(π‘š)𝑁/2βˆ’1π‘š=0 π‘Šπ‘

π‘˜2π‘š + π‘₯2(π‘š)𝑁/2βˆ’1π‘š=0 π‘Šπ‘

π‘˜(2π‘š+1)

β–« π‘₯1 π‘š = 𝑔(𝑛) = π‘₯ 2π‘š - even samples β–« π‘₯2 π‘š = β„Ž 𝑛 = π‘₯(2π‘š + 1) – odd samples

β€’ Since π‘Šπ‘2π‘šπ‘˜ = π‘Šπ‘/2

π‘šπ‘˜

β–« 𝑋 π‘˜ = π‘₯1(π‘š)𝑁/2βˆ’1π‘š=0 π‘Šπ‘/2

π‘˜π‘š + π‘Šπ‘π‘˜ π‘₯2(π‘š)

𝑁/2βˆ’1π‘š=0 π‘Šπ‘/2

π‘˜π‘š

𝑁/2-point DFT of even and out parts of π‘₯(𝑛)

β–« 𝑋 π‘˜ = 𝐺 π‘˜ + π‘Šπ‘π‘˜π»(π‘˜)

Full 𝑁 sequence is obtained by periodicity of each 𝑁/2 DFT

16

Page 17: EE480: Digital Signal Processing

FFT Butterfly Structure β€’ Full butterfly (8-point) β€’ Simplified structure

17

Page 18: EE480: Digital Signal Processing

FFT Decimation β€’ Repeated application of

even/odd signal split

β–« Stop at simple 2-point DFT

β€’ Complete 8-point DFT structure

18

Page 19: EE480: Digital Signal Processing

FFT Decimation in Time Implementation

β€’ Notice arrangement of samples is not in sequence – requires shuffling β–« Use bit reversal to figure out pairing of samples in 2-bit DFT

β€’ Input values to DFT block are not needed after calculation β–« Enables in-place operation

Save FFT output in same register as input β–« Reduce memory requirements

19

Page 20: EE480: Digital Signal Processing

FFT Decimation in Frequency

β€’ Similar divide and conquer strategy

β–« Decimate in frequency domain

β€’ 𝑋 2π‘˜ = π‘₯ 𝑛 π‘Šπ‘2π‘›π‘˜π‘βˆ’1

𝑛=0

β€’ 𝑋 2π‘˜ = π‘₯ 𝑛 π‘Šπ‘/2π‘›π‘˜π‘/2βˆ’1

𝑛=0 + π‘₯ 𝑛 π‘Šπ‘/2π‘›π‘˜π‘βˆ’1

𝑛=𝑁/2

β–« Divide into first half and second half of sequence

β€’ 𝑋 2π‘˜ =

π‘₯ 𝑛 π‘Šπ‘/2π‘›π‘˜π‘/2βˆ’1

𝑛=0 + π‘₯ 𝑛 +𝑁

2π‘Š

𝑁/2

𝑛+𝑁

2π‘˜π‘/2βˆ’1

𝑛=0

β€’ Simplifying with twidle properties

β–« 𝑋 2π‘˜ = π‘₯ 𝑛 + π‘₯ 𝑛 +𝑁

2π‘Šπ‘/2

π‘›π‘˜π‘/2βˆ’1𝑛=0

β–« 𝑋 2π‘˜ + 1 = π‘Šπ‘π‘› π‘₯ 𝑛 βˆ’ π‘₯ 𝑛 +

𝑁

2π‘Šπ‘/2

π‘›π‘˜π‘/2βˆ’1𝑛=0

20

Page 21: EE480: Digital Signal Processing

FFT Decimation in Frequency Structure

β€’ Stage structure

β€’ Bit reversal happens at output instead of input

β€’ Full structure

21

Page 22: EE480: Digital Signal Processing

Inverse FFT

β€’ π‘₯ 𝑛 =1

𝑁 𝑋(π‘˜)π‘βˆ’1

π‘˜=0 π‘Šπ‘βˆ’π‘˜π‘›

β€’ Notice this is the DFT with a scale factor and change in twidle sign

β€’ Can compute using the FFT with minor modifications

β–« π‘₯βˆ— 𝑛 =1

𝑁 π‘‹βˆ—(π‘˜)π‘βˆ’1

π‘˜=0 π‘Šπ‘π‘˜π‘›

Conjugate coefficients, compute FFT with scale factor, conjugate result

For real signals, no final conjugate needed

β–« Can complex conjugate twidle factors and use in butterfly structure

22

Page 23: EE480: Digital Signal Processing

FFT Example β€’ Example 5.10

β€’ Sine wave with 𝑓 = 50 Hz

β–« π‘₯ 𝑛 = sin2πœ‹π‘“π‘›

𝑓𝑠

𝑛 = 0,1, … , 128

𝑓𝑠 = 256 Hz

β€’ Frequency resolution of DFT?

β–« Ξ” = 𝑓𝑠/𝑁 =256

128= 2 Hz

β€’ Location of peak

β–« 50 = π‘˜Ξ” β†’ π‘˜ =50

2= 25

23

10 20 30 40 50 600

10

20

30

40

50

60

Frequency index, k

Ma

gn

itu

de

0 50 100 150-6

-4

-2

0

2

4

6x 10

-16

sample n

err

or

Page 24: EE480: Digital Signal Processing

Spectral Leakage and Resolution β€’ Notice that a DFT is like windowing

a signal to finite length β–« Longer window lengths (more

samples) the closer DFT 𝑋(π‘˜) approximates DTFT 𝑋 πœ”

β€’ Convolution relationship

β–« π‘₯𝑁 𝑛 = 𝑀 𝑛 π‘₯ 𝑛

β–« 𝑋𝑁 π‘˜ = π‘Š π‘˜ βˆ— 𝑋 π‘˜

β€’ Corruption of spectrum due to window properties (mainlobe/sidelobe) β–« Sidelobes result in spurious peaks

in computed spectrum known as spectral leakage

Obviously, want to use smoother windows to minimize these effects

β–« Spectral smearing is the loss in sharpness due to convolution which depends on mainlobe width

β€’ Example 5.15 β–« Two close sinusoids smeared

together

β€’ To avoid smearing: β–« Frequency separation should be

greater than freq resolution

β–« 𝑁 >2πœ‹

Ξ”πœ”, 𝑁 > 𝑓𝑠/Δ𝑓

24

10 20 30 40 50 600

10

20

30

40

50

60

70

Frequency index, kM

ag

nitu

de

Page 25: EE480: Digital Signal Processing

Power Spectral Density β€’ Parseval’s theorem

β€’ 𝐸 =

π‘₯ 𝑛 2 =1

𝑁 𝑋 π‘˜ 2π‘βˆ’1

π‘˜=0π‘βˆ’1𝑛=0

β–« 𝑋 π‘˜ 2 - power spectrum or periodogram

β€’ Power spectral density (PSD, or power density spectrum or power spectrum) is used to measure average power over frequencies

β€’ Computed for time-varying signal by using a sliding window technique β–« Short-time Fourier transform

β–« Grab 𝑁 samples and compute FFT Must have overlap and use

windows

β€’ Spectrogram β–« Each short FFT is arranged as a

column in a matrix to give the time-varying properties of the signal

β–« Viewed as an image

25

0.5 1 1.5 2 2.5 30

500

1000

1500

2000

2500

3000

3500

4000

Time

Fre

qu

en

cy (

Hz)

β€œShe had your dark suit in greasy wash water all year”

Page 26: EE480: Digital Signal Processing

Fast FFT Convolution

β€’ Linear convolution is multiplication in frequency domain

β–« Must take FFT of signal and filter, multiply, and iFFT

β–« Operations in frequency domain can be much faster for large filters

β–« Requires zero-padding because of circular convolution

β€’ Typically, will do block processing

β–« Segment a signal and process each segment individually before recombining

26