fir filters chapter - university of colorado colorado springsmwickert/ece2610/lecture_notes/... ·...

38
ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems as opposed to sig- nals. The systems discussed in this chapter are finite impulse response (FIR) digital filters. The term digital filter arises because these filters operate on discrete-time signals The term finite impulse response arises because the filter out- put is computed as a weighted, finite term sum, of past, pres- ent, and perhaps future values of the filter input, i.e., (5.1) where both and are finite One of the simplest FIR filters we may consider is a 3–term moving average filter of the form (5.2) An FIR filter is based on a feed-forward difference equation as demonstrated by (5.2) – Feed-forward means that there is no feedback of past or future outputs to form the present output, just input related terms Continuous-time filters will be discussed in the circuits and systems courses yn b k xn k k M 1 = M 2 = M 1 M 2 yn 1 3 -- xn 1 + xn xn 1 + + = Chapter 5

Upload: hoangthien

Post on 31-Jan-2018

260 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

er

FIR FiltersWith this chapter we turn to systems as opposed to sig-nals. The systems discussed in this chapter are finiteimpulse response (FIR) digital filters.

• The term digital filter arises because these filters operate ondiscrete-time signals

• The term finite impulse response arises because the filter out-put is computed as a weighted, finite term sum, of past, pres-ent, and perhaps future values of the filter input, i.e.,

(5.1)

where both and are finite

• One of the simplest FIR filters we may consider is a 3–termmoving average filter of the form

(5.2)

• An FIR filter is based on a feed-forward difference equationas demonstrated by (5.2)

– Feed-forward means that there is no feedback of past orfuture outputs to form the present output, just input relatedterms

• Continuous-time filters will be discussed in the circuits andsystems courses

y n bkx n k– k M1–=

M2

=

M1 M2

y n 13--- x n 1+ x n x n 1– + + =

Chapt

5

ECE 2610 Signal and Systems 5–1

Page 2: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Discrete-Time Systems

Discrete-Time Systems

• A discrete-time system transforms or maps an input sequence(signal) into and output sequence (signal) via afunction or operation denoted as

(5.3)

• Some examples are:

The Running (Moving) Average Filter

• A three-sample causal moving average filter is a special caseof (5.1)

, (5.4)

which uses no future input values to compute the present out-put

– Note: The term causal means that the present output, say

x n y n

T x n y n

y n T x n =

y n x n 3=

min x n x n 1– x n 2– =

x n x n 1– –=

12--- x n x n 1– + =

y n 13--- x n x n 1– x n 2– + + =

ECE 2610 Signals and Systems 5–2

Page 3: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The Running (Moving) Average Filter

, utilizes only past and present signal values (no futurevalues of the input)

• Consider a finite-length input sequence having support (non-zero values) over the interval

• For the 3–point causal moving average filter of (5.4)forms the output as

(5.5)

• If we put this into a spreadsheet we could write formulas intothe cells that calculate the output sequence values as follows

• The output is can be calculated using MATLAB func-

y n

1– n 3

n

x n

0 1 2 3 4-2-3

-1

5-1

2

4

6

4

n 0=

y 0 13--- x 0 x 1– x 2– + + =

13--- 2 1– 0+ 1

3--- 0.333= ==

y 2 13--- 6 4 2+ + 12

3------ 4= = =

y n

ECE 2610 Signals and Systems 5–3

Page 4: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The Running (Moving) Average Filter

tions as follows>> n= -3:5;>> x = [0 0 -1 2 4 6 4 0 0]>> % We will learn about the filter function later>> y = filter(1/3*[1 1 1],1,x);>> stem(n,y,'filled')

• The input/output relationship of (5.4) is known as a differ-ence equation

• The action of the moving average filter has resulted in theoutput being smoother than the input

• Since only past and present values of the input are being usedto calculate the present output, this filtering operation canoperate in real-time

• A variation of the above 3-point averager is

(5.6)

which can be termed a centralized averager, since the previ-ous input, the present input, the next input are used to formthe output

n

y n

0 1 2 3 4-2-3

-1

5-0.33

0.33

1.67

44.67

3.33

1.33 zero beyondn = 5

y n 13--- x n 1+ x n x n 1– + + =

ECE 2610 Signals and Systems 5–4

Page 5: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

• This system is noncausal and cannot be computed in real-time, since the future input would not be available

• Inside the spreadsheet we have the following:

