Salta al contenuto
Note per Studenti FIR and IIR Filters Report

FIR and IIR Filters

In questa pagina 4

Discrete-time filters are used in digital signal processing, hence the name digital filters (if the amplitudes are quantized). Two categories of discrete-time systems are analyzed:

  1. FIR: finite impulse response;
  2. IIR: infinite impulse response.

In general a discrete-time convolutional LTI system is fully described by an ARMA (auto-regressive moving average) model:

∑n=0Nan y(k−n)=∑m=0Mbm u(k−m),\sum_{n=0}^{N}a_n\,y(k-n)=\sum_{m=0}^{M}b_m\,u(k-m),

so discrete-time filters can be modeled via ARMA models. The design of a filter amounts to designing the coefficients an,bma_n,b_m.

FIR filters

If all ana_n are zero for n≠0n\ne0, the filter is FIR. The difference equation is not even auto-regressive (MA only):

y(k)=1a0∑m=0Mbm u(k−m).y(k)=\frac1{a_0}\sum_{m=0}^{M}b_m\,u(k-m).

Redefine βm:=bma0\beta_m:=\frac{b_m}{a_0}, so that y(k)=∑m=0Mβm u(k−m)y(k)=\sum_{m=0}^{M}\beta_m\,u(k-m). Applying the DTFT (the shift k−mk-m becomes the factor e−jθme^{-j\theta m}, see Discrete-Time Fourier TransformThe DTFT of an aperiodic discrete-time signal is the 2pi-periodic function X(e^{j theta}) = sum x(k) e^{-j theta k}; it is obtained as the envelope of the DFT of the N-periodic repetition when N tends to infinity, and has translation, modulation, convolution and Parseval properties.Discrete-Time Fourier Transform →):

Y(ejθ)=∑m=0Mβm e−jθm U(ejθ) ⇒ H(ejθ)=Y(ejθ)U(ejθ)=∑m=0Mβm e−jθm ⟺ h+(k)=∑m=0Mβm δ(k−m).Y(e^{j\theta})=\sum_{m=0}^{M}\beta_m\,e^{-j\theta m}\,U(e^{j\theta})\ \Rightarrow\ H(e^{j\theta})=\frac{Y(e^{j\theta})}{U(e^{j\theta})}=\sum_{m=0}^{M}\beta_m\,e^{-j\theta m} \ \Longleftrightarrow\ h_+(k)=\sum_{m=0}^{M}\beta_m\,\delta(k-m).

The reason why it is called FIR: h+(k)h_+(k) is defined over the bounded support [0,M][0,M].

Reminder: in continuous-time systems e−jθe^{-j\theta} is replaced by jωj\omega (so that the polynomial in (jω)m(j\omega)^m appears in H(jω)H(j\omega)).

IIR filters

If a discrete-time filter is not FIR then it is IIR. Now there is auto-regression in the difference equation: an≠0a_n\ne0 for at least one n>0n>0 (typically aN≠0a_N\ne0), the full ARMA model

∑n=0Nan y(k−n)=∑m=0Mbm u(k−m).\sum_{n=0}^{N}a_n\,y(k-n)=\sum_{m=0}^{M}b_m\,u(k-m).

Applying the DTFT:

Y(ejθ)∑n=0Nan(e−jθ)n=U(ejθ)∑m=0Mbm(e−jθ)m,Y(e^{j\theta})\sum_{n=0}^{N}a_n\left(e^{-j\theta}\right)^n=U(e^{j\theta})\sum_{m=0}^{M}b_m\left(e^{-j\theta}\right)^m,

hence the frequency response of an IIR filter

H(ejθ)=∑m=0Mbm(e−jθ)m∑n=0Nan(e−jθ)n.\boxed{H(e^{j\theta})=\frac{\sum_{m=0}^{M}b_m\left(e^{-j\theta}\right)^m}{\sum_{n=0}^{N}a_n\left(e^{-j\theta}\right)^n}.}

(For FIR filters the denominator is 11 after the normalization βm=bm/a0\beta_m=b_m/a_0.)

Example 1: first-order IIR filter

