U of U CS 5785 - Digital filters and signal processing

Unformatted text preview:

Today Digital filters and signal processing Filter examples and properties FIR filters Filter design Implementation issuesDACsDACs PWMDSP Big PictureSignal Reconstruction Analog filter gets rid of unwanted high-frequency componentsData Acquisition Signal: Time-varying measurable quantity whose variation normally conveys information Quantity often a voltage obtained from some transducer  E.g. a microphone Analog signals have infinitely variable values at all timestimes Digital signals are discrete in time and in value Often obtained by sampling analog signals Sampling produces sequence of numbers• E.g. { ... , x[-2], x[-1], x[0], x[1], x[2], ... }  These are time domain signalsSampling Transducers Transducer turns a physical quantity into a voltage ADC turns voltage into an n-bit integer Sampling is typically performed periodically Sampling permits us to reconstruct signals from the world•E.g. sounds, seismic vibrations•E.g. sounds, seismic vibrations Key issue: aliasing Nyquist rate: 0.5 * sampling rate Frequencies higher than the Nyquist rate get mapped to frequencies below the Nyquist rate Aliasing cannot be undone by subsequent digital processingSampling Theorem Discovered by Claude Shannon in 1949:A signal can be reconstructed from its samples without loss of information, if the original signal has no frequencies above 1/2 the sampling frequency This is a pretty amazing result But note that it applies only to discrete time, not discrete valuesAliasing Details Let N be the sampling rate and F be a frequency found in the signal Frequencies between 0 and 0.5*N are sampled properly Frequencies >0.5*N are aliased• Frequencies between 0.5*N and N are mapped to (0.5*N)-F and have phase shifted 180°F and have phase shifted 180°• Frequencies between N and 1.5*N are mapped to f-N with no phase shift• Pattern repeats indefinitely Aliasing may or may not occur when N == F*2*X where X is a positive integerNo Aliasing1 kHz Signal, No AliasingAliasingMore AliasingN == 2*F ExampleAvoiding Aliasing1. Increase sampling rate Not a general-purpose solution• White noise is not band-limited• Faster sampling requires:– Faster ADC–Faster CPU–Faster CPU– More power– More RAM for buffering2. Filter out undesirable frequencies before sampling using analog filter(s) This is what is done in practice Analog filters are imperfect and require tradeoffsSignal Processing PragmaticsAliasing in Space Spatial sampling incurs aliasing problems also Example: CCD in digital camera samples an image in a grid pattern Real world is not band-limited Can mitigate aliasing by increasing sampling rateSamples PixelPoint vs. SupersamplingPoint sampling 4x4 SupersamplingDigital Signal Processing Basic idea  Digital signals can be manipulated losslessly SW control gives great flexibility DSP examples Amplification or attenuationFiltering –leaving out some unwanted part of the signalFiltering –leaving out some unwanted part of the signal Rectification – making waveform purely positive Modulation – multiplying signal by another signal• E.g. a high-frequency sine waveAssumptions1. Signal sampled at fixed and known rate fs I.e., ADC driven by timer interrupts2. Aliasing has not occurred I.e., signal has no significant frequency components greater than 0.5*fgreater than 0.5*fs These have to be removed before ADC using an analog filter Non-significant signals have amplitude smaller than the ADC resolutionFilter Terms for CS People Low pass – lets low frequency signals through, suppresses high frequency High pass – lets high frequency signals through, suppresses low frequency Passband – range of frequencies passed by a filter Stopband – range of frequencies blocked Transition band – in between theseSimple Digital Filters y(n) = 0.5 * (x(n) + x(n-1)) Why not use x(n+1)? y(n) = (1.0/6) * (x(n) + x(n-1) + x(n-2) + … + y(n-5) ) y(n) = 0.5 * (x(n) + x(n-3))y(n) = 0.5 * (y(n-1) + x(n))y(n) = 0.5 * (y(n-1) + x(n)) What makes this one different? y(n) = median [ x(n) + x(n-1) + x(n-2) ]Gain vs. FrequencyGain1.01.5y(n) =(y(n-1)+x(n))/2y(n) =(x(n)+x(n-1))/2y(n) =(x(n)+x(n-1)+x(n-2)+ x(n-3)+x(n-4)+x(n-5))/6Gain0.00.50.0 0.1 0.2 0.3 0.4 0.5frequency f/fsy(n) =(x(n)+x(n-3))/2Useful Signals Step:  …, 0, 0, 0, 1, 1, 1, …1Step s(n) Impulse:  …, 0, 0, 0, 1, 0, 0, …-3 -2 -1 0 1 2 31Impulse i(n)-10 -2-31 2 3Step Response0.60.81step inputFIRResponse0 1 2 3 4 500.20.4sample number, nIIRmedianResponseImpulse Response0.60.81impulse inputFIRResponse0 1 2 3 4 500.20.4sample number, nFIRIIRmedianResponseFIR Filters Finite impulse response Filter “remembers” the arrival of an impulse for a finite time Designing the coefficients can be hard Moving average filter is a simple example of FIRMoving Average ExampleFIR in CSAMPLE fir_basic (SAMPLE input, int ntaps, const SAMPLE coeff[], SAMPLE z[]) {z[0] = input;SAMPLE accum = 0; SAMPLE accum = 0; for (int ii = 0; ii < ntaps; ii++) { accum += coeff[ii] * z[ii]; }for (ii = ntaps - 2; ii >= 0; ii--) { z[ii + 1] = z[ii]; } return accum; }Implementation Issues Usually done with fixed-point How to deal with overflow? A few optimizations Put coefficients in registers Put sample buffer in registers Block filter• Put both samples and coefficients in registers• Unroll loops Hardware-supported circular buffers  Creating very fast FIR implementations is importantFilter Design Where do coefficients come from for the moving average filter? In general:1. Design filter by hand2. Use a filter design toolFew filters designed by hand in practiceFew filters designed by hand in practice Filters design requires tradeoffs between1. Filter order2. Transition width3. Peak ripple amplitude Tradeoffs are inherentFilter Design in Matlab Matlab has excellent filter design support C = firpm (N, F, A) N = length of filter - 1 F = vector of frequency bands normalized to Nyquist A = vector of desired amplitudesfirpmuses minimax –it minimizes the maximum firpmuses minimax –it minimizes the maximum deviation from the desired amplitudeFilter Design Examplesf = [ 0.0 0.3 0.4 0.6 0.7 1.0]; a = [ 0 0 1 1 0 0];fil1 = firpm( 10, f, a);fil2 =


View Full Document

U of U CS 5785 - Digital filters and signal processing

Download Digital filters and signal processing
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Digital filters and signal processing and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Digital filters and signal processing 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?