• Notice that the output is the same as before, except it occursone sample index earlier

– To implement the causal filter we have to delay the outputby one sample

• How we position and choose the width of the averaging win-dow over the input signal are design choices

– What happens if we make the window wider?

The General FIR Filter

• The class of causal FIR filters has difference equation of theform

(5.7)

PresentInput/Output

Future Inputs

relative to n = 0

relative to n = 0Past Inputsrelative to n = 0

y n bkx n k– k 0=

M

=

ECE 2610 Signals and Systems 5–5

Page 6: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

– Note: When and , we havethe special case of the causal 3-point moving average filterof (5.4)

• The text has defined the following terms regarding filteringwith an Mth order causal FIR filter

Example: An FIR

• Suppose that and is as given inthe following spreadsheet table

• Fill-in the missing table entries

M 2= b0 b1 b2 1 3= = =

M 4=

bk 2– 0 1 2 3 = x n

y 3 2– 4 0 3 1 2 2 1 3 0+ + + + 4–= =

ECE 2610 Signals and Systems 5–6

Page 7: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

Example: Filtering A Windowed Noise Sequence

• In this example we create an input sequence composed ofuniformly distributed random numbers for

and zero otherwise

• The filter coefficients represent both 3-point and 7-point moving average filters

>> n = -5:50;>> x = [zeros(1,5), rand(1,41)-1/2, zeros(1,10)];>> y3 = filter(ones(1,3)/3,1,x);>> y7 = filter(ones(1,7)/7,1,x);

x 1 2– 1 2 0 n 40

bk

−5 0 5 10 15 20 25 30 35 40 45 50−0.5

0

0.5

x[n]

−5 0 5 10 15 20 25 30 35 40 45 50−0.5

0

0.5

y 3[n]

−5 0 5 10 15 20 25 30 35 40 45 50−0.5

0

0.5

y 7[n]

Time Index (n)

With a longer smoothingwindow the noise averageapproaches zero

ECE 2610 Signals and Systems 5–7

Page 8: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

The Unit Impulse Response

Three interconnected concepts of this subsection are the unitimpulse sequence, the unit impulse response, and the convolutionsum.

Unit Impulse Sequence:

• A sequence having a nonzero value of one only when itsargument is equal to zero, i.e.,

(5.8)

• The unit impulse sequence can be shifted right or left by inte-ger by writing

(5.9)

• We can both time shift and amplitude scale the impulsesequence, such that a linear combination of them can be usedto form any sequence, e.g.,

n

n 0=

n 1, n 0=

0, n 0

=

n0

n n0– 1, n n0=

0, n n0

=

n

n

1 2 30-1-2-3

n

n 2–

1 2 30-1-2-3

1

1

ECE 2610 Signals and Systems 5–8

Page 9: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

(5.10)

• Each of the five scaled and time shifted impulses forms a sin-gle nonzero sample value of the complete sequence

• The generalization to the above is the ability to expand anysequence in this fashion, i.e.,

(5.11)

Unit Impulse Response Sequence:

• When we input to an FIR filter the sequence ,the filter output (assuming the filter is initially at rest) is theunit impulse response, denoted

n ... -2 -1 0 1 2 3 4 5 6 ...

0 0 0 2 0 0 0 0 0 0 0

0 0 0 0 4 0 0 0 0 0 0

0 0 0 0 0 6 0 0 0 0 0

0 0 0 0 0 0 4 0 0 0 0

0 0 0 0 0 0 0 2 0 0 0

0 0 0 2 4 6 4 2 0 0 0

x n 2 n 4 n 1– 6 n 2– + +=

4 n 3– 2 n 4– + +

2 n

4 n 1–

6 n 2–

4 n 3–

2 n 4–

x n

x n x k n k– k=

x 1– n 1+ x 0 n + +=

x 1 n 1– x 2 n 2– + + +

h n

x n n =

y n h n =

ECE 2610 Signals and Systems 5–9

Page 10: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

• Note this definition holds for any discrete-time filter, not just FIR filters

Example: 3-Point Moving Average Filter Impulse Response

• For this filter

• Using (5.7)

(5.12)

• For a general FIR filter of (5.7) we observe that

(5.13)

Discrete-TimeFilter

n h n

bk 1 3 1 3 1 3 =

h n bk n k– k 0=

2

=

13--- n k– k 0=

2

=

13--- n n 1– n 2– + + =

n

h n

1 2 30-1-2-3

1/3

