Narrowband Lowpass Digital Differentiator Design

Ivan W. Selesnick Electrical and Computer Engineering Polytechnic University 6 Metrotech Center, Brooklyn, NY 11201 [email protected]

Abstract It is a narrow-band filter if ωc is much smaller than This paper describes a simple formulation for the non- π. Note that a narrow-band filter should have a long iterative design of narrow-band FIR linear-phase low- impulse response if its frequency response is to closely pass digital differentiators. The frequency response of approximate the ideal response. For long impulse re- the filters are flat around dc and have equally spaced sponse it is desirable to have simple design algorithms nulls in the stopband. The design problem is formu- so that ill-conditioning and computational complex- lated so as to avoid the complexity or ill-conditioning ity is minimized. The window method for FIR filter of standard methods for the design of similar filters design is a natural choice in this case. The design when those methods are used to design narrow-band method described here gives an alternative approach. filters with long impulse responses. Figure 2 illustrates the result of filtering an EOG signal with both a full-band differentiator and a 1 Introduction narrow-band lowpass differentiator (with impulse re- To avoid the undesirable amplification of noise in dig- sponse length N = 151 and K = 3 below). As shown ital differentiation, lowpass differentiators can be used in the figure, differentiation with the full-band differ- in place of full-band ones. Lowpass differentiators entiator yields an extremely noisy signal, while low- are used, for example, in airborne laser bathymetry pass differentiation gives a more useful result. [15]. The design of full-band digital differentiators ac- cording to the maximally-flat criterion has been de- 2 Derivation scribed by several authors [1, 5, 6, 8]. The design To design a narrow-band digital filter we can begin of lowpass differentiators can be performed with least with an analog filter, the frequency response of which squares, the Remez algorithm [10] and other meth- is denoted A(f). While the frequency response A(f) ods [7, 11, 13, 9]. The Kaiser window [3] is used to proposed below is not the frequency response of any design lowpass differentiators in [15]. The design of realizable analog filter, it can be converted into a re- maximally-flat lowpass differentiators is described in alizable digital filter. Provided, the filter is narrow- [12]. The design of FIR filters with flat passband and band, the digital-to-analog conversion used below will equiripple stopbands is described in [4, 9, 13, 14]. preserve the shape of the frequency response. This paper describes a simple formulation for the The digital filter design procedure we propose be- non-iterative design of narrow-band FIR linear-phase gins with an analog frequency response having the fol- lowpass digital differentiators. The filters are flat lowing form: around dc and have equally spaced nulls in the stop- band. The impulse response can be written as a sum K X of sines. The design problem is formulated so as to A(f) = a(k, K) (sinc(f − k) − sinc(f + k)) avoid the complexity or ill-conditioning of standard k=1 methods for the design of similar filters when those methods are used to design narrow-band filters with where the sinc function is given by long impulse responses. sin(π f) The frequency response of the ideal lowpass digital sinc(f) := . differentiator is π f  jω j ω |ω| < ωc The function sinc(f) is symmetric (sinc(−f) = HLP (e ) = (1) 0 ωc < |ω| < π sinc(f)) and equal to zero for f = ±1, ±2, ±3,... ; therefore if we define When K = 4, we have s (f) := sinc(f − k) − sinc(f + k) 1 29 427 31 k a(1, 4) = − + π2 − π4 + π6 720 4320 64800 18900 then we have 16 208 2366 496 a(2, 4) = − + π2 − π4 + π6 1. sk(f) is antisymmetric, sinc(−f) = − sinc(f). 45 135 2025 4725 2187 2187 5103 2511 a(3, 4) = − + π2 − π4 + π6 2. sk(f) = 0 for f ∈ Z/{±k}.(sk(f) = 0 whenever 560 160 800 4900 f is an integer different from ±k.) 2048 2048 12544 15872 a(4, 4) = − + π2 − π4 + π6 Therefore, the frequency response A(f) has the fol- 315 135 2025 33075 lowing properties: Other values a(k, K) can be easily computed. Numer- 1. A(f) is antisymmetric, A(−f) = −A(f). ical values of the first coefficients (for K up to 8) are given in Table 1. 2. A(f) = 0 for f = 0, and for f = ±(K +1), ±(K + 2), ±(K + 3),... . 3 Conversion to To convert the analog frequency response A(f) into a The frequency response A(f) is zero at f = 0 in agree- digital frequency response D(f), we can use the digital ment with a differentiator. The stopband of A(f) is sinc function in place of the usual sinc function. The neither equiripple nor maximally flat. The first null digital sinc function dsinc(f, N) can be written as in the stopband depends on K. The exact behavior of A(f) depends on the coefficients a(k, K), however, sin(Nπ f) dsinc(f, N) := . (9) the uniformly spaced nulls in the stopband ensures sin(π f) that the attenuation increases with frequency. The coefficients a(k, K) are to be determined so The digital sinc function defined in (9) is periodic in that the frequency response A(f) approximates f near f with period 2: f = 0: A(f) ≈ f. The design problem for a low- pass differentiator that is flat at dc is given as follows: dsinc(f + 2) = dsinc(f). Given K, find a(k, K) for 1 ≤ k ≤ K such that the derivatives of A(f) at f = 0 match the derivatives of The definition (9) is not the standard form of the dig- the ideal differentiator IdealDiff(f) := f at the point ital sinc function — the only difference is a scaling. f = 0: However, defining dsinc in this way, we have the fol- lowing approximation: A(1)(0) = 1 (2) 1  f  (i) sinc(f) ≈ dsinc ,N for |f| < 0.5 N. A (0) = 0, i = 3, 5,..., 2 K − 1. (3) N N The even derivatives are automatically zero because This approximation is illustrated in Figure 3 for N = A(f) is an odd function, A(−f) = −A(f). This is a 30 and N = 100. As illustrated in the figure, the linear system of equations with an equal number of approximation is more accurate for greater values of equations and variables. N. The design of digital differentiators described in For example, when K = 1, we have a(1, 1) = 1 . 2 this paper is intended for long impulses responses. In When K = 2, we have this case, N is large and the approximation is valid. 1 1 a(1, 2) = − + π2 (4) 4 Digital Lowpass Differentiators 6 9 4 2 Consider the function D(f), based on the digital sinc a(2, 2) = − + π2 (5) function: 3 9 K When K = 3, we have 1 X  f − k  D(f) = a(k, K) dsinc ,N (10) 1 13 7 N N a(1, 3) = − π2 + π4 (6) k=1 48 288 480 f + k  16 16 14 − dsinc ,N a(2, 3) = − π2 + π4 (7) N 15 9 75 243 81 189 For N > K, the function D(f) approximates the func- a(3, 3) = − π2 + π4 (8) 80 32 800 tion A(f) in the range |f| < N/2. To illustrate this approximation for K = 3, N = 30, Figure 1 shows −3 x 10 A(f)−D(f) the difference A(f) − D(f) on the range |f| < N/2. The figure shows that D(f) ≈ A(f) for |f| < N/2. 2 The function D( N ω) is then a 2 π periodic function 2 π 1 of ω and can therefore be used as the frequency re- jω jω sponse H(e ) of a digital filter. Then H(e ) will 0 be approximately maximally flat at ω = 0. The im- pulse response h(n) is given by the inverse discrete- −1 time of H(ejω), −2    −j( N−1 )ω N −10 −5 0 5 10 h(n) = IDTFT e 2 · D ω 2 π f where the phase term is included to make h(n) causal. Figure 1: The function A(f) − D(f); K = 3, N = 30. Then h(n) is a linear-phase FIR impulse response of For large values of N, D(f) is a good approximation length N: to A(f) for |f| < 0.5N.

