## Implementation of a filters

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 * y2x2 = x1x1 = xny2 = y1y1 = 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 * s2yn = b0 * s0 + b1 * s1 + b2 * s2s2 =      s1s1 =      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 + s2yn =      s4 + b0 * vns4 =      s3 + b1 * vns3 =           b2 * vns2 =      s1 - a1 * vns1 =         - 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 * xns2 = s1 + b1 * xn - a1 * yns1 =      b2 * xn - a2 * yn

## Symbol to represent Emergency Response Team (ERT) Bedrijfshulpverlening (BHV)

Emergency response officers (ERT), or in Dutch Bedrijfshulpverlening (BHV), within companies are trained in providing both first aid and limiting and combating (small) fires. All to limit the consequences of accidents. Various icons are used to resemble these organisations. One symbol which I have seen quiet often is the combination of first aid and a fire symbol.

However, since there was not yet a vector format available, I created one. Using the established first aid and fire sign from ISO 7010.

On the left the fire symbol with the red color. On the right half of the first aid cross with the green color. The red and green color form a gradient in the middle.

## Filters in Control Systems

In this blog I want to elaborate on the various types of filters that are being used in Control Systems. These filters are often used in combination with a PI, PD or PID controller to obtain a robust controller. The filters which we will discuss are:

• Low-Pass filter
• High-Pass filter
• Notch filter

Using these four filters we can create other filter types, such as a Band-Stop or Band-Pass filter. The behavior of each filter can be captured by a transfer function in the continuous-time using the Laplace domain of either first and/or second order. We use the transfer functions to describes the filter and as such the relation between the input and the output . Throughout this blog we will write the equations in the form of their angular frequency in [rad/s], also known as radian frequency. However, we will specify filters using their frequency in [Hz]. Using the radial frequency notation results in a more visual compact formula. Additionally, it is also possible to specify the filters in form of their time constant in [s]. The following relation holds between the angular frequency, frequency and time constant.

Many forms are used within literature, one book will use angular frequencies, the other will use time-constants. Finally, for second order filters, the only filter with possibly complex poles or zeros, can be written in various ways. We will specify second order filters in terms of the damping of the corresponding frequency. It is also possible to describe these formulas using the Quality factor . Whereas describes how oscillations decay in a system after a disturbance,  describes how underdamped the system is. The following relation holds between and

## Low-pass filter

A low-pass filter is used to pass signals with a frequency lower than a certain cut-off frequency . Below the formulas for both the first- and second-order low-pass filter is given.

Herein, denotes the gain, denotes the low-pass cut-off frequency and denotes the damping. Whereas the first-order supresses with 20 [dB/dec], the second-order supresses with 40 [dB/dec]. Low frequent the filter gain is .

## High-pass filter

The complement of a low-pass filter is a high-pass filter. This filter is used to pass signals with a frequency higher than a certain cut-off frequency . Below the formulas for both the first- and second-order high-pass filter is given.

Herein, denotes the gain, denotes the high-pass cut-off frequency and denotes the damping. Likewise as the low-pass filter the first-order supresses frequencies with 20 [dB/dec] and the second-order with 40 [dB/dec].

A lead-lag filter, also known as a lead-lag compensator, is often mainly used for phase compensation rather then magnitude. Below the formula for a lead or lag filter is shown.

Herein, and denote the frequency of the pole and zero, respectively. The filter functions as a lead filter if   and otherwise as a lag filter. The filter has its maximum or minimum phase at . Finally, at the filter has a gain of or in case of a lead or lag filter, respectively. Naturally, the filter can be cascaded with itself by which a the filter can be a lead and lag filter simultaneously.

## Notch filter

A notch filter is often used to filter undesired resonance peaks. Below the formula for a notch filter is shown.

Herein, and denote the frequency of the pole and zero, respectively. Likewise, and denote the damping of the pole and zero and is as usual the gain. When the notch will target one specific frequency. The gain at that frequency is given by . When the notch filter is also referred as a skewed notch and the difference between gain at low and high frequencies is given by .