bk13--- 1

3--- 1

3---

=

h n bk n k– k 0=

M

=

ECE 2610 Signals and Systems 5–10

Page 11: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

– Note in particular that the impulse response is finite, that isit extends over , hence the term finite impulseresponse (FIR) system is justified

Example: Triangle Impulse Response

(5.14)

• Evaluate point-by-point and plot, e.g.,

The Unit-Delay System:

• When , corresponds to a systemimparting a unit delay

• A unit delay system is a special FIR filter where

(5.15)

and the filter order is

n 0 M

M 10=

h n 6 k 5–– n k– k 0=

10

=

6 k 5–– k 5=

6= 6 k 5–– k 4=

5=

�2 2 4 6 8 10 12n

1

2

3

4

5

6h n

y n x n n0– =

n0 1= y n x n 1– =

bk 0 1 =

M 1=

ECE 2610 Signals and Systems 5–11

Page 12: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

• The impulse response of a delay by system is

(5.16)

Convolution and FIR Filters

• It can be shown (more on this later) that a general expressionof a filter’s output can be expressed in terms of the impulseresponse and the input as

(5.17)

• This formula has a special name: convolution sum formula

• We say that is the convolution of and

Example: Convolution Using the Text Table Method

• Convolve with ,where both sequence start at and are nonzero for thevalues given

0 1 2 3 4 5 6 7

0 2 4 6 4 2 0 0 0 0

0 3 -1 2 1

0 6 12 18 12 6 0 0 0 0

0 0 -2 -4 -6 -4 -2 0 0 0

0 0 0 4 8 12 8 4 0 0

0 0 0 0 2 4 6 4 2 0

0 6 10 18 16 18 12 8 2 0

n0

h n n n0– =

y n h k x n k– k 0=

M

=

y n x n h n

x n 2 4 6 4 2 = h n 3 1– 2 1 =n 0=

n n 0 n 7

x n

h n

h 0 x n

h 1 x n 1–

h 2 x n 2–

h 3 x n 3–

y n

sum

dow

n

ECE 2610 Signals and Systems 5–12

Page 13: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

• We can check the answers using MATLAB’s filter function>> n = 0:8;>> x = [2 4 6 4 2 0 0 0 0];>> h = [3 -1 2 1];>> y = filter(h,1,x);>> y

y = 6 10 18 16 18 12 8 2 0

Example: Convolution Using an Alternate Table Method

• In this example we consider another approach to performingconvolution of finite length sequences using a table

• Convolve and

• In the convolution sum formula we need to multiply thesequence by the sequence for a fixed/givenvalue of

0 1 2 3 4 5 6 7 80

2

4

6

8

10

12

14

16

18

Index n

y[n]

x n 0 1 2 3 = h n 1 1 2 3 =

h k x n k– n

ECE 2610 Signals and Systems 5–13

Page 14: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

• What is relative to ?

– is flipped from left to right about

– is flipped and shifted by n

– Check by plugging into

OK!

– Also plug into

OK!

y n h k x n k–

k 0=

M

=

k

k

M01–

h k

x n k–

multiply and addon the interval

where h[k] is nonzero

x n k– x k

x k– x k k 0=

k k0n1 n2 0 n– 1n– 2

x k x k–

x n k– x k

k k0n1 n2 0 n n1–n n– 2

x k x n k–

n n1– x n k–

x n n n1– – x n1 =

n n2– x n k–

x n n n2– – x n2 =

ECE 2610 Signals and Systems 5–14

Page 15: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

• Using the above view of the convolution sum, we obtain analternate table form for the convolution sum

• Check using MATLAB’s filter function>> n = 0:7;>> x = [0 1 2 3 0 0 0 0];>> h = [1 1 2 3];>> y = filter(h,1,x);>> y = 0 1 3 7 10 12 9 0

0 1 2 3 4 5 6 70

2

4

6

8

10

12

Index n

y[n]

ECE 2610 Signals and Systems 5–15

Page 16: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

Using MATLAB’s Filter Function

• We have been using the function filter() in the fewexamples, so how does it work?

>> help filter FILTER One-dimensional digital filter. Y = FILTER(B,A,X) filters the data in vector X with the filter described by vectors A and B to create the filtered data Y. The filter is a "Direct Form II Transposed" implementation of the standard difference equation: a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-na) If a(1) is not equal to 1, FILTER normalizes the filter coefficients by a(1). [Y,Zf] = FILTER(B,A,X,Zi) gives access to initial and final conditions, Zi and Zf, of the delays. Zi is a vector of length MAX(LENGTH(A),LENGTH(B))-1, or an array with the leading dimension of size MAX(LENGTH(A),LENGTH(B))-1 and with remaining dimensions matching those of X.

