Differential equations (ODE) - P2prod/Filter-Modeling-Simulation GitHub Wiki

Why ODEs?

Because an ODE (ordinary differential equation) is the same thing than a transfer function. Laplace, a french mathematician, developed an ingenious method based on ready-to-use tables for easily “solving” ODEs using the transform named after him (to know more about tables see https://lpsa.swarthmore.edu/LaplaceZTable/LaplaceZFuncTable.html). This was in 1812.

Principle

Let be an ODE of order 1 of the kind $$a \cdot y'(t) + b \cdot y(t) = c$$. The Laplace transform applied to this ODE gives:

  1. The original differential equation is : $$a \cdot y'(t) + b \cdot y(t) = c$$

  2. Replace c by u(t), which represents the system input: $$a \cdot y'(t) + b \cdot y(t) = u(t)$$

  3. Let's apply the Laplace transform with zero initial conditions (y(0) = 0): $$a \cdot (s \cdot Y(s) - y(0)) + b \cdot Y(s) = U(s)$$ $$a \cdot s \cdot Y(s) + b \cdot Y(s) = U(s)$$ (because y(0) = 0)

  4. Let's factor Y(s): $$(a \cdot s + b) \cdot Y(s) = U(s)$$

  5. Let's isolate Y(s): $$Y(s) = \frac{U(s)}{a \cdot s + b}$$

  6. The transfer function H(s) is defined as the ratio Y(s)/U(s): $$H(s) = \frac{Y(s)}{U(s)} = \frac{1}{a \cdot s + b}$$

Therefore, the transfer function is:

$$H(s) = \frac{1}{a \cdot s + b}$$

ODE applied to the filters

By applying the same principle to the following filters, we can write the corresponding ODEs.

1st order filters

Low pass

$$H(s) = \frac{1}{1 + \tau \cdot s}$$ gives $$\tau \cdot y'(t) + y(t) = u(t) $$


High pass

$$H(s) = \frac{\tau \cdot s}{1 + \tau \cdot s}$$ gives $$\tau \cdot y'(t) + y(t) = \tau \cdot u'(t) $$


2nd order filters

Low pass

$$H(s) = \frac{1}{\tau^2 \cdot s^2 + 2 \cdot z \cdot \tau \cdot s + 1}$$ gives $$\tau^2 \cdot y"(t) + 2 \cdot z \cdot \tau \cdot y'(t) + y(t) = u(t) $$


High pass

$$H(s) = \frac{\tau^2 \cdot s^2}{\tau^2 \cdot s^2 + 2 \cdot z \cdot \tau \cdot s + 1}$$ gives $$\tau^2 \cdot y"(t) + 2 \cdot z \cdot \tau \cdot y'(t) + y(t) = \tau^2 \cdot u"(t) $$


3rd order filters

$$H(s) = \frac{a_3 \cdot s^3 + a_2 \cdot s^2 + a_1 \cdot s + 1}{b_3 \cdot s^3 + b_2 \cdot s^2 + b_1 \cdot s + 1}$$ gives $$a_3 \cdot y'''(t) +a_2 \cdot y"(t) + a_1 \cdot y'(t) + y(t) = a_3 \cdot u'''(t) +a_2 \cdot u"(t) + a_1 \cdot u'(t) + u(t) $$

Lead-lag filters

$$H(s) = \frac{1 + \tau_1 \cdot s}{1 + \tau_2 \cdot s}$$ gives $$\tau_1 \cdot y'(t) + 1 =\tau_2 \cdot u'(t) + 1$$