y(k)=a y(k−1)+u(k),a≠0, ∣a∣<1.y(k)=a\,y(k-1)+u(k),\qquad a\ne0,\ |a|<1.

The term a y(k−1)a\,y(k-1) makes it IIR. DTFT:

Y(ejθ)=a e−jθY(ejθ)+U(ejθ) ⇒ Y(ejθ)(1−a e−jθ)=U(ejθ) ⇒ H(ejθ)=11−a e−jθ.Y(e^{j\theta})=a\,e^{-j\theta}Y(e^{j\theta})+U(e^{j\theta})\ \Rightarrow\ Y(e^{j\theta})\left(1-a\,e^{-j\theta}\right)=U(e^{j\theta})\ \Rightarrow\ H(e^{j\theta})=\frac1{1-a\,e^{-j\theta}} .

Impulse response (causal, h+(k)=0h_+(k)=0 for k<0k<0, h+(k)=a h+(k−1)+δ(k)h_+(k)=a\,h_+(k-1)+\delta(k)): h+(0)=1h_+(0)=1, h+(1)=ah_+(1)=a, h+(2)=a2,…h_+(2)=a^2,\dots, i.e. h+(k)=ak 1(k)h_+(k)=a^k\,\mathbb{1}(k).

Is this really a filter? The modulus is ∣H(ejθ)∣=1∣1−a e−jθ∣|H(e^{j\theta})|=\frac1{|1-a\,e^{-j\theta}|}, periodic of period 2π2\pi. Low frequencies are θ→0\theta\to0 and high frequencies are θ→±π\theta\to\pm\pi.

  • θ→0\theta\to0: ∣H(ej0)∣=1∣1−a∣|H(e^{j0})|=\frac1{|1-a|}. If 0<a<10<a<1 there is amplification; if −1<a<0-1<a<0 there is attenuation.
  • θ→π\theta\to\pi: ∣H(ejπ)∣=1∣1−a e−jπ∣=1∣1+a∣|H(e^{j\pi})|=\frac1{|1-a\,e^{-j\pi}|}=\frac1{|1+a|}. If 0<a<10<a<1 there is attenuation; if −1<a<0-1<a<0 there is amplification.

Case 0<a<10<a<1: ∣H∣|H| has a maximum at θ=0\theta=0 and decreases towards ±π\pm\pi: a low-pass filter. Case −1<a<0-1<a<0: ∣H∣|H| has a minimum at θ=0\theta=0 and grows towards ±π\pm\pi: a high-pass filter. In both cases a larger ∣a∣|a| makes the shape sharper (curve more peaked around θ=0\theta=0 for a>0a>0, a narrower dip for a<0a<0). For a→−1a\to-1 the dip at θ=0\theta=0 becomes very sharp: a notch filter.

|H|  (0<a<1)                 |H|  (-1<a<0)
   ^      /\                    ^
   |    _/  \_                 |--.__          __.--
   |__./      \.__             |     \__    __/
   +------+------> theta      +--------\__/-------> theta
  -pi     0     pi            -pi      0         pi
  low-pass                    high-pass (notch if a -> -1)

Example 2: moving average of order 1 (FIR)

y(k)=12 u(k)+12 u(k−1).y(k)=\frac12\,u(k)+\frac12\,u(k-1).

A moving average of order 1, so it must be an FIR filter. DTFT:

Y(ejθ)=12U(ejθ)+12e−jθU(ejθ)=12U(ejθ)(1+e−jθ),Y(e^{j\theta})=\frac12U(e^{j\theta})+\frac12e^{-j\theta}U(e^{j\theta})=\frac12U(e^{j\theta})\left(1+e^{-j\theta}\right),

