You are here: Home » Content » DIGITAL FILTERS

DIGITAL FILTERS

Module by: Nguyen Huu Phuong

Digital filters are the most typical and popular DSP (or DTSP) systems. We treat and apply them in successive chapters. The objective of this section is to introduce briefly types of filters with associative difference equations. As for analog filters, digital filters act upon input signals to produce output signals which differ in amplitude, frequency and phase from those of the input signals. For the classification of frequency characteristic, digital filters, like analog counterparts, consists of 4 types: Lowpass, highpass, bandpass, and bandstop (or bandsuppress)(Figure). The frequency aspect of filters will be discussed in next chapters when the Fourier analysis has been introduced. In this section, we will classify digital filters on basis of their impulse responses and their structures.

Nonrecursive filters and FIR filters

In a nonrecursive filter the present output signal depends only on the input signal at all time. Mathematically, nonrecursive filters are described by the signal difference equation
y(n)=k=MMbkx(nk)y(n)=k=MMbkx(nk) size 12{y \( n \) = Sum cSub { size 8{k= - M} } cSup { size 8{M} } {b rSub { size 8{k} } x \( n - k \) } } {} (1)
where bkbk size 12{b rSub { size 8{k} } } {} are filter coefficients which may be real or complex (usually assumed real). The limits are written as -M and M, but may be anything else, including size 12{ - infinity } {} and size 12{ infinity } {}. For causal filters, the lower limit is o. Structurally, a nonrecursive filter consists of three types of operators: Delay, multiplier and adder (summer). Figure 1 shows the direct implementation of a causal nonrecursive filter having 4 coefficients
y ( n ) = k = 0 3 b k ( n k ) y ( n ) = k = 0 3 b k ( n k ) size 12{y \( n \) = Sum cSub { size 8{k=0} } cSup { size 8{3} } {b rSub { size 8{k} } \( n - k \) } } {}
In the figure z1z1 size 12{z rSup { size 8{ - 1} } } {} is the unit delay (delay of one time index), z2z2 size 12{z rSup { size 8{ - 2} } } {} is delay of two time indices, etc...
Figure 1: Structure (or implementation) of nonrecursive filter
The impulse response h(n)h(n) size 12{h \( n \) } {} is obtained by replacing x(nk)x(nk) size 12{x \( n - k \) } {} by δ(nk)δ(nk) size 12{δ \( n - k \) } {}:
h(n)=k=MMbkδ(n-k)=bnh(n)=k=MMbkδ(n-k)=bn size 12{ size 10{h \( n \) = Sum cSub {k= - M} cSup {M} {b rSub {k} δ \( "n-k" \) } =b rSub {n} }} {} (2)
This result leads to two important conclusions: First the coefficient bnbn size 12{b rSub { size 8{n} } } {} is just the filter impulse response h(n)h(n) size 12{h \( n \) } {} at the same index n , second the nonrecursive filter defined by Equation 1 is also a Finite Inpulse Response (FIR) filter . Of course when one or both limits is/are size 12{ infinity } {}, we have no more a FIR filter but an IIR filter. However for most of the realistic cases the limits are finite, so nonrecursive filters and FIR filters are the same.
When replacing bkbk size 12{b rSub { size 8{k} } } {}by h(k)h(k) size 12{h \( k \) } {} we have another form of nonrecursive (FIR) filters
y(n)=k=MMh(k)x(nk)y(n)=k=MMh(k)x(nk) size 12{y \( n \) = Sum cSub { size 8{k= - M} } cSup { size 8{M} } {h \( k \) x \( n - k \) } } {} (3)
and for causal filters
y(n)=k=0Mh(k)x(nk)y(n)=k=0Mh(k)x(nk) size 12{y \( n \) = Sum cSub { size 8{k=0} } cSup { size 8{M} } {h \( k \) x \( n - k \) } } {} (4)
Notice that nonrecursive filters implement directly the convolution summation.
Example 1 
Consider a moving average filter of five terms y ( n ) = 1 5 [ x ( n 2 ) + x ( n 1 ) + x ( n ) + x ( n + 1 ) + x ( n + 2 ) ] y ( n ) = 1 5 [ x ( n 2 ) + x ( n 1 ) + x ( n ) + x ( n + 1 ) + x ( n + 2 ) ] size 12{y \( n \) = { {1} over {5} } \[ x \( n - 2 \) +x \( n - 1 \) +x \( n \) +x \( n+1 \) +x \( n+2 \) \] } {} which is a noncausal nonrecursive (or noncausal FIR) filter. When the time increases the averaging moves on, so is the name. The input signal is periodic with a period of 4 samples: x ( n ) = [ . . . 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3 . . . ] x ( n ) = [ . . . 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3 . . . ] size 12{x \( n \) = \[ "." "." "." 1, matrix { } 2, matrix { } 3, matrix { } 2, matrix { } 1, matrix { } 2, matrix { } 3, matrix { } 2, matrix { } 1, matrix { } 2, matrix { } 3 "." "." "." \] } {} Plot the input and output signals.
Solution
The evaluation of the output signal proceeds as follows:
y ( 0 ) = 0 . 2 [ x ( 2 ) + x ( 1 ) + x ( 0 ) + x ( 1 ) + x ( 2 ) ] = 0 . 2 [ 1 + 2 + 3 + 2 + 1 ] = 1 . 8 y ( 1 ) = 0 . 2 [ x ( 1 ) + x ( 0 ) + x ( 1 ) + x ( 2 ) + x ( 3 ) ] = 0 . 2 [ 2 + 3 + 2 + 1 + 2 ] = 2 . 0 y ( 2 ) = 0 . 2 [ x ( 0 ) + x ( 1 ) + x ( 2 ) + x ( 3 ) + x ( 4 ) ] = 0 . 2 [ 3 + 2 + 4 + 2 + 3 ] = 2 . 2 y ( 3 ) = 0 . 2 [ x ( 1 ) + x ( 2 ) + x ( 3 ) + x ( 4 ) + x ( 5 ) ] = 0 . 2 [ 2 + 1 + 2 + 3 + 2 ] = 2 . 0 . . . y ( 0 ) = 0 . 2 [ x ( 2 ) + x ( 1 ) + x ( 0 ) + x ( 1 ) + x ( 2 ) ] = 0 . 2 [ 1 + 2 + 3 + 2 + 1 ] = 1 . 8 y ( 1 ) = 0 . 2 [ x ( 1 ) + x ( 0 ) + x ( 1 ) + x ( 2 ) + x ( 3 ) ] = 0 . 2 [ 2 + 3 + 2 + 1 + 2 ] = 2 . 0 y ( 2 ) = 0 . 2 [ x ( 0 ) + x ( 1 ) + x ( 2 ) + x ( 3 ) + x ( 4 ) ] = 0 . 2 [ 3 + 2 + 4 + 2 + 3 ] = 2 . 2 y ( 3 ) = 0 . 2 [ x ( 1 ) + x ( 2 ) + x ( 3 ) + x ( 4 ) + x ( 5 ) ] = 0 . 2 [ 2 + 1 + 2 + 3 + 2 ] = 2 . 0 . . . alignl { stack { size 12{y \( 0 \) =0 "." 2 \[ x \( - 2 \) +x \( - 1 \) +x \( 0 \) +x \( 1 \) +x \( 2 \) \] =0 "." 2 \[ 1+2+3+2+1 \] =1 "." 8} {} # size 12{y \( 1 \) =0 "." 2 \[ x \( - 1 \) +x \( 0 \) +x \( 1 \) +x \( 2 \) +x \( 3 \) \] =0 "." 2 \[ 2+3+2+1+2 \] =2 "." 0} {} # size 12{y \( 2 \) =0 "." 2 \[ x \( 0 \) +x \( 1 \) +x \( 2 \) +x \( 3 \) +x \( 4 \) \] =0 "." 2 \[ 3+2+4+2+3 \] =2 "." 2} {} # size 12{y \( 3 \) =0 "." 2 \[ x \( 1 \) +x \( 2 \) +x \( 3 \) +x \( 4 \) +x \( 5 \) \] =0 "." 2 \[ 2+1+2+3+2 \] =2 "." 0} {} # size 12{ "." "." "." } {} } } {}
The input and output and signals are shown in Figure 2.
Figure 2: Example (a) x(n), (b) y(n)
Notice that the moving average filter is a lowpass filter because it tends to reduce the variation in amplitude of the input signal. Of course, not all nonrecursive (or FIR) filters are lowpass. When the more samples are averaged the more the output signal is smooth, but also the more is the processing time.
The moving average filtering bears a fundamental meaning of DSP (or DTSP), i.e. the computation on the samples is just the digital signal processing.
Notice that the given filter is noncausal because the present value of y(n)y(n) size 12{y \( n \) } {} depends on the two future values x(n=1)x(n=1) size 12{x \( n=1 \) } {} and x(n=2)x(n=2) size 12{x \( n=2 \) } {} of input signal. This cause no problem if we process the stored data. In real-time processing (RTP) signals must be causal. The given filter can be made causal by making all samples, except the present, become the past :
y ( n ) = 1 5 [ x ( n ) + x ( n 1 ) + x ( n 2 ) + x ( n 3 ) + x ( n 5 ) ] y ( n ) = 1 5 [ x ( n ) + x ( n 1 ) + x ( n 2 ) + x ( n 3 ) + x ( n 5 ) ] size 12{y \( n \) = { {1} over {5} } \[ x \( n \) +x \( n - 1 \) +x \( n - 2 \) +x \( n - 3 \) +x \( n - 5 \) \] } {}
Now the output signal y(n)y(n) size 12{y \( n \) } {} is the average value around the central sample x(n2)x(n2) size 12{x \( n - 2 \) } {} insteal around x(n)x(n) size 12{x \( n \) } {}as previously.
Example 2 
The signal x ( n ) = sin 2πn 60 + sin 2πn 10 60 n 320 x ( n ) = sin 2πn 60 + sin 2πn 10 60 n 320 size 12{x \( n \) ="sin" { {2πn} over {"60"} } +"sin" { {2πn} over {"10"} } matrix { {} # {} # {} } "60" <= n <= "320"} {} is applied to a nonrecursive (FIR) filter having impulse response h ( n ) = 0 . 1 0 n 9 = 0, otherwise h ( n ) = 0 . 1 0 n 9 = 0, otherwise alignl { stack { size 12{h \( n \) =0 "." 1 matrix { {} # {} } 0 <= n <= 9} {} # size 12{ matrix { {} # {} # {} } =0, matrix { {} # {} } ital "otherwise"} {} } } {} Plot the input signal x(n)x(n) size 12{x \( n \) } {}and the output signal y(n)y(n) size 12{y \( n \) } {}.
Note: This Example is adapted from Introductory Digital Signal Processing with Computer Applications, Revised Edition, Paul A. Lynn and Wolfgang Fuerst, John. Wiley & Sons, 1994.
Solution
The given input signal consists of a low frequency component having 60 samples in its size 12{2π} {}period, and a high frequency component having 10 samples in its size 12{2π} {}period. Figure 3a depicts the signal. The given impulse response means the filter is a moving average filter of 10 samples of equal amplitude of 0.1. The equation of the filter is
y ( n ) = k = 0 9 h ( k ) x ( n k ) = h ( 0 ) x ( n ) + h ( 1 ) x ( n 1 ) + . . . + h ( 9 ) x ( n 9 ) = 0 . 1 [ x ( n ) + x ( n 1 ) + . . . + x ( n 9 ) ] y ( n ) = k = 0 9 h ( k ) x ( n k ) = h ( 0 ) x ( n ) + h ( 1 ) x (