DSP First, 2/e

33
DSP First, 2/e Lecture 9 Sampling & Aliasing MODIFIED TLH

Transcript of DSP First, 2/e

Page 1: DSP First, 2/e

DSP First, 2/e

Lecture 9

Sampling & Aliasing

MODIFIED TLH

Page 2: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 2

Let’s Go to the MoviesSAMPLING AND ALIASING REFERENCES CH 4 2/12/2019

Interesting illusion: the helicopter's blades are somehow in sync with

the camera's shutter making it seem as though they are not moving.

0:47 https://www.youtube.com/watch?v=qgvuQGY946g

Helicopter blades and other fast spinning objects often produce

strange effects on camera. Lauren explains why. 3:51https://www.youtube.com/watch?v=AYQAKwCxScc

Audio Sampling Rate Demo 0:35

https://www.youtube.com/watch?v=hRhVb6iRArg&feature=youtu.be

Page 3: DSP First, 2/e

Video Aliasing

May 2016 © 2003-2016, JH McClellan & RW Schafer 3

Why car wheels rotate

backwards in movies 4:25https://www.youtube.com/watch?v=SFbINinFsxk&feature=yout

u.be

Page 4: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 4

READING ASSIGNMENTS

This Lecture:

Chap 4, Sections 4-1 and 4-2

Other Reading:

TLH WEBSITE

Next Lecture: Chap. 4, Sects. 4-3 and 4-4

Page 5: DSP First, 2/e

Sampling

Figure 4-1: Block diagram representation of the ideal continuous-to-discrete (C-to-D)

converter. The parametersT specifies uniform sampling of the input signal every

sT seconds.

Sometimes ADC, A2D, Analog-to-Digital

n = 1,2,3,4… nTs in seconds

Page 6: DSP First, 2/e

Copyright © 2016, 1998 Pearson Education, Inc. All Rights Reserved

Sampling Sinusoidal Signals (1 of 2)

Figure 4-2: Plotting format for discrete-time signals, called a stem plot. In MATLAB, the

function stem produces this plot. Some students also refer to the stem plot as a “lollypop”

plot.

Page 7: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 7

>> help stem

stem Discrete sequence or "stem" plot.

stem(Y) plots the data sequence Y as stems from the x axis

terminated with circles for the data value. If Y is a matrix

then each column is plotted as a separate series.

stem(X,Y) plots the data sequence Y at the values specified

in X.

Page 8: DSP First, 2/e

Copyright © 2016, 1998 Pearson Education, Inc. All Rights Reserved

Sampling Sinusoidal Signals (2 of 2)

Figure 4-3: A continuous-time 100 Hz sinusoid (a) and two discrete-time sinusoids

formed by sampling at samples/s 2000sf (b) and at (c). samples/s 500sf

Page 9: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 9

LECTURE OBJECTIVES

SAMPLING can cause ALIASING

Sampling Theorem

Sampling Rate > 2(Highest Frequency)

Spectrum for digital signals, x[n]

Normalized Frequency

22

ˆ s

sf

fT

ALIASING

Page 10: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 10

SYSTEMS Process Signals

PROCESSING GOALS:

Change x(t) into y(t)

For example, more BASS, pitch shifting

Improve x(t), e.g., image deblurring

Extract Information from x(t)

SYSTEMx(t) y(t)

Page 11: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 11

System IMPLEMENTATION

DIGITAL/MICROPROCESSOR Convert x(t) to numbers stored in memory

ELECTRONICSx(t) y(t)

COMPUTER D-to-AA-to-Dx(t) y(t)y[n]x[n]

ANALOG/ELECTRONIC: Circuits: resistors, capacitors, op-amps

Page 12: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 12

SAMPLING x(t)

SAMPLING PROCESS Convert x(t) to numbers x[n]

“n” is an integer index; x[n] is a sequence of values

Think of “n” as the storage address in memory

UNIFORM SAMPLING at t = nTs

IDEAL: x[n] = x(nTs)

C-to-Dx(t) x[n]

Page 13: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 13

SAMPLING RATE, fs

SAMPLING RATE (fs)

fs =1/Ts

NUMBER of SAMPLES PER SECOND

Ts = 125 microsec fs = 8000 samples/sec• UNITS of fs ARE HERTZ: 8000 Hz

UNIFORM SAMPLING at t = nTs = n/fs IDEAL: x[n] = x(nTs)=x(n/fs)

C-to-Dx(t) x[n]=x(nTs)

Page 14: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 14

STORING DIGITAL SOUND

x[n] is a SAMPLED SISIGNAL

A list of numbers stored in memory

EXAMPLE: audio CD

CD rate is 44,100 samples per second

16-bit samples

Stereo uses 2 channels

Number of bytes for 1 minute is

2 X (16/8) X 60 X 44100 = 10.584 Mbytes

