Digital Signal ProcessingFIR & IIRDr. Arjon Turnip*
DSPAJT
Digital Filters*
y(t)
x(t)
C
A
D
C
D
A
Sampling frequency fS
Analog smoothing filter
Analog anti-aliasing filter
Digital Filter
yn
xn
Digital Filter
n
y
n
x
DSPAJT
Input and Output*Fourier Transforms Z Transfer Function
DSPAJT
Rational z Transfer Function* Linear equation with constant coefficients.
DSPAJT
Ideal Filters*One of the reasons why we design a filter is to remove disturbancesWe discriminate between signal and noise in terms of the frequency spectrum
DSPAJT
Ideal Filters*Problem: ideally we do not want the filter to distort the signal we want to recover.IDEALFILTERSame shape as s(t), just scaled and delayed.Consequence on the Frequency Response:constantlinear
DSPAJT
Types of Transfer Functions*The time-domain classification of an LTI digital transfer function sequence is based on the length of its impulse response:- Finite impulse response (FIR) transfer function- Infinite impulse response (IIR) transfer functionIn the case of digital transfer functions with frequency-selective frequency responses, there are two types of classifications(1) Classification based on the shape of the magnitude function |H (e j) |(2) Classification based on the the form of the phase function ()
DSPAJT
Classification: Magnitude Characteristics*One common classification is based on an ideal magnitude responseA digital filter designed to pass signal components of certain frequencies without distortion should have a frequency response equal to one at these frequencies, and should have a frequency response equal to zero at all other frequenciesThe range of frequencies where the frequency response takes the value of one is called the passbandThe range of frequencies where the frequency response takes the value of zero is called the stopband
DSPAJT
Digital Filters with Ideal Magnitude Responses*Frequency responses of the four popular types of ideal digital filters with real impulse response coefficients are shown below:
DSPAJT
Digital Filters with Ideal Magnitude Responses*Lowpass filter: Passband -0c Stopband -cHighpass filter: Passband -c Stopband -0cBandpass filter: Passband -c1c2 Stopband -0c1 and c2 Bandstop filter: Stopband -c1c2Passband -0c1 and c2 The frequenciesc ,c1 ,andc2 are called the cutoff frequencies
DSPAJT
Digital Filters with Ideal Magnitude Responses*Moreover, the magnitude response is allowed to vary by a small amount both in the passband and the stopbandTypical magnitude response specifications of a lowpass filter are shown the right
DSPAJT
Classification: Phase Characteristics*A second classification of a transfer function is with respect to its phase characteristicsIn many applications, it is necessary that the digital filter designed does not distort the phase of the input signal components with frequencies in the passbandOne way to avoid any phase distortion is to make the frequency response of the filter real and nonnegative, i.e., to design the filter with a zero phase characteristicHowever, it is not possible to design a causal digital filter with a zero phaseThe function filtfilt implements the above zero-phase filtering schemeIn the case of a causal transfer function with a nonzero phase response, the phase distortion can be avoided by ensuring that the transfer function has a unity magnitude and a linear-phase characteristic in the frequency band of interest
DSPAJT
Classification: Phase Characteristics*The most general type of a filter with a linear phase has a frequency response given by H(ej)=e-jD which has a linear phase from =0 to =2Note also |H(ej)|=1 ()=D The output y[n] of this filter to an input x[n]=Aejn is then given by y[n]=Ae-jDejn=Aej(n-D)If xa(t) and ya(t) represent the continuous-time signals whose sampled versions, sampled at t = nT ,are x[n] and y[n] given above, then the delay between xa(t) and ya(t) is precisely the group delay of amount D
DSPAJT
Classification: Phase Characteristics*If D is an integer, then y[n] is identical to x[n], but delayed by D samplesIf D is not an integer, y[n], being delayed by a fractional part, is not identical to x[n]In the latter case, the waveform of the underlying continuous-time output is identical to the waveform of the underlying continuous-time input and delayed D units of timeIf it is desired to pass input signal components in a certain frequency range undistorted in both magnitude and phase, then the transfer function should exhibit a unity magnitude response and a linear-phase response in the band of interest
DSPAJT
Classification: Phase Characteristics*Figure below shows the frequency response if a lowpass filter with a linear-phase characteristic in the passbandSince the signal components in the stopband are blocked, the phase response in the stopband can be of any shapeExample Determine the impulse response of an ideal lowpass filter with a linear phase response:
DSPAJT
IIR and FIR Filters*IIR = Infinite Impulse ResponseFIR = Finite Impulse ResponseFIRIIR
DSPAJT
FIR and IIR*FIR: output yn is a linear combination of a finite number of input samples.
IIR: output yn is a linear combination of a finite number of input and of output samples. Recursive form.Advantages: always stable, the phase can be made exactly linear, we can approximate any filter we want;Disadvantages: we need a lot of coefficients (Q large) for good performance;Advantages: very selective with a few coefficients;Disadvantages: non necessarily stable, non linear phase.
DSPAJT
Causality and Stability*A filter is causal if hn=0 for n < 0A filter is stable if the output is bounded for any bounded input.Condition for stability is:All the poles of H(z) are inside the unit circleFIR are always stable.Or:
DSPAJT
*Digital Filter SpecificationsFor example the magnitude response of a digital lowpass filter may be given as indicated belowIn the passband we require that with a deviation
In the stopband we require that with a deviation
DSPAJT
*Filter specification parameters - passband edge frequency - stopband edge frequency - peak ripple value in the passband - peak ripple value in the stopbandDigital Filter SpecificationsPractical specifications are often given in terms of loss function (in dB) Peak passband ripple dBMinimum stopband attenuation dB
DSPAJT
*In practice, passband edge frequency and stopband edge frequency are specified in HzFor digital filter design, normalized bandedge frequencies need to be computed from specifications in Hz using
Digital Filter Specifications
DSPAJT
*Example - Let kHz, kHz, and kHzThen
Digital Filter Specifications
DSPAJT
*The transfer function H(z) meeting the specifications must be a causal transfer functionFor IIR real digital filter the transfer function is a real rational function of
H(z) must be stable and of lowest order N or M for reduced computational complexitySelection of Filter Type
DSPAJT
*Selection of Filter Type
FIR real digital filter transfer function is a polynomial in (order N) with real coefficients
For reduced computational complexity, degree N of H(z) must be as small as possibleIf a linear phase is desired then we must have:(More on this later)
DSPAJT
Filter Design *Recall: we relate the Frequency Response and the Impulse Response by the DTFT:Example: Ideal Low Pass FilterDTFT
DSPAJT
Filter Design *Notice two facts: the filter is not causal, i.e. the impulse response h(n) is non zero for n 5kHz with attenuation of at least 40dBSampling Frequency 20kHzStep 1: translate specifications into digital frequencyPass Band Stop BandStep 2: from pass band, determine ideal filter impulse response
DSPAJT
Ex. of Design FIR filter by Windows*Step 3: from desired attenuation choose the window. In this case we can choose the hamming window;Step 4: from the transition region choose the length N of the impulse response. Choose an odd number N such that:So choose N=81 which yields the shift L=40.Finally the impulse response of the filter
DSPAJT
Ex. of Design FIR filter by Windows*The Frequency Response of the Filter:
DSPAJT
*FIR DesignFIR Digital Filter DesignThree commonly used approaches to FIR filter design -(1) Windowed Fourier series approach(2) Frequency sampling approach(3) Computer-based optimization methods
DSPAJT
*Design of FIR filters: Windows
(i) Start with ideal infinite duration (ii) Truncate to finite length. (This produces unwanted ripples increasing in height near discontinuity.)(iii) Modify toWeight w(n) is the window
DSPAJT
*WindowsCommonly used windows RectangularBartlettHannHammingBlackmanKaiser
DSPAJT
Windows*attenuationFor different windows we have different values of the transition region and the attenuation in the stopband:transition regionRectangular-13dBBartlett-27dBHanning-32dBHamming-43dBBlackman-58dB
DSPAJT
*Kaiser window
Transition width (Hz) Min. stop attn dB 2.121.5/N304.542.9/N506.764.3/N708.965.7/N90
DSPAJT
Parametrized Window: Kaiser Window*The Kaiser window has two parameters:Window Length and To control attenuation in the Stop BandAttenuation in dBTransition Region in radExample:Sampling Freq. 20 kHzPass Band 4 kHzStop Band 5kHz, with 40dB Attenuation
DSPAJT
Parametrized Window: Kaiser Window*Then we determine the Kaiser window
DSPAJT
Parametrized Window: Kaiser Window*Then the impulse response of the FIR filter becomesideal impulse responsewith
Impulse ResponseFrequency Response
DSPAJT
Example*Design a digital filter which approximates a differentiator.Specifications: Desired Frequency Response: Sampling Frequency Attenuation in the stopband at least 50dB. Solution.Step 1. Convert to digital frequency
DSPAJT
Example*Step 2: determine ideal impulse responseFrom integration tables or integrating by parts we obtain Therefore
DSPAJT
Example*Step 3. From the given attenuation we use the Blackman window. This window has a transition region region of . From the given transition region we solve for the complexity N as followswhich yields . Choose it odd as, for ex., N=121, ie. L=60. Step 4. Finally the result
DSPAJT
Example*Impulse response h(n)Frequency Response
DSPAJT
*ExampleLowpass filter of length 51 and
DSPAJT
*Frequency Sampling Method
In this approach we are given and need to find This is an interpolation problem and the solution is given in the DFT part of the course
It has similar problems to the windowing approach
DSPAJT
*Linear-Phase FIR Filter Design by OptimisationAmplitude response for all 4 types of linear-phase FIR filters can be expressed as
where
DSPAJT
*Linear-Phase FIR Filter Design by OptimisationModified form of weighted error function
where
DSPAJT
*Linear-Phase FIR Filter Design by OptimisationOptimisation Problem - Determine which minimise the peak absolute value of
over the specified frequency bandsAfter has been determined, construct the original and hence h[n]
DSPAJT
*Linear-Phase FIR Filter Design by OptimisationSolution is obtained via the Alternation TheoremThe optimal solution has equiripple behaviour consistent with the total number of available parameters.Parks and McClellan used the Remez algorithm to develop a procedure for designing linear FIR digital filters.
DSPAJT
*FIR Digital Filter Order EstimationKaisers Formula:
Ie., N is inversely proportional to transition band width and not on transition band location
DSPAJT
*FIR Digital Filter Order EstimationHermann-Rabiner-Chans Formula:where
with
DSPAJT
*FIR Digital Filter Order EstimationFormula valid for For , formula to be used is obtained by interchanging and Both formulae provide only an estimate of the required filter order NIf specifications are not met, increase filter order until they are met
DSPAJT
*FIR Digital Filter Order EstimationFred Harris guide:where A is the attenuation in dBThen add about 10% to it
DSPAJT
*Finite Impulse Response Filters
The transfer function is given by
The length of Impulse Response is NAll poles are at . Zeros can be placed anywhere on the z-plane
DSPAJT
*FIR: Linear phase
For phase linearity the FIR transfer function must have zeros outside the unit circle
DSPAJT
*FIR: Linear phaseTo develop expression for phase response set transfer function (order n)
In factored form
Where , is real & zeros occur in conjugates
DSPAJT
*FIR: Linear phaseLet where
Thus
DSPAJT
*FIR: Linear phaseExpand in a Laurent Series convergent within the unit circleTo do so modify the second sum as
DSPAJT
*FIR: Linear phaseSo that
Thus
where
DSPAJT
*FIR: Linear phase are the root moments of the minimum phase component are the inverse root moments of the maximum phase componentNow on the unit circle we haveand
DSPAJT
*Fundamental Relationships
hence (note Fourier form)
DSPAJT
*FIR: Linear phase
Thus for linear phase the second term in the fundamental phase relationship must be identically zero for all index values.Hence 1) the maximum phase factor has zeros which are the inverses of the those of the minimum phase factor2) the phase response is linear with group delay (normalised) equal to the number of zeros outside the unit circle
DSPAJT
*FIR: Linear phase
It follows that zeros of linear phase FIR trasfer functions not on the circumference of the unit circle occur in the form
DSPAJT
*FIR: Linear phase
For Linear Phase t.f. (order N-1) so that for N even:
DSPAJT
*FIR: Linear phase
for N odd:
I) On we have for N even, and +ve sign
DSPAJT
*FIR: Linear phaseII) While for ve sign
[Note: antisymmetric case adds rads to phase, with discontinuity at ] III) For N odd with +ve sign
DSPAJT
*FIR: Linear phaseIV) While with a ve sign
[Notice that for the antisymmetric case to have linear phase we require
The phase discontinuity is as for N even]
DSPAJT
*FIR: Linear phase
The cases most commonly used in filter design are (I) and (III), for which the amplitude characteristic can be written as a polynomial in