Sunteți pe pagina 1din 10

2008

Project I Filter Design


6.341 Discrete-Time Signal Processing
One area where discrete-time signal processing has enjoyed widespread use is the field of sampling rate conversion. In this project, we will design several discretetime filters for use in a rate-conversion system, according to a given set of system specifications.

Albert H. Chang Massachusetts Institute of Technology 10/16/2008

Ripple Definitions in MATLAB


Before using MATLAB for filter design, it is critical to understand that MATLAB uses inconsistent definitions of ripple for FIR and IIR filters. In the design of an IIR filter, it takes a specification of ripple magnitude, IIR, as input parameter and assumes the maximum passband gain of unity and the minimum passband gain of - IIR dB. On the other hand, in the design of FIR filters in MATLAB, specifying the ripple magnitude to be FIR, the maximum passband gain is assumed to be 20xlog10(1 + FIR) dB and minimum passband gain is assumed to be 20xlog10(1 - FIR) dB. Thus, given the design specification in IIR filter, we need to convert the specification to FIR filter in order to have a valid correspondence between FIR and IIR designs. Consider an FIR filter that has a maximum passband gain of (1 + FIR) and minimum passband gain of (1 - FIR). To normalize the maximum passband gain for the FIR filter to be unity as in the case of IIR filter design, the minimum passband gain, , would become:

=
The overall gain and FIR will:
1 1+
20

1 1 +

= 10

110 20 1+10 20

gain factor =

1 1+

Rate Conversion Decision


The choice of L (or the up-sampling rate) will determine the cutoff frequency of our low-pass filter. As L gets bigger, the cutoff frequency gets smaller and the transition band will also get smaller as illustrated in figure 1. It is usually harder to design filter with lower cutoff frequency and smaller transition band. Therefore, we want to pick the smallest integer L that satisfies 48 x L / M = 32. A choice of L = 2 and M = 3 will meet the required specification.

x[n]
48 kHz

L=2

xe[n]

H(ejw)
LPF

xi[n]

M=3

xd[n]
32 kHz

-4/L

-3/L -2/L -/L 0 /L 2/L 3/L 4/L

Choose the smallest integer L that satisfies this rate conversion condition to ease the low-pass filter design

Figure 1
1

In addition, we need to convert the width of the transition band from continuous time to discrete time. The conversion procedure is as follows:

Transition Bandwidth =

2 2 248

= 24

Filter Design Flow


The design flow is highlighted in figure 2 below. Here are the steps that we follow: 1. Given set of design specification, program them into MATLAB. 2. Create an ideal magnitude response of the desired filter. 3. Use the order estimation function provided by MALTAB for each type of filter. 4. Reduce the estimated order by 10, since the order estimator might overestimate the order. 5. Design the filter using MATLAB filter design function. 6. Compare the magnitude response of our design with the ideal filter. i. If it meets the design specification, we will finalize the filter and plot the response. ii. If it does not meet the spec, we will increase the filter order by 1 and re-design the filter to check against the ideal case. This design procedure will help us find the minimum filter order that meets the specification.

Filter Design Flow Chart


Set Design Specification Band Freq + Max Gain Filter Order Estimation

Create Ideal Filter

Reduce the Order by 10 Filter Design

CHECK Meet the spec? No

Yes

Finalize Filter PLOTS

Increase N by 1 Figure 2

Finite Precision in MATLAB


While designing in MATLAB, because of the finite precision approximation of root function, we will not get the desired roots back from a polynomial of more than 2rd order. For example, if we create a polynomial function using poly(-1- 1 -1 -1 -1), we will not get -1 back by doing roots(poly(-1 -1 -1 -1 -1)). Instead, we will get complex number circles around -1. One way to solve this problem is using the roots function only for polynomial of order less than 2. By doing roots(poly([-1 -1])), we will be able to get [-1 -1] back. Therefore, when we use the filter design function, we always want the function to return the poles and zeroes location instead of giving us the A and B matrix. By having all the poles and zeroes location, we can use the function zp2sos to create cascaded 2rd order polynomials with equivalent magnitude response as the higher polynomial before. We then have to write our own function to plot the magnitude response of this cascaded filter. However, from the project, we found that even though using the A and B matrix to find the poles and zeroes location is not accurate, using the A and B matrix to plot the frequency response will produce the same result as using the cascaded 2rd order polynomials that we create. Thus, we do not find it is necessary to use the function zp2sos. One exception we find it is necessary to use the function zp2sos is when plotting the frequency response of the Butterworth filter. Since the specification is rather severe, the required order of the Butterworth filter is very high. Using freqz function to plot the frequency response will produce some notable numerical ripple errors at both the passband and stopband. However, using the cascaded 2rd order polynomials to calculate the magnitude response, we will get a gain at the passband much higher than unity due to MATLABs finite numerical precision while multiplying the magnitude response of each 2rd order polynomials. Because we know the maximum gain at the passband for a Butterworth filter is unity, we normalize the gain at the passband by its gain to get rid of the numerical approximation errors.