Page 15: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 15Which one provides the most accurate representation of x(t)?

fs 2 kHz

fs 500Hz

Hz100f

Page 16: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 16

SAMPLING THEOREM

HOW OFTEN DO WE NEED TO SAMPLE?

DEPENDS on FREQUENCY of SINUSOID

ANSWERED by SHANNON/NYQUIST Theorem

ALSO DEPENDS on “RECONSTRUCTION”

Page 17: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 17

Reconstruction? Which One?

)4.0cos(][ nnx

When n is an integer

cos(0.4n) cos(2.4n)

Given the samples, draw a sinusoid through the values

Occam’s razor -> pick lowest frequency sinusoid

Page 18: DSP First, 2/e

Be careful…https://www.youtube.com/watch?v=qgvuQGY946g

May 2016 © 2003-2016, JH McClellan & RW Schafer 18

See the References on the Website

Page 19: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 19

sfsT

nAnx

ˆ

)ˆcos(][

)cos()(][

)cos()(

ss nTAnTxnx

tAtx

DISCRETE-TIME SINUSOID

Change x(t) into x[n] DERIVATION

))cos((][ nTAnx s

DEFINE DIGITAL FREQUENCY

Page 20: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 20

DIGITAL FREQUENCY

VARIES from 0 to 2, as f varies from

0 to the sampling frequency

UNITS are radians, not rad/sec

DIGITAL FREQUENCY is NORMALIZED

ˆ Ts 2f

fs

ˆ

Page 21: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 21

SPECTRUM (DIGITAL)

sf

f 2ˆ

kHz1sf

12 X1

2 X*

2(0.1)–0.2

))1000/)(100(2cos(][ nAnx

Page 22: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 22

SPECTRUM (DIGITAL) ???

ˆ

12 X1

2 X*

2(1)–2

?

x[n] is zero frequency???

))100/)(100(2cos(][ nAnx

sf

f 2ˆ

fs 100 Hz

Page 23: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 23

rad, 52ˆ

samples/s. 80sf100 Hz sinusoid

Page 24: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 24

The REST of the STORY

Spectrum of x[n] has more than one line for

each complex exponential

Called ALIASING

MANY SPECTRAL LINES

SPECTRUM is PERIODIC with period = 2 Because

( ) ( )( ) nAnA 2ˆcosˆcos

Page 25: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 25

ALIASING DERIVATION

Other Frequencies give the same

Hz1000at sampled)400cos()(1 sfttx

)4.0cos()400cos(][10001 nnx n

Hz1000at sampled)2400cos()(2 sfttx

)4.2cos()2400cos(][10002 nnx n

)4.0cos()24.0cos()4.2cos(][2 nnnnnx

][][ 12 nxnx )1000(24002400

ˆ

Page 26: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 26

ALIASING DERIVATION

Other Frequencies give the same

s

sf

fT

2ˆ 2

ˆ

s

s

ss

s

f

f

f

f

f

ff

22)(2ˆ :then

and we want : x[n] Acos( ˆ n )

))(2cos()( If tffAtx s

tn

fs

Page 27: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 27

ALIASING CONCLUSIONS

Adding an INTEGER multiple of fs or –fs to

the frequency of a continuous sinusoid xc(t)

gives exactly the same values for the

sampled signal x[n] = xc(n/fs )

GIVEN x[n], we CAN’T KNOW whether it came

from a sinusoid at fo or (fo + fs ) or (fo + 2fs ) …

This is called ALIASING

Page 28: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 28

SPECTRUM for x[n]

PLOT versus NORMALIZED FREQUENCY

INCLUDE ALL SPECTRUM LINES

ALIASES

ADD MULTIPLES of 2

SUBTRACT MULTIPLES of 2

FOLDED ALIASES

(to be discussed later)

ALIASES of NEGATIVE FREQS

Page 29: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 29

SPECTRUM (MORE LINES)

12 X1

2 X*

2(0.1)–0.2

12 X

*

1.8

12 X

–1.8

))1000/)(100(2cos(][ nAnx

kHz1sf

sf

f 2ˆ

Page 30: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 30

SPECTRUM (ALIASING CASE)

12 X

*

–0.5

12 X

–1.5

12 X

0.5 2.5–2.5

12 X1

2 X* 1

2 X*

1.5

))80/)(100(2cos(][ nAnx

kHz80sf

sf

f 2ˆ

Page 31: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 31

SAMPLING GUI (con2dis)

Page 32: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 32

SAMPLING GUI (con2dis)

Page 33: DSP First, 2/e

May 2016 © 2003-2016, JH McClellan & RW Schafer 33

SPECTRUM (FOLDING CASE)

2f

fs

fs 125Hz

12 X

*

0.4

12 X

–0.4 1.6–1.6

12 X1

2 X*

))125/)(100(2cos(][ nAnx