• From the help listing we see that it simply evaluates a generaldifference equation of the form

(5.18)

• At the present time (Chapter 5) we do not have any feedbackterms in our difference equation, so and we assumethat , resulting in (5.18) reducing to

(5.19)

aky n k– k 0=

N

bkx n k– k 0=

M

=

N 0=a0 1=

y n bkx n k– k 0=

M

=

ECE 2610 Signals and Systems 5–16

Page 17: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

The General FIR Filter

• When using filter() to implement an FIR filter, we setthe vectors and

Convolution in MATLAB

• We have seen how MATLAB’s filter function can directlyevaluate (number crunch) a difference equation for a givenfilter coefficient set and input sequence

• Convolution between any two finite support (duration)sequences can also be performed using the function conv()

>> help conv CONV Convolution and polynomial multiplication. C = CONV(A, B) convolves vectors A and B. The resulting vector is length LENGTH(A)+LENGTH(B)-1. If A and B are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials.

• Check this out using the previous example values for and

>> h = [1 1 2 3];>> x = [0 1 2 3];>> y = conv(x,h)

y = 0 1 3 7 10 12 9

• We can also use the conv() function to perform polynomialmultiplication, or at least obtain the coefficient set corre-sponding to polynomial multiplication, e.g.

(5.20)

a 1 = b b0 b1 bM =

bk x n

h n x n

P1 x a0 a1x a2x2

+ +=

P2 x b0 b1x b2x2

+ +=

ECE 2610 Signals and Systems 5–17

Page 18: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Implementation of FIR Filters

• Let , then the coefficients are[c0 c1 c2 ...] = conv([a0 a1 a2],[b0 b1 b2])

such that

(5.21)

• For example>> conv([1 2 3],[1 -1 2])

ans = 1 1 3 1 6

• So we conclude that

(5.22)

• Verify!

Implementation of FIR Filters

• The implementation of an FIR requires three basic buildingblocks

– multiplication

– addition

– signal delay

• We also need to be able to store filter coefficients in memory

P3 x P1 x P2 x =

P3 x c0 c1x c2x2 + + +=

1 2x 3x2

+ + 1 x– 2x2

+ 1 x 3x2x

36x

4+ + + +=

ECE 2610 Signals and Systems 5–18

Page 19: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Implementation of FIR Filters

Building Blocks

Multiplier:

• In a DSP system the multiplier must be fast and must havesufficient precision (bit width; think logic circuits) to supportthe desired application

• A high quality filter will in general require more multiplica-tions than one of lesser quality, so throughput suffers if themultiplier is not fast

– There are classes of filters that do not require multiplies

• FIR filters having 50 coefficients or more are not that uncom-mon

Adder:

• Signal addition is a very basic DSP function

• In an FIR filter additions are required in combination withmultiplications, hence DSP microprocessors feature multi-ply-accumulate (MAC) units

• Adders generally operate with just two inputs at a time

Multiply Add Delay

y n x n =

y n x1 n x2 n +=

ECE 2610 Signals and Systems 5–19

Page 20: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Implementation of FIR Filters

Unit Delay:

• The unit delay provides a one sample signal delay

• A sample value is stored in a memory slot for one sampleclock cycle, and then made available as an input to the nextprocessing stage

• An M-unit delay requires M memory cells (note each mem-ory cell must store say B-bits) configured as a shift register(B-bits wide)

Block Diagrams

• Using the building blocks described above, we can constructa block diagram for say an FIR filter

y n x n 1– =

M 3=

y n bkx n k–

k 0=

3

=

UnitDelay

UnitDelay

UnitDelay

y n

x n

x n 1–

x n 2–

x n 3–

b0

b1

b2

b3

ECE 2610 Signals and Systems 5–20

Page 21: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Implementation of FIR Filters

• Notice that the signal flow is strictly feed-forward, since allpaths connecting the input to the output flow in the forwarddirection

• Feedback paths will be needed in the filters of Chapter 8

• The structure of this block diagram is called direct form

– Other structures can be used to implement the same differ-ence equation, and hence the same input/output relation-ship