H(ejθ)=12(1+e−jθ)=12(e−jθ2ejθ2+e−jθ2e−jθ2)=e−jθ2 ejθ2+e−jθ22=e−jθ2cos⁡ ⁣(θ2).H(e^{j\theta})=\frac12\left(1+e^{-j\theta}\right)=\frac12\left(e^{-j\frac\theta2}e^{j\frac\theta2}+e^{-j\frac\theta2}e^{-j\frac\theta2}\right)=e^{-j\frac\theta2}\,\frac{e^{j\frac\theta2}+e^{-j\frac\theta2}}2=e^{-j\frac\theta2}\cos\!\left(\frac\theta2\right).

  • θ→0\theta\to0: H(ej0)=1H(e^{j0})=1.
  • θ→π\theta\to\pi: H(ejπ)=e−jπ2cos⁡ ⁣(π2)=0H(e^{j\pi})=e^{-j\frac\pi2}\cos\!\left(\frac\pi2\right)=0.

So ∣H(ejθ)∣=∣cos⁡θ2∣|H(e^{j\theta})|=\left|\cos\frac\theta2\right| is an arch from 00 at ±π\pm\pi up to 11 at θ=0\theta=0: high frequencies are attenuated and low frequencies are preserved, hence a low-pass filter. The impulse response is

h+(k)=12δ(k)+12δ(k−1)={12if k=0,10otherwise.h_+(k)=\frac12\delta(k)+\frac12\delta(k-1)=\begin{cases}\frac12&\text{if }k=0,1\\0&\text{otherwise.}\end{cases}

Remark. FIR filters can be implemented by storing in memory a finite number of values representing their impulse response. This is very advantageous from a computational point of view.

Exercise (homework). Analyze ∣H(ejθ)∣|H(e^{j\theta})| for y(k)=12u(k)−12u(k−1)y(k)=\frac12u(k)-\frac12u(k-1). (Left as an exercise in the notes; no solution is given.)

Versione ripasso

  • ARMA model: ∑n=0Nany(k−n)=∑m=0Mbmu(k−m)\sum_{n=0}^{N}a_ny(k-n)=\sum_{m=0}^{M}b_mu(k-m). Designing the filter = designing an,bma_n,b_m.
  • FIR: an=0a_n=0 for n≠0n\ne0 (MA only). y(k)=∑m=0Mβmu(k−m)y(k)=\sum_{m=0}^M\beta_mu(k-m), βm=bm/a0\beta_m=b_m/a_0; H(ejθ)=∑βme−jθmH(e^{j\theta})=\sum\beta_me^{-j\theta m}; h+(k)=∑βmδ(k−m)h_+(k)=\sum\beta_m\delta(k-m) with bounded support [0,M][0,M]. Cheap to implement (store finitely many values).
  • IIR: some an≠0a_n\ne0 with n>0n>0 (auto-regression): H(ejθ)=∑bm(e−jθ)m∑an(e−jθ)nH(e^{j\theta})=\frac{\sum b_m(e^{-j\theta})^m}{\sum a_n(e^{-j\theta})^n}. Continuous-time analogue: e−jθ→jωe^{-j\theta}\to j\omega.
  • Example y(k)=ay(k−1)+u(k)y(k)=ay(k-1)+u(k), 0<∣a∣<10<|a|<1: H=11−ae−jθH=\frac1{1-ae^{-j\theta}}, h+(k)=ak1(k)h_+(k)=a^k\mathbb{1}(k); ∣H(ej0)∣=1∣1−a∣|H(e^{j0})|=\frac1{|1-a|}, ∣H(ejπ)∣=1∣1+a∣|H(e^{j\pi})|=\frac1{|1+a|}. 0<a<10<a<1: low-pass; −1<a<0-1<a<0: high-pass; a→−1a\to-1: very sharp notch. Larger ∣a∣|a|: sharper.
  • Example y(k)=12u(k)+12u(k−1)y(k)=\frac12u(k)+\frac12u(k-1): H=e−jθ/2cos⁡θ2H=e^{-j\theta/2}\cos\frac\theta2, H(1)=1H(1)=1 at θ=0\theta=0, 00 at θ=π\theta=\pi: low-pass FIR with h+(k)=12h_+(k)=\frac12 for k=0,1k=0,1.
  • Typical mistakes: calling a filter FIR when there is any y(k−n)y(k-n) term on the left with n>0n>0; forgetting that ∣H∣|H| must be read over θ∈[−π,π]\theta\in[-\pi,\pi] with low frequencies near 00 and high frequencies near ±π\pm\pi.

Teoria collegata