Suppose I have a digital filter implemented in Direct Form II. How do I initialize the state of the filter as if the input $x[n]$ had a fixed value $x_0$ for all $n<0$?

Direct Form II Filter Topology

  • $\begingroup$ normally we initialize states to zero, which corresponds to your input signal, $x[n]$ being prepended with an infinite number of samples that have zero value. $\endgroup$ – robert bristow-johnson Apr 5 '19 at 22:42
  • 1
    $\begingroup$ solve this equation $$w[-1] = (-a_1) w[-1] + (-a_2) w[-1] + x_0$$ for $w[-1]$. $\endgroup$ – robert bristow-johnson Apr 5 '19 at 22:47
  • 1
    $\begingroup$ I had asked a similar question: dsp.stackexchange.com/questions/50992/… a while back. I had never thought much of filter initialization until I had to implement a 0.01Hz low-pass filter. $\endgroup$ – Izzo May 6 '19 at 0:16

The difference equations for this filter are:

y[n] = b0 w[n] + b1 w[n-1] + b2 w[n-2]
w[n] =    x[n] - a1 w[n-1] - a2 w[n-2]

To achieve steady-state, w[n] == w[n-1] == w[n-2]. Call this value w. Solving the second difference equation, we find w = x/(1 + a1 + a2), where x is the steady-state input value.

  • 1
    $\begingroup$ you should swap the order of the two difference equations. w[n] is calculated first. $\endgroup$ – robert bristow-johnson Apr 5 '19 at 22:40
  • 3
    $\begingroup$ BTW, i hope you're not using a DF2 filter with fixed-point arithmetic. DF2 and fixed-point don't like each other if the filter gets resonant. $\endgroup$ – robert bristow-johnson Apr 5 '19 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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