I am currently integrating a C-Code (written by a third person) in a Simulink model. In the C-Code various sensor signals are filtered, using a PT1 filter with the following equation:

$$y(t) = \dfrac{u(t) + Cy(t-1)}{C + 1}$$

Where $y(t)$, $u(t)$ and $C$ are the output (the filtered signal), input and a factor applied for each signal individually, respectively.

Looking at the step function response, I can see a typical PT1-behaviour with a gain factor of 1.

I cannot figure out the derivation of this function from the general formulation (the differential equation) of a PT1, which is:

$$Ty'(t) + y(t) = Ku(t)$$

Can any of you guys help me out?


1 Answer 1


The equation being used in code is a discrete-time implementation of the filter. The second equation you gave is a continuous-time expression of the filter dynamics. In order to create a discrete-time filter from the continuous-time dynamics the person who wrote the code used a first order approximation (backwards difference, specifically) of the derivative of $y$, like so:

$$\frac{dy}{dt} \approx \frac{y(t)-y(t-\Delta t)}{\Delta t}$$

Now, if we use the notation $k$ to denote a sample taken at time $t$ and $k-1$ to denote a sample taken at time $t-\Delta t$, then we can derive the equation used in code as follows:

$$T\frac{dy}{dt} + y(t) = Ku(t)$$ $$T \frac{y(k)-y(k-1)}{\Delta t} + y(k) = Ku(k)$$ $$\left(\frac{T}{\Delta t} + 1\right) y(k) = K u(k) + \frac{T}{\Delta t} y(k-1)$$

Now let $K=1$ and $C = \frac{T}{\Delta t}$, and you get:

$$\left(C + 1\right) y(k) = u(k) + C y(k-1)$$ $$ y(k) = \frac{u(k) + C y(k-1)}{C + 1}$$

  • $\begingroup$ Thank you very much for your prompt answer. I have not thought about backwards difference this far, silly me :P This is exactly what I was looking for! $\endgroup$
    – J.M.
    Commented Jan 31, 2017 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.