K 1 X 2πk  (N − 1) h(n) = a(k, K) sin n − N 2 N 2 k=1 [6] B. Kumar and S. C. Dutta Roy. Design of digital differ- entiators for low frequencies. Proc. IEEE, 76(3):287–289, for 0 ≤ n ≤ N − 1. This gives a very simple way March 1988. to design narrow-band digital differentiators. Once a [7] T. W. Parks and C. S. Burrus. Digital Filter Design. John table of values a(k, K) is computed, it can be used re- Wiley and Sons, 1987. gardless of the length N of the impulse response h(n). [8] S.-C. Pei and P.-H. Wang. Closed-form design of maximally The first values (for K up to 8) are given in Table 1. flat FIR Hilbert transformers, differentiators, and frac- The width of the passband is controlled by the pa- tional delayers by power series expansion. IEEE Trans. on Circuits and Systems I, 48(4):389–389, April 2001. rameter K, the number of flatness constraints at dc. [9] R. Rabenstein. Design of FIR digital filters with flatness Note that 2 (K − 1) is the number of zeros of H(z) constraints for the error function. Circuits, Systems, and that lie away from the unit circle, as illustrated in the Signal Processing, 13(1):77–97, 1993. following examples. [10] L. R. Rabiner, J. H. McClellan, and T. W. Parks. FIR Figures 4 and 5 illustrate two digital lowpass differ- digital filter design techniques using weighted Chebyshev entiators designed according to the method described approximation. Proc. IEEE, 63(4):595–610, April 1975. above. The figures illustrate the impulse response Also in [2]. h(n), the frequence response |H(ejω)|, and the zero [11] H. W. Sch¨ussler and P. Steffen. Some advanced topics in filter design. In J. S. Lim and A. V. Oppenheim, editors, diagram. The fourth panel in each figure illustrates Advanced Topics in Signal Processing, chapter 8, pages the magnification of the passband of the differentia- 416–491. Prentice Hall, 1988. tors. [12] I. W. Selesnick. Maximally flat lowpass digital differentia- tors. IEEE Trans. on Circuits and Systems II, 49(3):219– 223, March 2002. References [13] I. W. Selesnick and C. S. Burrus. Exchange algorithms for [1] B. Carlsson. Maximum flat digital differentiator. Electron. the design of FIR filters and differentiators Lett., 27(8):675–677, 11th April 1991. having flat monotonic passbands and equiripple stopbands. IEEE Trans. on Circuits and Systems II, 43(9):671–675, [2] IEEE DSP Committee, editor. Selected Papers In Digital September 1996. Signal Processing,II. IEEE Press, 1976. [14] P. P. Vaidyanathan. Optimal design of linear-phase FIR [3] J. F. Kaiser. Nonrecursive digital filter design using the I - o digital filters with very flat passbands and equiripple stop- sinh . In Proc. IEEE Int. Symp. Circuits bands. IEEE Trans. on Circuits and Systems, 32(9):904– and Systems (ISCAS), pages 20–23, April 1974. Also in 916, September 1985. [2]. [15] H. Wong and A. Antoniou. One-dimensional signal pro- [4] J. F. Kaiser and K. Steiglitz. Design of FIR filters with cessing techniques for airborne laser bathymetry. IEEE flatness constraints. In Proc. IEEE Int. Conf. Acoust., Trans. on Geoscience and Remote Sensing, 32(1):35–46, Speech, Signal Processing (ICASSP), pages 197–200, 1983. January 1994. [5] B. Kumar and S. C. Dutta Roy. Coefficients of maximally linear, FIR digital differentiators for low frequencies. Elec- tron. Lett., 24(9):563–565, 28th April 1988. K a(1,K) a(2,K) a(3,K) a(4,K) a(5,K) a(6,K) a(7,K) a(8,K) 1 0.5000 2 0.9300 0.8599 3 0.9959 1.7037 1.0680 4 0.9999 1.9591 2.3145 1.1673 5 1.0000 1.9966 2.8547 2.7662 1.1913 6 1.0000 1.9998 2.9798 3.6548 3.0723 1.1647 7 1.0000 2.0000 2.9980 3.9336 4.3401 3.2516 1.1058 8 1.0000 2.0000 2.9999 3.9907 4.8393 4.8996 3.3245 1.0277