– Once we understand how the direct form structure works,we can easily write the equations or draw the block dia-gram

Example: M = 3 Block Diagram to Difference Equation

UnitDelay

UnitDelay

UnitDelay

y n

x n

x n 1–

x n 2–

x n 3–

3

3

2

2–

v1 n

v2 n

v3 n

v4 n

ECE 2610 Signals and Systems 5–21

Page 22: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Implementation of FIR Filters

• By inspection we know that

• If we were not familiar with this form, we can write an equa-tion for the output by adding some additional labels, and thenmaking substitutions, e.g.,

– Given a new unfamilar block diagram requires a procedureto derive the difference equation

Step Description

(a) Create a signal label for the input to each unit delay

(b) Delay outputs can be written in terms of the delay inputs

(c) At each summing node write an equation

(d) Reduce the multiple equations you obtain via a series substitutions similar to solving a system of equations

y n 3x n 3x n 1– 2x n 2– 2x n 3– –+ +=

y n v1 n v2 n v3 n v4 n + + +=

b0x n b1x n 1– +=

b2x n 2– b3x n 3– + +

ECE 2610 Signals and Systems 5–22

Page 23: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Implementation of FIR Filters

Example: A Transposed Block Diagram

• To discover the difference equation we begin by writingequations at summer output

• Next make substitutions, beginning with

• Next substitute in

UnitDelay

UnitDelay

UnitDelay

y n

x n

b3

b2

b1

b0

v3 n

v2 n

v1 n

y n b0x n v1 n 1– +=

v1 n b1x n v2 n 1– +=

v2 n b2x n v3 n 1– +=

v3 n b3x n =

v1 n

y n b0x n b1x n 1– v2 n 2– + +=

v2 n

ECE 2610 Signals and Systems 5–23

Page 24: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Linear Time-Invariant (LTI) Systems

• Finally substitute in

• The block diagram studied in the last example implements atransposed direct form

– Notice that the order of operation is different from thedirect form, specifically the signal flow is in the oppositedirection and the input and output are swapped

– Changing the order of operations can be important inapplications where hardware architectures come into play,e.g., VLSI designs or particular FPGA structures for highspeed DSP

– Finite word-length effects also come into play whenchoosing the block diagram topology

Linear Time-Invariant (LTI) Systems

• The FIR filter we have been considering has two importantproperties that need further discussion

– linearity

– time invariance

• In this section of the notes and text, a transformation of theinput signal to the output signal is denoted via

y n b0x n b1x n 1– b2x n 2– v3 n 3– + + +=

v3 n

y n b0x n b1x n 1– b2x n 2– b3x n 3– + + +=

x n y n

ECE 2610 Signals and Systems 5–24

Page 25: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Linear Time-Invariant (LTI) Systems

(text) or (notes) (5.23)

• This notation applies to difference equation systems as wellas instantaneous systems such as

Time Invariance

• A discrete-time system is time-invariant if for an inputdelayed/shifted by , the output is also delayed by the sameamount, i.e.,

(5.24)

given that and (5.24) holds for any

Example:

• Using the above proof template, we let

,

that is we delay the input before it enters the system

x n y n x n y n

y n x2 n =

n0

x n n0– y n n0–

x n y n n0

y n ax n b+=

w n ax n n0– b+=

ECE 2610 Signals and Systems 5–25

Page 26: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Linear Time-Invariant (LTI) Systems

• Now we compare to

so the system is time-invariant

Example:

• Let

– Note the delay is applied before being input to the system

• Now compare the delayed output to

so the system is not time-invariant

Linearity

• For a system to be linear, superposition must hold, meaningthat given and , then it followsthat

(5.25)

for all values of and

– As a special case results in

y n n0– w n

y n n0– ax n b+ n n n0– ax n n0– b+= =

yes! w n =

y n nx n =

w n nx n n0– =

w n

y n n0– n n0– x n n0– = nx n n0– w n =

x1 n y1 n x2 n y2 n

x n x1 n x2 n +=

y n y1 n y2 n +=

1= =

ECE 2610 Signals and Systems 5–26

Page 27: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Linear Time-Invariant (LTI) Systems

(5.26)

– Also if we have

(5.27)

Example: Revisit

• Using the above proof template,

and

x n x1 n x2 n += y1 n y2 n + y n =

0=

x n x1 n = y1 n y n =

y n nx n =

w n nx1 n nx2 n +=

y n n x1 n x2 n + =

