The discrete-time transfer function is often obtained from its counterpart, the continuous-time transfer function via discretization. A discrete-time transfer function has the following form:

(1)

Herein, is the input and is the output of the system, and are the degree of the numerator and denominator, respectively. Where , meaning we are dealing with a proper transfer function. While (1) is valid for any order it is not recommended to directly use transfer functions of high order. These can namely introduce numerical problems very quickly. Rather factorize the numerator and denominator of (1) into a cascade of first and second order polynomials.

Now let us look at the simple discrete-time transfer function of order two:

This function is non-causal, because it depends on future inputs. Therefor, both the numerator and denominator are multiplied by reciprocal of the highest order of occuring in the denominator, in this case , to make the system causal. Hence, we obtain:

Followingly, using the linearity and time-shifting properties of the -transform, i.e., and , we obtain the difference equation. Remark that the shift operator is defined as , the forward shift operation and , the backward shift (delay) operator. As a result we obtain,

(2)

Rewriting (2) gives us:

This last equation is the difference equation which we can easily implement on our digital platform. Numerous methods exists on how to implement a filter. Four of these methods are closely related to each other. These are:

- Direct form I
- Direct form II
- Transposed direct form I
- Transposed direct form II

## Direct form I

The direct form I is an FIR filter followed by an IIR filter. That is to say, it implements followed by

(3)

In an algorithm you can implement it as:

yk = b0 * xn + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2

x2 = x1

x1 = xn

y2 = y1

y1 = yn

Where, x1, y1, x2 and y2 are the four state variables.

## Direct form II

The direct form I is an IIR filter followed by an FIR filter. Which implements followed by .

(4)

In an algorithm you can implement it as:

s0 = xn - a1 * s1 - a2 * s2

yn = b0 * s0 + b1 * s1 + b2 * s2

s2 = s1

s1 = s0

Where, s0, s1, s2 are the three state variables.

## Direct form I transposed

Both direct forms can be converted to an equivalent transposed form via:

- Reverse direction of each interconnection
- Reverse direction of each multiplier
- Change junctions to adders and vice-versa
- Interchange the input and output signals

(5)

In an algorithm you can implement it as:

vn = xn + s2

yn = s4 + b0 * vn

s4 = s3 + b1 * vn

s3 = b2 * vn

s2 = s1 - a1 * vn

s1 = - a2 * vn

Note that this form is very inefficient. You can easily shift the delays to the center, obtaining the direct form II.

## Direct form II transposed

(6)

In an algorithm you can implement it as:

yn = s2 + b0 * xn

s2 = s1 + b1 * xn - a1 * yn

s1 = b2 * xn - a2 * yn

## One thought on “Implementation of a filters”

Comments are closed.