Sampling, Reconstruction, and Elementary Digital Filters

Download Report

Transcript Sampling, Reconstruction, and Elementary Digital Filters

Sampling, Reconstruction, and
Elementary Digital Filters
R.C. Maher
ECEN4002/5002 DSP Laboratory
Spring 2002
Sampling and Reconstruction
• Need to understand relationship between a
continuous-time signal f(t) and a discretetime (sampled) signal f(kT), where T is the
time between samples (T=1/fs)
1
f (kT ) 
2
ECEN4002 Spring 2002

F
(
j

)
e

jkT
d

Delay Lines and Simple Filters
R. C. Maher
2
Sampling (cont.)
• After some manipulation, can show:

T
f (kT ) 
2
1   
2 n   jkT
F  j   
  e d
 T n
T  

 


T
T


 
2 n  
1 1
 DTFT   F  j   
 
T  
T n    
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
3
Sampling Effects: Frequency Domain
Xc(j)
-N
S > 2 N
Fourier Transform of
continuous function

N
Fourier Transform of
sampled function
XS(j)
-2S
-S
-N
S < 2 N (aliasing)
S
2S

XS(j)
-2S -S
ECEN4002 Spring 2002
N
S
Delay Lines and Simple Filters

2S
R. C. Maher
4
Reconstruction
• Since spectrum of sampled signal consists of
baseband spectrum and spectral images shifted at
multiples of 2π/T, reconstruction means isolating
the baseband image
• Concept: lowpass filter to pass baseband while
removing images
XS(j)
-2S
ECEN4002 Spring 2002
-S
-N
N
Delay Lines and Simple Filters
S
2S

R. C. Maher
5
Reconstruction (cont.)
• Multiplication by rectangular pulse in
frequency domain (LPF) corresponds to
convolution by sinc( ) function in time
domain
• Because sinc( ) is non-causal and of infinite
extent, practical reconstruction requires an
approximation to the ideal case
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
6
Delay Lines
• In order to create a frequency-selective
function, there must be a delay memory so
that the function is able to observe and
resolve the frequencies present in the signal
• Digital filters used tapped delay lines to
create the z-1 (delay) terms in the ztransform
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
7
Delay Lines (cont.)
x[n]
Z-1
h0
Z-1
h1
Z-1
h2
+
y[n]
x[n-1]
x[n-2]
x[n-3]
h3
3
H ( z )   hn z n
n 0
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
8
Delay Lines (cont.)
• Delay lines can be implemented easily as a
one dimensional array or FIFO in DSP
memory
• Typically use an address register to point to
array, then just increment pointer instead of
copying data to achieve the delay
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
9
Modulo Buffers
• DSP supports modulo arithmetic in the
address generation unit
• With modulo buffer, incrementing or
decrementing address register “rolls over”
automatically at beginning and ending of
buffer memory range
• Modulo buffers are useful for delay stages
in filters and other FIFO queue structures
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
10
Modulo Buffers (cont.)
• Modulo calculations keep address pointer
within a fixed range of memory locations
Base Address + N -1
N memory
locations
Modulo N
Buffer
Memory
Base Address
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
11
56300 Modulo Buffers
• The M registers in the AGU select the
modulo size of the buffer
– M = $FFFFFF implies no modulo (regular
linear addressing)
– M = 0 implies bit-reversed addressing (useful in
FFT algorithms)
– M = ‘modulo’-1 implies address range
including ‘modulo’ memory locations
(2modulo  $7FFF)
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
12
56300 Modulo (cont.)
• The base address of the modulo buffer must
be a power of 2
• The base address must either be zero, or a
power of 2 that is greater than or equal to
the modulo
• In other words, the base address must be 2k,
where 2kmodulo, which implies k least
significant bits must be zero
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
13
FIR Filter
• FIR filter coefficients are equal to the unit
sample response of the filter
• Given filter specifications, we need to
choose a unit sample response that is
“close” to the desired response, yet within
the implementation constraints (memory,
computational complexity, etc.)
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
14
FIR Filter Design
• Several FIR design techniques are available
• Consider the Window method:
– Determine ideal response function
– If length of ideal function is too long, multiply
ideal response by a finite length window
function
– Note that multiplication by window in time
domain means convolution (and smearing) in
the frequency domain
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
15
FIR Window Design Concept
• Lowpass filter: cutoff at 0.2 fs .
Amplitude (linear scale)
1.2
1
0.8
0.6
0.4
0.2
0
ECEN4002 Spring 2002
0
0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Frequency (fraction of fs)
Delay Lines and Simple Filters
R. C. Maher
16
FIR Design Concept (cont.)
• Time domain response (Inverse DTFT)
0.4
0.35
0.3
Amplitude
0.25
0.2
0.15
0.1
0.05
0
-0.05
-0.1
-60
ECEN4002 Spring 2002
-40
-20
0
20
Sample Index
Delay Lines and Simple Filters
40
R. C. Maher
60
17
FIR Design Concept
• Window function to limit response length
1.2
1
Amplitude
0.8
Hamming
window
0.6
0.4
0.2
0
-0.2
-60
ECEN4002 Spring 2002
-40
-20
0
20
Sample Index
Delay Lines and Simple Filters
40
R. C. Maher
60
18
FIR Design Concept (cont.)
• Windowed and shifted (causal) result
0.4
0.35
0.3
Amplitude
0.25
0.2
0.15
0.1
0.05
0
-0.05
-0.1
0
ECEN4002 Spring 2002
5
10
15
20
25
Sample Index
Delay Lines and Simple Filters
30
35
40
R. C. Maher
19
FIR Design Concept
• Resulting frequency response of filter
10
Magnitude (dB)
0
-10
-20
-30
-40
-50
-60
ECEN4002 Spring 2002
0
0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Frequency (fraction of fs)
Delay Lines and Simple Filters
R. C. Maher
20
Lab Assignment #2
• Due at START of class in two weeks
• Topics:
–
–
–
–
–
–
Sampling and reconstruction (MATLAB)
Program #1: Cycle counting
Program #2: Simple delay line
Program #3: File I/O via Debugger
Program #4: FIR filter, non-real time
Program #5: FIR filter, real time
ECEN4002 Spring 2002
Delay Lines and Simple Filters
R. C. Maher
21