3/9/2018 © 2003, JH McClellan & RW Schafer 2
License Info for SPFirst Slides
This work released under a Creative Commons Licensewith the following terms:
Attribution The licensor permits others to copy, distribute, display, and perform
the work. In return, licensees must give the original authors credit.
Non-Commercial The licensor permits others to copy, distribute, display, and perform
the work. In return, licensees may not use the work for commercial purposes—unless they get the licensor's permission.
Share Alike The licensor permits others to distribute derivative works only under
a license identical to the one that governs the licensor's work. Full Text of the License This (hidden) page should be kept with the presentation
3/9/2018 © 2003, JH McClellan & RW Schafer 3
LECTURE OBJECTIVES
SAMPLING can cause ALIASING Sampling Theorem Sampling Rate > 2(Highest Frequency)
Spectrum for digital signals, x[n] Normalized Frequency
22ˆ s
s ffT
ALIASING
3/9/2018 © 2003, JH McClellan & RW Schafer 4
SYSTEMS Process Signals
PROCESSING GOALS: Change x(t) into y(t) For example, more BASS
Improve x(t), e.g., image deblurring Extract Information from x(t)
SYSTEMx(t) y(t)
3/9/2018 © 2003, JH McClellan & RW Schafer 5
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
3/9/2018 © 2003, JH McClellan & RW Schafer 6
4-1 SAMPLING
SAMPLING PROCESS Convert x(t) to numbers x[n] “n” is an integer; 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]
3/9/2018 © 2003, JH McClellan & RW Schafer 7
SAMPLING RATE, fs
SAMPLING RATE (fs) (Sampling frequency) fs =1/Ts NUMBER of SAMPLES PER SECOND
Ts = 125 microsec fs = 8000 samples/sec• UNITS 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)
3/9/2018 © 2003, JH McClellan & RW Schafer 9
SAMPLING THEOREM
HOW OFTEN ? DEPENDS on FREQUENCY of SINUSOID ANSWERED by SHANNON/NYQUIST Theorem ALSO DEPENDS on “RECONSTRUCTION”
3/9/2018 © 2003, JH McClellan & RW Schafer 10
NYQUIST RATE
“Nyquist Rate” Sampling fs > TWICE the HIGHEST Frequency in x(t) “Sampling above the Nyquist rate”
BANDLIMITED SIGNALS DEF: x(t) has a HIGHEST FREQUENCY
COMPONENT in its SPECTRUM NON-BANDLIMITED EXAMPLE TRIANGLE WAVE is NOT BANDLIMITED
3/9/2018 © 2003, JH McClellan & RW Schafer 11
Reconstruction? Which One?
)4.0cos(][ nnx )4.2cos()4.0cos(
integer an is Whennn
n
Given the samples, draw a sinusoid through the values
3/9/2018 © 2003, JH McClellan & RW Schafer 12
STORING DIGITAL SOUND
x[n] is a SAMPLED SINUSOID 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
3/9/2018 © 2003, JH McClellan & RW Schafer 13
sfsTnAnx
ˆ)ˆcos(][
)cos()(][)cos()(
ss nTAnTxnxtAtx
DISCRETE-TIME SINUSOID
Change x(t) into x[n] DERIVATION
))cos((][ nTAnx s
DEFINE DIGITAL FREQUENCY
3/9/2018 © 2003, JH McClellan & RW Schafer 14
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
ss f
fT 2ˆ
3/9/2018 © 2003, JH McClellan & RW Schafer 15
4-2 Spectrum View of Sampling
sff 2ˆ
kHz1sf
12 X1
2 X*
2–0.2
))1000/)(100(2cos(][ nAnx
3/9/2018 © 2003, JH McClellan & RW Schafer 16
Spectrum (Digital)
ˆ 2s
ff
fs 100 Hz
12 X1
2 X*
2–2
?
x[n] is zero frequency???
))100/)(100(2cos(][ nAnx
3/9/2018 © 2003, JH McClellan & RW Schafer 17
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
ˆ ˆcos( ) cos(( 2 ) )A n A n
3/9/2018 © 2003, JH McClellan & RW Schafer 18
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
3/9/2018 © 2003, JH McClellan & RW Schafer 19
Aliasing Derivation–2
Other Frequencies give the same
ss f
fT 2ˆ 2
s
s
ss
s
ff
ff
fff 22)(2ˆ :then
ˆand we want: [ ] cos( )x n A n If x (t) A cos( 2( f f s )t ) t
nfs
3/9/2018 © 2003, JH McClellan & RW Schafer 20
Aliasing Conclusions
ADDING fs or 2fs or –fs to the FREQ of x(t) gives exactly the same x[n] The samples, x[n] = x(n/ fs ) are EXACTLY
THE SAME VALUES
GIVEN x[n], WE CAN’T DISTINGUISH fo FROM (fo + fs ) or (fo + 2fs )
3/9/2018 © 2003, JH McClellan & RW Schafer 22
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
3/9/2018 © 2003, JH McClellan & RW Schafer 23
SPECTRUM (MORE LINES)
12 X1
2 X*
2–0.2
12 X*
1.8
12 X
–1.8
))1000/)(100(2cos(][ nAnx
kHz1sf
sff 2ˆ
3/9/2018 © 2003, JH McClellan & RW Schafer 24
SPECTRUM (ALIASING CASE)
12 X*
–0.5
12 X
–1.5
12 X
0.5 2.5–2.5
12 X1
2 X* 12 X*
1.5
))80/)(100(2cos(][ nAnxkHz80sf
sff 2ˆ
3/9/2018 © 2003, JH McClellan & RW Schafer 25
SPECTRUM (FOLDING CASE)
ˆ 2s
ff
fs 125Hz
12 X*
0.4
12 X
–0.4 1.6–1.6
12 X1
2 X*
))125/)(100(2cos(][ nAnx
3/9/2018 © 2003, JH McClellan & RW Schafer 26
DIGITAL FREQ AGAIN
ss f
fT 2ˆ 2
22ˆ s
s ffT FOLDED ALIAS
ALIASING
3/9/2018 © 2003, JH McClellan & RW Schafer 27
EXAMPLE: SPECTRUM
x[n] = Acos(0.2n+) FREQS @ 0.2 and -0.2 ALIASES: {2.2, 4.2, 6.2, …} & {-1.8,-3.8,…} EX: x[n] = Acos(4.2n+)
ALIASES of NEGATIVE FREQ: {1.8,3.8,5.8,…} & {-2.2, -4.2 …}
3/9/2018 © 2003, JH McClellan & RW Schafer 28
FOLDING (a type of ALIASING)
EXAMPLE: 3 different x(t); same x[n]
])1.0(2cos[])1.0(2cos[]2)9.0(2cos[])9.0(2cos[))900(2cos(
])1.0(2cos[])1.1(2cos[))1100(2cos(])1.0(2cos[))100(2cos(
1000
nnnnnt
nntnt
fs
)1.0(210001002ˆ
900 Hz “folds” to 100 Hz when fs=1kHz
3/9/2018 © 2003, JH McClellan & RW Schafer 30
FREQUENCY DOMAINS
D-to-AA-to-Dx(t) y(t)x[n]
ff
f
y[n]
sff2ˆ
2sff 2ˆ
3/9/2018 © 2003, JH McClellan & RW Schafer 31
4-4 Discrete-to-ContinuousConversion
Create continuous y(t) from y[n] IDEAL If you have formula for y[n]
Replace n in y[n] with fst y[n] = Acos(0.2n+) with fs = 8000 Hz y(t) = Acos(2(800)t+)
COMPUTER D-to-AA-to-Dx(t) y(t)y[n]x[n]
3/9/2018 © 2003, JH McClellan & RW Schafer 32
D-to-A is Ambiguous!
ALIASING Given y[n], which y(t) do we pick ? ? ? Infinite number of y(t) Passing through the samples, y[n]
D-to-A reconstruction must choose one output
Reconstruct the SMOOTHEST one The LOWEST frequcney, if y[n] = sinusoid
3/9/2018 © 2003, JH McClellan & RW Schafer 33
SPECTRUM (ALIASING CASE)
ˆ 2s
ff
fs 80Hz
12 X*
–0.5
12 X
–1.5
12 X
0.5 2.5–2.5
12 X1
2 X* 12 X*
1.5
))80/)(100(2cos(][ nAnx
3/9/2018 © 2003, JH McClellan & RW Schafer 34
Reconstruction (D-to-A)
Convert stream of numbers to x(t) “Connect the dots” INTERPOLATION
y(t)
y[k]
kTs (k+1)Tst
INTUITIVE,conveys the idea
3/9/2018 © 2003, JH McClellan & RW Schafer 35
SAMPLE & HOLD DEVICE
Convert y[n] to y(t) y[k] should be the value of y(t) at t = kTs
Make y(t) equal to y[k] for kTs -0.5Ts < t < kTs +0.5Ts
y(t)
y[k]
kTs (k+1)Tst
STAIR-STEPAPPROXIMATION
3/9/2018 © 2003, JH McClellan & RW Schafer 39
EXPAND the SUMMATION
SUM of SHIFTED PULSES p(t-nTs) “WEIGHTED” by y[n] CENTERED at t=nTs
SPACED by Ts RESTORES “REAL TIME”
y[n]p( t nTs ) n
y[0]p(t) y[1]p(t Ts ) y[2]p(t 2Ts )
3/9/2018 © 2003, JH McClellan & RW Schafer 41
OPTIMAL PULSE ?
CALLED“BANDLIMITEDINTERPOLATION”
,2,for 0)(
for sin
)(
ss
TtT
t
TTttp
ttps
s