Transcript Document

Electronics
Principles & Applications
Sixth Edition
Charles A. Schuler
Chapter 16
Digital Signal Processing
(student version)
©2003
Glencoe/McGraw-Hill
INTRODUCTION
• Overview
• Moving-Average Filters
• Fourier Theory
• Digital Filter Design
• Other DSP Applications
• DSP Limitations
• Troubleshooting
Dear Student:
This presentation is arranged in segments.
Each segment is preceded by a Concept
Preview slide and is followed by a Concept
Review slide. When you reach a Concept
Review slide, you can return to the
beginning of that segment by clicking on the
Repeat Segment button. This will allow you
to view that segment again, if you want to.
Concept Preview
• Continuous signals are converted to discrete
form for digital signal processing. The
conversion process takes place in an A/D
converter and is called sampling.
• An anti-alias filter prevents high frequency
signals and noise from interfering with the
frequencies of interest.
• Anti-alias filters are low-pass types.
• DSP eliminates problems with component
tolerance, aging and temperature.
• DSP provides functions that analog techniques
cannot.
Block Diagram of a Typical DSP System
Continuous
signal
Anti-alias
filter
LPF
A/D
Discrete
signal
Reconstruction
filter
DSP
D/A
Discrete
signal
LPF
Continuous
signal
The anti-alias filter is necessary because a
higher frequency signal or noise can show
up as a lower frequency alias.
The 3 kHz signal and the 1 kHz signal
produce identical discrete samples.
Why Bother with DSP?
Consider a LPF with unity gain to 1 kHz, passband ripple of 1
dB or less, and at least 80 dB of attenuation above 2 kHz. This
8th order Chebyshev should meet the requirements.
0 dB
NOMINAL RESPONSE
OF THE 8TH ORDER FILTER
The requirements appear
to have been satisfied.
- 60
1
10
100
Frequency in Hz
1k
MONTE CARLO ANALYSIS
[10 TRIALS, 5% TOLERANCE]
+6 dB
0 dB
- 4 dB
Unfortunately, there are
production problems when
using 5% tolerance components.
- 60
1
10
100
Frequency in Hz
1k
MONTE CARLO ANALYSIS
[10 TRIALS, 1% TOLERANCE]
0 dB
The purchasing agent laughs when
asked about 1% capacitors!
What about temperature
and component aging?
- 60
1
10
100
Frequency in Hz
1k
DSP eliminates the effects of:
Component tolerance
Temperature
Component aging
Also, DSP makes possible:
Adaptive filters
Software updates
Functions impossible with analog
Overview Quiz
A 200 Hz signal produced by sampling
a 4 kHz signal is called an _________.
Anti-alias filters have a ________
frequency response.
The signal going into an A/D converter
is called analog or _________.
The signal coming out of an A/D converter
is called digital or __________.
alias
low-pass
continuous
discrete
DSP eliminates problems with component
tolerance, aging, and __________.
temperature
Concept Review
• Continuous signals are converted to discrete form
for digital signal processing. The conversion
process takes place in an A/D converter and is
called sampling.
• An anti-alias filter prevents high frequency signals
and noise from interfering with the frequencies of
interest.
• Anti-alias filters are low-pass types.
• DSP eliminates problems with component
tolerance, aging and temperature.
• DSP provides functions that analog techniques
cannot.
Repeat Segment
Concept Preview
• A moving average low-pass filter will reduce
high-frequency noise and interference.
• The basic process in DSP is MAC (multiply and
accumulate). The formal name is convolution.
• The symbol for convolution is *.
• The discrete signal samples are multiplied by
coefficients (also called taps).
• Subtracting the moving average will reduce
low-frequency noise and hum (high-pass filter).
• DSP is very flexible as it is controlled by
software.
Moving Average Low-pass Filter
How the Moving Average Smooths the Response
1/ Add the first 3 values.
2/ Calculate the average.
3/ Convert to analog.
4/ Add 2nd, 3rd, 4th values.
5/ Calculate the average.
6/ Convert to analog.
7/ Add 3rd, 4th, 5th values.
8/ Calculate the average.
9/ Etc.
Block Diagram of the Moving Average Low-pass Filter
clock
A/D
x(n)
Formal Terminology
delay
delay
0.333
0.333
The filter coefficients
(also called taps) are 0.333
h(1) = 0.333, h(2) = 0.333, h(3) = 0.333
convolution  y(n) = x(n)  h(n)
y(n)
D/A
0.333
DSP chips employ circular buffers and
optimized MAC (multiply and accumulate).
Some DSP chips MAC in one clock cycle.
Moving Average High-pass Filter
Block Diagram of the Moving Average High-pass Filter
input
A/D
delay
delay
delay
- 0.333
1.000
- 0.333
clock
THE FILTER COEFFICIENTS:
- 0.333
- 0.333
1.000
- 0.333
D/A
output
- 0.333
Basic architecture (MAC) never changes
and software provides endless possibilities!
Moving Average Filter Quiz
The basic frequency response of a
moving average filter is __________.
The coefficients of a moving average
filter are also called __________.
The formal name for multiply and
accumulate is ________________.
The symbol for convolution is ________.
How many time delays are there in
a seventeen tap filter? ________
low-pass
taps
convolution
*
sixteen
Concept Review
• A moving average low-pass filter will reduce
high-frequency noise and interference.
• The basic process in DSP is MAC (multiply and
accumulate). The formal name is convolution.
• The symbol for convolution is *.
• The discrete signal samples are multiplied by
coefficients (also called taps).
• Subtracting the moving average will reduce
low-frequency noise and hum (high-pass filter).
• DSP is very flexible as it is controlled by
software.
Repeat Segment
Concept Preview
• A Fourier series can be used to synthesize
periodic waveforms.
• Signals can be viewed in two domains: time
(oscilloscope) or frequency (spectrum
analyzer).
• The Fourier transform converts from the time
domain to the frequency domain.
• When waveforms with discontinuities are
synthesized with a long Fourier series, there are
distortions due to Gibb’s phenomenon.
• The lowest workable sampling frequency is half
the signal bandwidth.
Fourier Synthesis
+15 V
+3 V
0V
0V
-15 V
0
-3 V
1 ms
0
1 ms
1 kW
1 kW
1 kW
1 kW
1 kHz
9V
3 kHz
3V
5 kHz
1.8 V
7 kHz
1.29 V
1 kW
(spectrum analyzer)
(oscilloscope)
Amplitude
The frequency
domain is a
second point
of view.
Frequency
Two Basic Functions of Fourier Theory
[decompose]
Fourier transform
2 views
of the
same
thing
time domain
frequency domain
[synthesize]
Inverse Fourier transform
The core ideas: Signals can be decomposed into sinusoids.
(Signals can be decomposed into a series of single frequencies.)
(Signals can be synthesized using a series of sinusoids.)
As more harmonics
are included, the
square wave approaches
the ideal. However,
there is a problem.
Discontinuities (abrupt changes) in a square
wave give rise to Gibb’s phenomenon.
Gibb’s phenomenon
Rate of change
approaching
infinity!
This Fourier square wave was
generated with 50 odd harmonics.
(In an ideal square wave, the transition time is 0.)
The sampling frequency (fs) is an important factor.
(How low can fs be before information is lost?)
Discrete
signal
CLOCK
Continuous
signal
fs
LPF
DSP
A/D
D/A
LPF
Sampling Theory
Continuous signal
time
Spectrum of
continuous
signal
frequency
LSB
USB
LSB
USB
0
LSB
USB
Spectrum of
sampled signal
LSB
USB
Signal after being sampled
at 4 x highest frequency
fs
2fs
3fs
4fs
Same Signal Sampled at 2 x Highest Frequency
Spectrum of
sampled signal
0
fs
2fs
3fs
4fs
5fs
6fs
At any lower sampling rate, the sidebands will
overlap and the information will be corrupted.
This is known as Shannon’s sampling theorem.
Fourier Theory Quiz
The Fourier transform can convert from
the time domain to the __________ domain. frequency
An oscilloscope displays in the __________
domain.
A spectrum analyzer displays in the
__________ domain.
Synthesis of functions with discontinuities
causes distortions called __________
phenomenon.
The lowest sampling rate for a signal
with a bandwidth of 5 kHz is _________.
time
frequency
Gibb’s
10 kHz
Concept Review
• A Fourier series can be used to synthesize periodic
waveforms.
• Signals can be viewed in two domains: time
(oscilloscope) or frequency (spectrum analyzer).
• The Fourier transform converts from the time
domain to the frequency domain.
• When waveforms with discontinuities are
synthesized with a long Fourier series, there are
distortions due to Gibb’s phenomenon.
• The lowest workable sampling frequency is half the
signal bandwidth.
Repeat Segment
Concept Preview
• Finite impulse response (FIR) filters can be
designed using the windowed sinc function (the
coefficients follow the sin(x)/x function).
• FIR filters usually have symmetrical
coefficients (for a linear phase response).
• The impulse response of an FIR filter is
equivalent to a graph of its coefficients.
• Group delay in an FIR filter is proportional to
the number of taps and inversely proportional
to the sampling frequency.
Block Diagram of a 9 Tap FIR Low-pass Filter
A/D
800 Hz
clock
1 delay = 1.25 ms and the group delay = 5 ms
delay
delay
delay
delay
delay
delay
delay
delay
- 0.111
- 0.059
0.320
0.556
0.320
- 0.059
- 0.111
0.073
(N –1)/2
group delay =
fs
0.073
coefficient
symmetry
0.073 = 0.073
-0.111 = -0.111
-0.059 = -0.059
0.320 = 0.320
0.556
D/A
sinc
function
passband
transition
amplitude
Where do the FIR filter coefficients come from?
One approach is the windowed sinc design method.
stopband
frequency
IDFT
h (n) =
1
sin(pnK/N)
N
sin(pn/N)
Where h (n) represents the filter coefficients.
Example: sampling frequency = 800 Hz
9 tap filter: N = 9
cutoff frequency = 200 Hz
K=5
800/N-1 = 100 Hz
-400 Hz
0 Hz
+400 Hz
K
h (0) =
N
h (n) =
5
h (0) =
1
= 0.556
9
h (3) =
1
sin(pnK/N)
N
sin(pn/N)
sin(p*3*5/9)
= -0.111
9
sin(p*3/9)
A/D
800 Hz
clock
delay
h(3)
- 0.111
delay
- 0.059
delay
0.320
delay
delay
delay
delay
0.556
0.320
- 0.059
- 0.111
h(0)
0.073
D/A
h(3)
delay
0.073
Frequency and Impulse Response
for the 9-tap Fir Filter
UNIT
IMPULSE
RESPONSE
coefficients
0.556
0
- 0.111
FREQUENCY
RESPONSE
[combined time/frequency axis]
FIR means Finite Impulse Response
clock
A/D
delay
delay
delay
delay
delay
delay
delay
delay
- 0.111
- 0.059
0.320
0.556
0.320
- 0.059
- 0.111
0.073
After the impulse,
the output settles
to zero.
0.073
D/A
filter
Frequency Response (9 Tap Fir)
+ 180°
phase
discontinuities
0°
- 180°
0 Hz
phase wrap
200 Hz
400 Hz
PHASE RESPONSE
FIR filters have linear phase response in the passband!
(when the filter coefficients are symmetrical)
180º at 100 Hz
+ 180°
N-1
Delay =
2fs
8
Delay =
= 5 ms
1600
0°
360º at 200 Hz - 180°
0 Hz
200 Hz
delay1 = / = p/2pf = 5 ms & delay2 = / = 2p/2pf = 5 ms
(180° = p radians) (360° = 2p radians)
( = radians/sec)
Group delay is a function of the number
of taps and the sampling frequency.
Concept Review
• Finite impulse response (FIR) filters can be
designed using the windowed sinc function (the
coefficients follow the sin(x)/x function).
• FIR filters usually have symmetrical
coefficients (for a linear phase response).
• The impulse response of an FIR filter is
equivalent to a graph of its coefficients.
• Group delay in an FIR filter is proportional to
the number of taps and inversely proportional
to the sampling frequency.
Repeat Segment
Concept Preview
• Changing the sign of every other coefficient will
transform an FIR low-pass filter to high-pass.
• Increasing the number of taps will make the
transition bandwidth smaller.
• FIR filter response shows Gibb’s phenomenon
due to truncation of the sinc function.
• The truncated coefficients (and the response)
are smoothed by applying a window function.
• Extremely sharp FIR filters are possible but the
large number of taps required can require too
much processing time.
The LP filter
easily
to high-pass
The is
9 tap
FIRconverted
low-pass filter
clock
A/D
Changing the sign of every other
coefficient will reverse the response.
delay
delay
delay
delay
delay
delay
delay
delay
- 0.111
- 0.059
0.059
0.320
- 0.556
0.556
0.320
- 0.059
0.059
- 0.111
-0.073
0.073
- 0.073
0.073
D/A
filter
9-Tap, FIR High-Pass Filter
0 Hz
200 Hz
400 Hz
Adding taps will make the transition bandwidth smaller.
(A more ideal filter)
51 taps
0 Hz
9 taps
200 Hz
400 Hz
But Gibb’s phenomenon is a problem!
The Sinc Function
The ideal series h(n) produced by the IDFT is infinite.
People (and computers) can’t deal with infinity; thus
the series must be truncated. This gives rise to
discontinuities and Gibb’s phenomenon.
The practical h(n) is a
truncated infinite series.
truncation
truncation
The series h(n) can be passed through a window that
smooths the truncation discontinuities to reduce this effect.
A Blackman window suppresses Gibb’s phenomenon.
w(n)
n
51 taps with
Blackman
window
General
shape of
Blackman
window
0 Hz
The tradeoff:
The transition
bandwidth is
larger.
200 Hz
w(n) = 0.42 + 0.5 cos (2pn/N) + 0.08 cos (4np/N)
[where n ranges from –N/2 to N/2]
400 Hz
Suppose we need a narrow transition bandwidth
(perhaps 20 Hz with fs = 1 kHz)
4
N 
TBW
fs
(log response)
 70 dB

