International Journal of Biomedical Signal Processing, 2(1), 2011, pp. 49-53 A SIMPLE APPROACH TO DESIGN LINEAR PHASE IIR FILTERS Shivani Duggal1 and D. K. Upadhyay2 1 Guru Tegh Bahadur Institute of Technology Delhi, E-mail: duggal_shivani@yahoo.com 2 ECE Division N.S.I.T. Dwarka, E-mail: upadhyay_d@rediffmail.com Abstract: This paper proposed a simple technique to design Linear Phase Infinite Impulse Response (IIR) filter. The design problem is formulated as linear equation problem, which uses a frequency domain sampling of the desired Magnitude and Phase response of filters along with optimal solution of linear equations to obtain the filter design. The proposed method can give the best result if we increase the number of samples. We have presented the filter design solving methodology along with the simulation results. Keywords: Finite impulse response, Infinite impulse response, filter design, linear phase filter, Frequency domain sampling. I. INTRODUCTION Finite Impulse Response (FIR) filters are widely used in many digital signal processing applications, especially in the field of communications, because they can exhibit linear phase characteristics. A filter with a nonlinear phase characteristic causes distortion to its input signal, since the various frequency components in the signal will be delayed, in general, by amounts which are not proportional to their frequency, thus altering their mutual harmonic relationships. A distortion of this form is undesirable in many practical digital signal processing applications such as music, video, data transmission and biomedicine and can be avoided by using filters with linear phase over frequency range of interest [10]. Unfortunately, in many cases the order of FIR filters is high for practical implementation. In general, the number of delay elements and multipliers needed for an FIR design is much higher compared to similar Infinite Impulse Response (IIR) implementations. Usually, IIR filters offer computational efficiency and improved selectivity in comparison with FIR filters. But the design of the IIR filter has restriction Phase response is not physically realizable. Some methods in the History try to achieve a good approximation of the linear phase, but results in extensive and complex hardware. We introduce a concept of using the frequency domain samples of the desired magnitude and phase response of the filter and using the same to obtain the filter coefficients to implement the filter. The given magnitude and phase responses of the filter can be sampled at a convenient sampling frequency and the number of samples can be conveniently chosen. Let us consider the standard expression [2] for the IIR filter transfer function. H ( z) = Y ( z) b0 + b1 z −1 ...bN z − N = U( z) 1 + a1 z −1 ...aD z − D (1) Where U (z) is the z-transform of the input signal, Y (z) is the z-transform of the output signal, and ‘a’ and ‘b’ are real valued coefficients. From the above transfer function, we can write the time-domain difference equation as, y(k)=-a1 y(k-1)- a2 y(k-2)-.... aD y(k-D) +b0 u(k) + b1 u(k-1) +... bN u(k-N). (2) where the a and b coefficients are exactly the same as in the transfer function above, k is the time index, u (k) and y (k) are the current values of the input and output (respectively), u(k – N) was the input value N samples in the past, and y(k – D) was the output value D samples in the past. Generally, if, frequency response of a system at a frequency ω1 is given in magnitude/phase form as A 1 ∠ϕ 1 the output amplitude will be A1 times the input amplitude and the output phase will be shifted an angle ϕ1 relative to the input phase when a steadystate sine or cosine wave of frequency ω1 is applied to the system. For instance, if the input to the system described above at time instance ‘k’ is u 1(k) = Cos(kω1ts), where ts is the sampling period, then the output will be y1(k) = A1 Cos(kω1ts + ϕ1). The input 50 International Journal of Biomedical Signal Processing and output values at any sample time can be determined in a similar manner. The final sampled values in the matrix form with time index (k=0) is, A= 7 2 2 3 4 5 B= 1 2 3 Possible Selections: (3) 7 2 A1 = B1 = 2 3 1 2 3 2 , A 2 = 4 5 B2 = 4 5 A3 = B3 = 7 2 The above equation is similar to AX ≈ B. the matrix ‘A’ contains the sampled coefficients at different frequencies and the column vector ‘X’ contains the filter coefficients. The first ‘D’ values in ‘X’ represent the coefficients a1, a2, etc in denominator and the next ‘N’ values give the b0, b1, b2, etc coefficients in numerator. The column vector ‘Y’ is the desired output value (both amplitude and phase) at specific frequencies. Our aim now is to solve the above problem, and get the filter coefficients given by the vector ‘X’. Standard methods use the inverse of the matrix ‘A’ .If the inverse of the matrix does not exist, then Pseudo inverses [9] can be used. To make the procedure simple, we introduce the concept of optimal solution of linear equation into this context. II. DESIGN METHODOLOGY Now we can move on to formulate the problem to find the filter coefficients. The knowledge of desired frequency response (both magnitude as well as phase) is the only requirement. Here we try to reduce the error to get the best solution by minimizing this error parameter. The algorithm which we follow to get the best solution is as given. A. Algorithm for Low Pass Filter 1. Generate sample table (Phase, Amplitude, Frequency) for Low Pass Filter from desired magnitude and phase response. 2. Select order N for numerator and D for denominator. 3. Compute the matrices ‘A’ & ‘B’ Which is in the same form as (3) using values of sample table and N, D for particular selected value of sample time ts. 4. Select all possible combinations of equations from matrix ‘A’ such that we will be able to form square matrix & accordingly ‘B’ is selected. For example: 2 3 3 1 5. For each Square matrix computed we will be able to find trial solution of ‘X’ by Xn= Inv (An)*Bn. (4) 6. Using all trial solutions of ‘X’ we find error by €n = (An*Xn - Bn) for all values of n (5) 7. We select trial ‘X’ solution as desired filter coefficients for which error €n is minimum. B. Algorithm for Band Pass and High Pass Filters 1. Same as step 1 of low pass filter the only difference here we generate sample table (Phase, Amplitude, Frequency) for Band Pass and High Pass Filters respectively using desired magnitude and phase response of Band Pass and High Pass filters. 2. Select order N for numerator and D for denominator. 3. Compute the matrices ‘A’ & ‘B’ as in Low Pass Filter using values of sample table and N, D for particular selected value of sample time ts. Steps 4, 5, 6 and 7 are repeated for BP/HP as in Low pass filter. III. SIMULATION RESULTS We have taken few examples [11], [12], [13] of low pass; band pass and high pass filter we have chosen a second order filter, with N = D = 2 , sampling rate ts is 10-3s and solved the above formulated problem using Matlab. A. Simulation Results Low Pass Filter The desired response of Low pass IIR Filter has the following: Specifications fs1at 100 Hz, fs2 at 350 Hz and the total frequency is 500 Hz. The signal is sampled corresponding to phase, amplitude and frequency. We have experimented with 16 samples. Using, the same procedure as discussed in Algorithm for Low Pass Filter, we obtained the Filter coefficients as given in Table 1. 51 A Simple Approach to Design Linear Phase IIR Filters Table 1 Obtained Coefficients - LPF a0 1 a1 a2 b0 b1 b2 0.1995 -0.3855 0.2657 0.4077 0.1408 The obtained transfer function (6) are used to plot the magnitude and phase response and the results are compared with the desired one as shown in Figure 1. OBTAINED TRANSFER FUNCTION Y ( z) HLP(Z) U( z) = 0.2657 + 0.4077 z −1 + 0.1408 z −2 1 + 0.1995 z −1 − 0.3855 z −2 (6) Results Discussion (Low Pass Filter) The obtained response better approximates the desired one with just 16 samples and a second order filter. It can be inferred that the phase response exhibits almost linear characteristics in our pass band which is 0 - 100Hz. We are not concerned of the phase relation in the stop band, but the phase is a linear curve in stop band also. The small deviation in the response in the transition from the pass band to stop band can be rectified by increasing the number of sample points in this region. Figure 1b: Comparison of Desired and Obtained Phase Responses of the Low Pass Filter With this method, a linear phase response can be achieved even with an IIR filter. B. Simulations Results Band Pass We now discuss the second example of designing a band pass filter. A Band pass IIR Filter was designed for the given Specifications: fs1at 100 Hz, fs2 at 350 Hz and the total frequency is 500 Hz. The signal is sampled corresponding to amplitude, phase and frequency. We have experimented with 16 samples. Using, the same procedure as discussed in Algorithm for Band Pass Filter, we obtained the Filter coefficients as given in Table 2. Table 2 Obtained Coefficients - BPF a0 a1 a2 b0 b1 b2 1 -0.4705 0.0729 0.5132 0.0329 -0.4287 The obtained transfer function (7) are used to plot the magnitude and phase response and the results are compared with the desired one as shown in Figure 2. OBTAINED TRANSFER FUNCTION Figure 1a: Comparison of Desired and Obtained Magnitude Responses of the Low Pass Filter H BP (Z ) = Y ( z) 0.5132 + 0.0329 z −1 − 0.4287 z −2 = (7) U( z) 1 − 0.4705 z −1 + 0.0729 z −2 52 International Journal of Biomedical Signal Processing samples. By Increasing the Number of samples, the obtained response may be further improved. C. Simulations Results High Pass The Third example we have considered is that of a High pass filter. The procedure similar to the previous examples is followed here also. A High pass IIR Filter was designed for the given Specifications: stop band1at 100 Hz, stop band2 at 350 Hz and the total frequency is 500 Hz. The signal is sampled corresponding to amplitude, phase and frequency. We have experimented with 16 samples. Using the same procedure as discussed in Algorithm for High Pass we obtained the Filter coefficients as given in Table 3. Table 3 Obtained Coefficients - HPF Figure 2a: Comparison of Desired and Obtained Magnitude Responses of the Band Pass Filter a0 a1 a2 b0 b1 b2 1 -0.3407 0.0671 0.4222 -0.7052 0.2805 OBTAINED TRANSFER FUNCTION H BP (Z ) = Y ( z) 0.4222 − 0.7052 z −1 + 0.2805 z −2 = (8) U ( z) 1 − 0.3407 z −1 + 0.0671 z −2 The obtained transfer function (8) are used to plot the magnitude and phase response and the results are compared with the desired one as shown in Figure 3. Figure 2b: Comparison of Desired and Obtained Phase Responses of the Band Pass Filter Results Discussion (Band Pass Filter) The phase response in the pass band, that is 100 Hz – 350 Hz, is quite linear with respect to frequency. The small deviation in the response in the transition from the pass band to stop band can be rectified by increasing the number of sample points in this region. We have experimented with 16 Figure 3a: Comparison of Desired and Obtained Magnitude Responses of the High Pass Filter 53 A Simple Approach to Design Linear Phase IIR Filters by WLS techniques. IEEE Trans. on ASSP, 38(2): 2478211; 252, 1990. [2] T. W. Parks and C. S. Burrus. Digital Filter Design. John Wiley & Sons, New York, 1987. [3] L. R. Rabiner and B. Gold. Theory and Application of Digital Signal Processing. Prentice-Hall, Englewood Cliffs, NJ, 1975. [4] S. R. Powell and P. M. Chau, “A technique for realizing linear phase IIR filters,” IEEE Trans. Signal Processing, vol. 39, pp. 2425–2435, Nov. 1991. [5] V. Sreeram and P. Agathoklis, “Design of linear Phase IIR filters via impulse response gramians,” IEEE Trans. Signal Processing, vol. 40, pp. 389-394, 1992. [6] G. Strang “Linear Algebra and its Applications”, 3rd ed. Thomson Brooks/Cole. [7] S. K. Mitra, J. Kaiser, Handbook for Digital Signal Processing, 1993 John Wiley and Sons, Inc. [8] A. N. Willson and H.J. Orchard, “An improvement to the Powell and Chau linear phase IIR filters,” IEEE Trans. Signal Processing, Vol. 42, pp. 2842-2848, Oct. 1994. [9] B. Djokic, M. Popovic, and M. Lutovac, “A new improvement to the Powell and Chau linear Phase IIR filters,” IEEE Trans. Signal Processing, Vol. 46, pp. 1685-1688, 1998. Figure 3b: Comparison of Desired and Obtained Phase Responses of the High Pass Filter Results Discussion (High Pass Filter) The obtained response better approximates the desired one with just 16 samples and a second order filter. It can be inferred that the phase response exhibits almost linear characteristics in our pass band which is 100-350Hz. The small deviation in the response in the transition from the pass band to stop band can be rectified by increasing the number of sample points in this region. IV. CONCLUSION This methodology for design of linear phase IIR filters is very simple. This requires only very low computational resources in spite of a very good approximation of the linear phase response. The design problem is formulated as linear equation problem, which uses a frequency domain sampling of the desired Magnitude and Phase response of filters along with optimal solution of linear equations to obtain the filter design. The proposed method can give the best result if we increase the number of samples. The results can be further improved by proper choice and position of sample points. It is very simple technique that may be effectively adopted by the design engineers. REFERENCES [1] Takao Kobayashi and Satoshi Imai. Design of IIR digital filters with arbitrary log magnitude function [10] A. Kurosu, S. Miyase, S. Tomiyama, and T. Takebe, “An analysis of linear phase IIR filters and a condition for perfect linear phase,” in proc. School Eng. Tokai Univ. Series J, Vol. 39.1999. [11] Ricardo A .Vargas and C. Sidney Burrus. On the design of IIR filters with arbitrary frequency response. In Proceedings of IEEE International Conference on Acoustics Speech and Signal Processing, ICASSP-01, Salt Lake City, May 2001. [12] R. Lyons, Understanding Digital Signal Processing, 2nd ed., Upper Saddle River, NJ: Prentice-Hall, pp. 232–240, 2004. [13] G.Berchin, “Precise Filter Design” IEEE Signal Processing Magazine, January 2007. [14] C. Sidney Burrus and Ricardo A .Vargas. The direct design of recursive or IIR digital filters. In Proceedings of International Symposium on Communications, Control, and Signal Processing, ISCCSP-08, Malta, March 2008. [15] L. B. Jackson. Frequency-domain steiglitz-mcbride method for least-squares IIR filters design, arma modeling, and periodogram smoothing. IEEE Signal Processing Letters, 15: 498211; 52, 2008. [16] C. Sidney Burrus, “Direct Frequency Domain IIR Filter Design Methods” Version 1.1: Jun 24, 2008. [17] R. Ramanathan, K. P. Soman, A Novel Methodology for Designing Linear Phase IIR Filters. International Journal of Recent Trends in Engineering, 1(3), 2009.