Table 1: a(k, K) values for 1 ≤ K ≤ 8. The Kth row of the table gives the coefficients a(k, K) required to compute A(f), and the impulse response h(n).

EOG SIGNAL sinc(f) and dsinc(f/N)/N [N = 30] 6 1 4 0.5 2 0 0 −2 −0.5 −4 −6 −1 −20 0 20 2500 3000 3500 4000 4500 f EOG SIGNAL AFTER FULLBAND DIFFERENTIATION sinc(f)−dsinc(f/N)/N [N = 30] 0.02 6 4 0.01 2 0 0

−2 −0.01 −4 −0.02 −6 −15 −10 −5 0 5 10 15 2500 3000 3500 4000 4500 f

EOG SIGNAL AFTER LOWPASS DIFFERENTIATION −3 x 10 sinc(f)−dsinc(f/N)/N [N = 100] 4 6

4 2 2 0 0 −2 −2 −4 −6 −4 −50 0 50 2500 3000 3500 4000 4500 f n Figure 3: Comparison of sinc(f) and dsinc(f/N)/N Figure 2: An EOG signal filtered using full-band and for N = 30 and N = 100. For large values of N, lowpass differentiators. For noisy signals, (narrow- sinc(f) is well approximated by dsinc(f/N)/N for band) lowpass differentiators yield more useful results |f| < 0.5N. than full-band differentiators. −3 −3 x 10 IMPULSE RESPONSE x 10 IMPULSE RESPONSE 4 5

2

0 0

−2

−4 −5 0 20 40 60 80 100 0 20 40 60 80 100

FREQUENCY RESPONSE FREQUENCY RESPONSE 0.05 0.08

0.04 0.06 0.03 0.04 0.02 0.02 0.01

0 0 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1

ZERO DIAGRAM ZERO DIAGRAM 1 1

0.5 0.5

100 100 0 0

−0.5 −0.5

−1 −1 −1 0 1 −1 0 1

FREQUENCY RESPONSE FREQUENCY RESPONSE 0.05 0.08

0.04 0.06 0.03 0.04 0.02 0.02 0.01

0 0 0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2

Figure 4: Lowpass differentiator (K = 4, N = 101). Figure 5: Lowpass differentiator (K = 6, N = 101). The length of the impulse response is N = 101. There The length of the impulse response is N = 101. There are 6 = 2(K − 1) zeros contributing to the shape of are 10 = 2(K − 1) zeros contributing to the shape of the passband. the passband. The passband is wider than that shown in Figure 4.