Final Remarks
For the different types of filter weve designed, Elliptic filter can meet the specification with the lowest filter order while FIR filter generally needs more orders to meet the same specification. Therefore, in order to implement filter with a given specification, the amount of hardware required for FIR filter is higher. However, we can see that both Parks-McClellan and Kaiser FIR filter have constant group delays and all the other IIR filters have their group delay varies with frequency. Varying group delay can be undesirable for many applications. Another benefit of implementing FIR filter is that we do not have to worry about stability problem since there is no feedback. The choice of using FIR and IIR filter really depends on the applications. There is no filter implementation that is always better than the other filter implementation.

Butterworth:
Magnitude (dB)
5000 0 -5000 0 0.1 0.2

43th order

Butterworth Filter

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) Amplitude Response

0.9

Amplitude

1 0.95 0.9 0 0.05 0.1 0.15 0.2 0.25 Normalized Frequency ( rad/sample) Group Delay 0.3

Group delay (samples)

100 0 -100 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) 0.9 1

Butterworth Filter 1

Imaginary Part

0.5 0 -0.5 -1 -3 -2 -1 0 1 Real Part Impulse Response 2 3 43

0.6

Amplitude

0.4 0.2 0 -0.2

10

20

30

40 50 60 n (samples)

70

80

90

Chebyshev Type I:
Magnitude (dB)
0 -1000 -2000 0 0.1 0.2

13th order

Chebyshev Type I Filter

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) Amplitude Response

0.9

Amplitude

1 0.95 0.9 0 0.05 0.1 0.15 0.2 0.25 Normalized Frequency ( rad/sample) Group Delay 0.3

Group delay (samples)

200 100 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) 0.9 1

Chebyshev Type I Filter 1

Imaginary Part

0.5 0 -0.5 -1 -3 -2 -1 0 1 Real Part Impulse Response 2 3 13

0.6

Amplitude

0.4 0.2 0 -0.2

10

20

30

40 50 60 n (samples)

70

80

90

Chebyshev Type II:


Magnitude (dB)
200 0 -200 0 0.1 0.2

13th order

Chebyshev Type II Filter

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) Amplitude Response

0.9

Amplitude

1 0.95 0.9 0 0.05 0.1 0.15 0.2 0.25 Normalized Frequency ( rad/sample) Group Delay 0.3

Group delay (samples)

40 20 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) 0.9 1

Chebyshev Type II Filter 1

Imaginary Part

0.5 0 -0.5 -1 -3 -2 -1 0 1 Real Part Impulse Response 2 3

0.6

Amplitude

0.4 0.2 0 -0.2

10

20

30

40 50 60 n (samples)

70

80

90

Elliptic:
Magnitude (dB)
0 -100 -200 0 0.1 0.2

10th order

Elliptic Filter

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) Amplitude Response

0.9

Amplitude

1 0.95 0.9 0 0.05 0.1 0.15 0.2 0.25 Normalized Frequency ( rad/sample) Group Delay 0.3

Group delay (samples)

1000 500 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) 0.9 1

Elliptic Filter 1

Imaginary Part

0.5 0 -0.5 -1 -3 -2 -1 0 1 Real Part Impulse Response 2 3

0.6

Amplitude

0.4 0.2 0 -0.2

10

20

30

40 50 60 n (samples)

70

80

90

Parks-McClellan:
Magnitude (dB)
0 -100 -200 0 0.1 0.2

85th order

Parks-McClellan Filter

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) Amplitude Response

0.9

Amplitude

1 0.95 0.9 0 0.05 0.1 0.15 0.2 0.25 Normalized Frequency ( rad/sample) Group Delay 0.3

Group delay (samples)

44 42 40 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) 0.9 1

Parks-McClellan Filter 1

Imaginary Part

0.5 0 -0.5 -1 -2 -1 0 1 Real Part Impulse Response 2 3 4 85

0.6

Amplitude

0.4 0.2 0 -0.2

10

20

30

40 50 60 n (samples)

70

80

90

Kaiser Windows:
Magnitude (dB)
0 -100 -200 0 0.1 0.2

140th order

Kaiser Windows Filter

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) Amplitude Response

0.9

Amplitude

1 0.95 0.9 0 0.05 0.1 0.15 0.2 0.25 Normalized Frequency ( rad/sample) Group Delay 0.3

Group delay (samples)

71 70 69 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample) 0.9 1

Kaiser Windows Filter 1

Imaginary Part

0.5 0 -0.5 -1 -3 -2 -1 0 1 Real Part Impulse Response 2 3 140

0.6

Amplitude

0.4 0.2 0 -0.2

10

20

30

40 50 60 n (samples)

70

80

90

S-ar putea să vă placă și