200 tap filter
response
(linear)
0 Hz
250 Hz
4
20
1000
 200
500 Hz
Even with a Blackman window, a very sharp filter can be realized.
A 200-tap filter might not
be acceptable.
The problem is that of efficiency and
the time required to process signals.
As with analog filters, it is possible
to improve performance by using
feedback. Feedback filters are called
recursive or IIR.
Concept Review
• Changing the sign of every other coefficient will
transform an FIR low-pass filter to high-pass.
• Increasing the number of taps will make the
transition bandwidth smaller.
• FIR filter response shows Gibb’s phenomenon
due to truncation of the sinc function.
• The truncated coefficients (and the response)
are smoothed by applying a window function.
• Extremely sharp FIR filters are possible but the
large number of taps required can require too
much processing time.
Repeat Segment
Concept Preview
• IIR means infinite impulse response.
• IIR filters (also called recursive filters) use
feedback.
• IIR filters are more efficient (don’t need as
many taps) and are faster than FIR filters.
• IIR filters can oscillate.
• IIR filters do not have a linear phase response.
• Band-pass and band-stop filters can be realized
by combining low-pass and high-pass
responses.
IIR means Infinite Impulse Response
[Exponential decay never reaches 0.]
A/D
feed forward coefficients (a)
delay
a1
delay
delay
a2
a3
feed back coefficients (b)
delay
b1
a0 Of course, infinite output
means an oscillator and
that must be avoided!
clock
D/A
delay
b2
delay
b3
Decaying response
The output
can increase
with no end.
FIR and IIR Compared
Characteristic
FIR
IIR
Efficiency
Low
High
Speed
Slow
Fast
Coefficient sensitivity
Overflow
Stability
Phase response
Low
Not Likely
Guaranteed
Linear
High
Likely
Design issue
Non-linear
Analog modeling
Design/noise analysis
Arbitrary filters
Not directly
Straightforward
Straightforward
Yes
Complicated
Complicated
Linear phase is
important in
telecommunications
where the signal
components must
arrive at the detector
at the same time.
ideal
linear phase
non-linear phase
Also important in digital signaling where pulse shape is an issue.
Bandpass and Bandstop Realization
hlp(n)  hhp(n)
convolution
hlp(n) + hhp(n)
Filter Design Quiz
Transition bandwidth can be reduced by
increasing the number of __________.
taps
The impulse response of an FIR low-pass
filter is called the __________ function.
sinc
FIR filter coefficients are smoothed by passing
them through a __________ function.
window
FIR filters are noted for their
__________ phase response.
Digital filters that use feedback are known
as recursive or __________ types.
linear
IIR
Concept Review
• IIR means infinite impulse response.
• IIR filters (also called recursive filters) use
feedback.
• IIR filters are more efficient (don’t need as
many taps) and are faster than FIR filters.
• IIR filters can oscillate.
• IIR filters do not have a linear phase response.
• Band-pass and band-stop filters can be realized
by combining low-pass and high-pass
responses.
Repeat Segment
Concept Preview
• The sampling rate of a discrete signal can be
increased by zero stuffing (interpolation).
• The sampling rate of a discrete signal can be
decreased by discarding samples (decimation).
• DSP systems that use interpolation and/or
decimation are called multi-rate.
• Interpolation can relax the requirements for
the reconstruction filter.
• Decimation can make more time available for
complex operations.
SSB generation using
the phasing method
(in-phase)
(quadrature)
In-phase and quadrature signal components are
common in modulation and demodulation systems.
SSB generation
using DSP
Up-sampling
(zero-stuffing)
SSB Demodulation Using DSP
Down-sampling
(discard samples)
Note: multi-rate systems are those that
use interpolation, decimation, or both.
AM Demodulation Using DSP
This operation
takes time!
Since decimation decreases the sampling rate,
it can make more time available for processing.
This can be important in real-time applications.
DAC output without interpolation
DAC output with interpolation
Applications Quiz
Up-sampling a signal by zero stuffing is
called __________.
interpolation
Down-sampling a signal by discarding
samples is called __________.
decimation
The quadrature part of a digital signal can
be formed by using a __________ filter.
Hilbert
Up-sampling before the DAC can relax
the __________ filter requirements.
reconstruction
Multi-rate systems use decimation
and/or __________.
interpolation
Concept Review
• The sampling rate of a discrete signal can be
increased by zero stuffing (interpolation).
• The sampling rate of a discrete signal can be
decreased by discarding samples (decimation).
• DSP systems that use interpolation and/or
decimation are called multi-rate.
• Interpolation can relax the requirements for
the reconstruction filter.
• Decimation can make more time available for
complex operations.
Repeat Segment
Concept Preview
• The attenuation of the anti-alias filter at half
the sampling frequency should be equal to or
greater than the signal to noise ratio (SNR) of
the analog to digital converter.
• The number of bits determines the SNR of the
A/D converter.
• Due to DAC performance, 1/sinc correction
might be needed in some DSP systems.
• Interpolation can eliminate the need for 1/sinc
correction.
DSP Limitations
• aliasing (added spectral components
caused by sampling)
• quantization noise (error)
• idle channel noise (random switching
of the lsb)
• dynamic range (A/D and/or processor
overflow)
• speed (frequency limits … improving
but still a factor)
• clock feedthrough
Aliasing
A 200 Hz continuous
signal after sampling
A 5.2 kHz continuous
signal after sampling
Both signals were sampled at a 5 kHz rate.
What would a 4.8 kHz signal look like?
[same as above but phase inverted]
Signals (and noise) above fs/2 can alias into
the operating range of a DSP system.
What are the requirements for this filter?
anti-alias
filter
LPF
A/D
continuous
discrete
reconstruction
filter
DSP
D/A
LPF
continuous
discrete
attenuation
The anti-alias filter is an analog type (either active
or passive) and provides a low-pass response.
0 dB
A
fs/2
The attenuation (A) of the anti-alias filter at fs/2 should
be equal to or greater than the SNR of the ADC.
Signal to noise ratiodb = 6.02n + 1.76
Quantization Error
Continuous signal
Amplitude
Discrete values
Time
Less Quantization Error (more bits)
Continuous signal
Amplitude
Discrete values
Time
Quantization Error (noise)
Vnoise(rms) =
Vfull-scale • 0.289
2n
Signal to noise ratiodb = 6.02n + 1.76
The noise voltage for a 5 volt range:
5.64 mV in an 8 bit system
353 V in a 12 bit system
What are the requirements for this filter?
anti-alias
filter
continuous
LPF
A/D
discrete
reconstruction
filter
DSP
D/A
LPF
continuous
discrete
The reconstruction filter is an
analog type and may
incorporate a 1/sinc correction.
sinc function =
sin(pf/fs)
pf/fs
Zeroth-order hold DAC
(1/sinc correction is included in some chips … CODECs)
A zeroth-order hold DAC alters the spectrum.
sinc function =
holds
sin(pf/fs)
pf/fs
1
0
fs
The higher frequencies are attenuated by the sinc effect.
1
sinc
D/A
sinc
1
0
Reconstructed
signal
LPF
1
sinc
Ideal
reconstruction
filter response
curve
1
0
fs
fs
2
1/sinc correction can be applied before, or
after, the digital-to-analog converter.
sinc
If fs is high enough, 1/sinc
correction is not needed.
1
0
fs
Remember, interpolation increases the
sampling rate and can be used to
eliminate the need for 1/sinc correction.
Limitations Quiz
The signal to noise ratio can be increased
by __________ the number of bits.
increasing
Anti-alias filter attenuation at fs/2 should
at least equal the ADC’s __________.
SNR
1/sinc correction compensates for the frequency
response of zeroth-order hold __________.
DACs
Quantization error is also called
quantization __________.
noise
Troubleshooting
•
•
•
•
•
•
•
•
•
•
•
Take a system view.
Check software.
Consider recent history.
Verify power supplies.
Check grounds.
Check inputs and outputs.
Connect instrument grounds properly.
Verify clock signals.
Verify proper logic levels.
Check bus activity, interrupts, etc.
Verify reset signal.
Bad solder joints can be located by pushing
down on the SMT IC pins with an insulating tool.
DSP Design and Development
• Design software (type, order, coefficients,
etc.)
• Software libraries (often used routines)
• Assembly source code (DSP chip specific)
• Object code (to be stored in the DSP ROM)
• Software simulators often used
• Hardware emulators test in the actual
environment
Concept Review
• The attenuation of the anti-alias filter at half
the sampling frequency should be equal to or
greater than the signal to noise ratio (SNR) of
the analog to digital converter.
• The number of bits determines the SNR of the
A/D converter.
• Due to DAC performance, 1/sinc correction
might be needed in some DSP systems.
• Interpolation can eliminate the need for 1/sinc
correction.
Repeat Segment
REVIEW
• Overview
• Moving-Average Filters
• Fourier Theory
• Digital Filter Design
• Other DSP Applications
• DSP Limitations
• Troubleshooting