nx1 n nx2 n +=

ECE 2610 Signals and Systems 5–27

Page 28: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Linear Time-Invariant (LTI) Systems

• Thus we see that , so the system is linear

Example:

• Again using the template,

and

• The last term of does not agree with the last term of, thus the system is not linear

– Note that if , then linearity holds

The FIR Case

• A special case of interest is the FIR filter system we havebeen studying

Time Invariance: Let initially, in forming

y n w n =

y n ax n b+=

w n ax1 n b+ ax2 n b+ +=

a x1 n x2 n + b + +=

y n a x1 n x2 n + b+=

a x1 n x2 n + b+=

w n y n

b 0=

v n x n n0– =w n

w n bkv n k– k 0=

M

bkx n k– n0– k 0=

M

= =

bkx n n0– k– k 0=

M

=

ECE 2610 Signals and Systems 5–28

Page 29: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Convolution and LTI Systems

Next,

Which proves time invariance!

Linearity: Input

Which proves linearity!

• An FIR filter is an example of a linear time-invariant (LTI)system

Convolution and LTI Systems

Will will now establish that the impulse response characterizesany LTI system, and the convolution of the input with theimpulse response produces the output.

y n bkx n k–

k 0=

M

=

y n n0– bkx n n0– k–

k 0=

M

=

x1 n x2 n +

y n bk x1 n k– x2 n k– + k 0==

bkx1 n k– k 0=

M

bkx2 n k– k 0=

M

+=

y1 n y2 n +=

ECE 2610 Signals and Systems 5–29

Page 30: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Convolution and LTI Systems

Derivation of the Convolution Sum

• Step 1: For any signal we can write

(5.28)

where in the most general case the sum runs from to +

• Step 2: Time invariance means that

for any l

• Step 3: Apply (5.28) on both sides to the system and use lin-earity to write

(5.29)

• For the case of an input signal having support over the entireaxis, n, the convolution sum formula becomes

(5.30)

for all LTI systems

x n x l n l– l=

n n0– h n n0–

so x l n l– x l h n l–

x n x l n l– l=

x l h n l– l y n =

y n x l h n l– l –=

=

ECE 2610 Signals and Systems 5–30

Page 31: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Convolution and LTI Systems

Example: FIR Convolution

• For the special case of nonzero over the interval , the sum limits of (5.30) are reduced since is

zero outside the interval

• Solving the inequality for we have

so

(5.31)

Example: Proof that (5.17) and (5.31) are Equivalent

• Starting from (5.31) we change variables in the sum formulaby letting

• With it follows that

• With k the new summation variable, the lower sum limit of(5.31) becomes

• The upper sum limit becomes , so

(5.32)

• Where the last step follows from the fact that changing theorder of the summation does not alter the sum

h n 0 nM h n l–

0 n l– M

l

n M– l n

y n x l h n l– l n M–=

n

=

k n l–=

k n l–= l n k–=

l n M–= k n n M– – M= =

l n= k n n– 0= =

y n x n k– h k k M=

0

x n k– h k k 0=

M

= =

ECE 2610 Signals and Systems 5–31

Page 32: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Convolution and LTI Systems

Some Properties of LTI Systems

• Convolution as an Operator:

– When viewed as an operator we are saying that is theresult of convolving the sequence with

Example: Convolving with

• When one of the two signals is an impulse sequence, we get aresult known as the sifting property

(5.33)

• The impulse sequence inside the sum turns on only when k =, so only one term of the sum is retained (sifted out)

• Commutative Property:

– In an earlier example we showed that the convolution sumfor FIR filtering can be written in two ways; this estab-lished the commutative property as a special case

– In general terms we can write

(5.34)

Now let in the sum to obtain

y n x n *h n =

y n x n h n

n n0–

x n * n n0– x k n n0– k– k –=

=

x n n0– =

n n0–

x n *h n h n *x n =

y n x n *h n x l h n l– l –=

= =

k n l–=

ECE 2610 Signals and Systems 5–32

Page 33: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Cascaded LTI Systems

(5.35)

• Associative Property:

– This property applies when three signals and two convolu-tions are involved

– It says that either convolution operation may be done first

– proof in text

Cascaded LTI Systems

• Cascaded LTI systems occur frequently in practice, e.g., asignal must go through two filtering operations before thefinal result is obtained

• The natural question is how is related to , ,and ?

• To start with we know that

• Likewise we know that

