# Draw a structure for IIR Filter given H(z)

This is the transfer function for the Direct Form 1 of the IIR Filter: I'm trying to understand the rules to convert $$H(z)$$ into its corrispondent structure I've just understood how to draw $$H_1(z)$$, but i don't understand why $$H_2(z)$$ is drawed as such in diagram. Can you explain to me ?

ps: can i also implement a FIR filter using Direct Forms 1 and 2 ?

• the FIR would leave out the half on the right because all of the $a_m$ coefficients are zero. – robert bristow-johnson Jan 14 '20 at 17:10
• and the form you have shown is the Direct Form 1. the Direct form 2 would be obtained by swapping the order of the two halves: $H_1(z)$ and $H_2(z)$ and combining the $z^{-1}$ blocks. – robert bristow-johnson Jan 14 '20 at 17:13

You can't implement the transfer function H(z) directly, you need to convert it to a difference equation. However, the process is trivial, so once you understand it you'll see the connection between the diagram and transfer function better.

First, we need to unroll the summation. For example, we get this with m=2, for a second-order equation:

$$H(z) = \frac{b_{0} z^{0} + b_{1} z^{-1} + b_{2} z^{-2}}{a_{0} z^{0} + a_{1} z^{-1} + a_{2} z^{-2}}$$

As the transfer function is the relationship of the system's output to input, we start by making that substitution.

$$H(z) = \frac{Y(z)}{X(z)}$$

$$\frac{Y(z)}{X(z)} = \frac{b_{0} z^{0} + b_{1} z^{-1} + b_{2} z^{-2}}{a_{0} z^{0} + a_{1} z^{-1} + a_{2} z^{-2}}$$

The output is Y, input is X, so this shows that for the fraction on the right, the top part is related to the input and bottom is related to output. Let's rearrange to get output in terms of input.

$$Y(z)(a_{0} z^{0} + a_{1} z^{-1} + a_{2} z^{-2}) = X(z)(b_{0} z^{0} + b_{1} z^{-1} + b_{2} z^{-2})$$

Here we multiply the terms and rearrange to get our difference equation in terms of y[n], the output now.

$$a_{0} y[n] + a_{1} y[n-1] + a_{2} y[n-2] = b_{0} x[n] + b_{1} x[n-1] + b_{2} x[n-2]$$

$$a_{0} y[n] = b_{0} x[n] + b_{1} x[n-1] + b_{2} x[n-2] - a_{1} y[n-1] - a_{2} y[n-2]$$

$$y[n] = \frac{b_{0}}{a_{0}} x[n] + \frac{b_{1}}{a_{0}} x[n-1] + \frac{b_{2}}{a_{0}} x[n-2] - \frac{a_{1}}{a_{0}} y[n-1] - \frac{a_{2}}{a_{0}} y[n-2]$$

And you can see why we typically "normalize" the coefficients by dividing all by a0 to get our final form. I use this prime notation to show that the coefficients are normalized ($$b^{'}_{0}=\frac{b_{0}}{a_{0}}$$) as compared to the above, but we typically assume normalized coefficients.

$$y[n] = b^{'}_{0} x[n] + b^{'}_{1} x[n-1] + b^{'}_{2} x[n-2] - a^{'}_{1} y[n-1] - a^{'}_{2} y[n-2]$$

So, in retrospect you can get some intuition of the block diagram by looking at the transfer function. The summations give the strings of delays and their coefficients, and the denominator becomes subtracted terms in the difference equation.

• You have really helped me a lot. If you have any free time could you check this question ? dsp.stackexchange.com/questions/63226/… – themagiciant95 Jan 14 '20 at 21:07
• Glad it helped! Sorry, I took a quick look at the other problem, but short on time and couldn't think of anything helpful to say off the top of my head. – Nigel Redmon Jan 15 '20 at 23:17

It would help to apply some specificity to the general equation:

$$H(z) = \frac{b_0 + b_1z^{-1}+b_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}}$$

Rearrange into a difference equation, skipping the steps for brevity:

$$y[n] = b_0x[n] +b_1x[n-1]+b_2x[n-1]-a_1y[n-1]-a_2y[n-2]$$

Does the difference equation form show now that the Direct Form structure is derived purely by inspection?

• Okay, but is there a way to do it only watching the transfer function ? (avoiding to use the discrete time formula) – themagiciant95 Jan 14 '20 at 12:37
• For some reason I assumed discrete time there, you are using z for delays. I guess through just knowing it - when I looked I knew how the structure was realised from the equation you gave because I had already seen it – DamienBradley Jan 14 '20 at 12:38
• Also to answer your question on FIR - yes – DamienBradley Jan 14 '20 at 12:40
• I still don't understand how to traslate the z transfer function into that diagram... – themagiciant95 Jan 14 '20 at 13:14
• Do you understand how the difference equation is turned into that diagram? – DamienBradley Jan 14 '20 at 13:15