Thursday, May 2, 2013

Filtering with differential equations

For those of us who are more familiar with digital filters than their analog counterparts, a one pole lowpass filter is easy:

yn = (1 - β)xn + βyn-1,   0 < β < 1.

But how do you filter a signal with an ordinary differential equation?

Working backwards, we should have an ODE that says

dy/dt + Ay(t) = Bx(t)   (*)

for some suitable constants A and B yet to be found. The differential may be approximated with a forward difference over a short time interval T, so dy(nT)/dt ≈ (y(nT+T) - y(nT))/T. Setting T equal to one sampling period, the discrete time version of (*) is

(yn+1 - yn)/T + ayn = bxn

Perform some algebraic shuffling to and fro of the variables to obtain

yn+1 = bTxn + (1 - aT)yn

and recall that the filter coefficients are 1 - β = bT and β = 1 - aT, hence bT = aT. Now we introduce a new coefficient τ > 0 for the variables in (*) and set 1/τ equal to both A and B. The system then is

dy/dt = (x - y) / τ

where now τ plays the role of a relaxation time constant. The greater τ is, the slower the response of the filter. Also, when the input equals the output the derivative becomes zero, which is to say that the system has unit DC response as required.

blackboard formula

No comments:

Post a Comment

I'm not home right now, but please leave a message and I'll get back to you in the next few years.