x n *h n x n k– h k k +=

=

x n k– h k k –=

h n *x n ==

x1 n *x2 n *x3 n x1 n * x2 n *x3 n =

LTI #1

h1 n LTI #2

h2 n x n

w n y n

y n x n h1 n h2 n

w n x n *h1 n =

y n w n *h2 n =

ECE 2610 Signals and Systems 5–33

Page 34: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Cascaded LTI Systems

• Putting these two results together we obtain

(5.36)

• From the commutative associative properties, we can alsowrite that

(5.37)

which establishes that we may change the order of the LTIsystems in the cascade

• Thus when we have a cascade of LTI systems the equivalentimpulse response is

(5.38)

Example: 4-point Moving Average and Backwards Difference

• Consider the cascade of a moving average system withimpulse response

y n x n *h1 n *h2 n =

y n x n * h1 n *h2 n =

x n * h2 n *h1 n =

x n *h2 n *h1 n =

LTI #2

h2 n LTI #1

h1 n x n

v n y n

h n h1 n *h2 n h2 n *h1 n = =

h1 n 1 4 , 0 n 3 0, otherwise

=

ECE 2610 Signals and Systems 5–34

Page 35: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Cascaded LTI Systems

and a first-order backwards difference system, which has dif-ference equation

which implies

• We know that the impulse response of the cascade, , isgiven by

• We can again use the table method introduced in the text orthe alternate table method introduced in the notes, to find

– Since has support on the interval [0, 3], the sum lim-its run from to

– The support interval for runs [0+0, 3+1] = [0, 4]

y n w n w n 1– –=

h2 n n n 1– –=

h1 n h2 n x n y n w n

h3 n

h3 n h1 n *h2 n =

h1 k h2 n k– k –=

=

h3 n

h1 n k 0= k 3=

h3 n

ECE 2610 Signals and Systems 5–35

Page 36: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Cascaded LTI Systems

• We can check this using MATLAB’s convolution function>> conv([1 1 1 1]/4,[1 -1])

ans = .25000 0 0 0 -.25000 % first point at n=0

• We can now draw the direct form block diagram correspond-ing to

vs.

0 -1 1 0 0 0 0 0 1/4

0 0 -1 1 0 0 0 0 0

0 0 0 -1 1 0 0 0 0

0 0 0 0 -1 1 0 0 0

0 0 0 0 0 -1 1 0 -1/4

h1 k k

h2 n k– 14--- 1

4--- 1

4--- 1

4--- h3 n

n 0=

n 1=

n 2=

n 3=

n 4=

h3 n

UnitDelay

UnitDelay

UnitDelay

x n

y n

14---–

14---

x n 1– x n 2– x n 3–

UnitDelay

x n 4–

ECE 2610 Signals and Systems 5–36

Page 37: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Cascaded LTI Systems

Filtering a Sinusoidal Sequence with a Moving Average Filter

• To provide motivation for studying the frequency response ofFIR filters, in this section we will consider the output of a 4-tap ( ) moving average filter when

• Specifically we will consider >> n = 0:100;>> h1 = [1 1 1 1]/4;>> x1 = cos(pi/8*n);>> x2 = cos(pi/2*n);>> y1 = filter(h1,1,x1);>> y2 = filter(h1,1,x2);

• The output signal at is still a sinusoid, but theamplitude is reduced and there is small amount of phase shift

M 3= x n 0n cos=

0 8 and 4=

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

0.5

1

x 1[n]

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

0.5

1

y 1[n]

Index n

0 8 (16 samples per cycle) =

Output signal is still a sinusoid

0 8=

ECE 2610 Signals and Systems 5–37

Page 38: FIR Filters Chapter - University of Colorado Colorado Springsmwickert/ece2610/lecture_notes/... · ECE 2610 Signal and Systems 5–1 FIR Filters With this chapter we turn to systems

Cascaded LTI Systems

• For the case of the output signal disappears

• This filter must have a special property that allows at leastsinusoids of a particular frequency to be blocked

• In Chapter 6 we study the frequency response, and will dis-cover how it is possible for the above to occur

0 5 10 15 20 25 30 35 40−1

−0.5

0

0.5

1x 2[n

]

0 5 10 15 20 25 30 35 40−0.5

0

0.5

y 2[n]

Index n

0 4 (4 samples per cycle)=

After a brief transient, the output signal disappears

0 4=

ECE 2610 Signals and Systems 5–38