A Numerical System for Real Time measurements

Generally, a digital filter is a discrete time invariant system, implemented with a finite precision arithmetic, even if using a floating point notation.

The design of a digital filter needs three fundamental steps: the first step is to handle the system user requirements; the second step is the specification approximation through a linear time invariant discrete system, and the last step is the system implementation.

As for the analog filter design case, the system user requirements are given in the frequency domain defining a set of constrains. Unlike the analog filter design, the system user requirements are referred to the frequency characteristics of the digital signal to be filtered. When, as in our case, the signal comes from a periodic sampling and subsequently digital conversion of an analog signal, those user requirements must be bring back to the frequency requirements of the analog signal.

These frequency requirements come from a frequency domain subdivision in three bands (pass-band, transition-band, and rejection-band.). For each band, the user must define the limit values (it depends on the kind of filter: lowpass, highpass, bandpass, or bandstop), and their relative attenuations (in decibel), as shown in following figures (3.1 and 3.2).

Fig. 3.1. Tolerance limits and bands representation in a generic lowpass filter.

Fig. 3.2. Tolerance limits and bands representation in a generic pass band filter.

In case of a lowpass filter (figure 3.1), we need to define the following items:

• Maximum and minimum frequencies of both the pass and rejection bands respectively (and therefore the transition bandwidth).

• Both the pass and rejection bands attenuation.

In case of a highpass filter, we need to define the following items:

• Minimum and maximum frequencies of both the pass and rejection bands respectively (and therefore the transition bandwidth).

• Both the pass and rejection bands attenuation.

In case of a bandpass filter (figure 3.2), we need to define the following items:

• The lower and the higher cut-off frequencies of the pass band.

• The lower and the higher cut-off frequencies of the rejection bands.

• Both the pass and rejection bands attenuation.

In case of a bandstop filter, we need to define the following items:

• The lower and the higher cut-off frequencies of the stop band.

• The lower and the higher cut-off frequencies of the pass bands.

• The stop and pass band attenuations.

The problem in the filter design is to find a time invariant discrete linear system that matches the above requirements. One possible solution is to approximate the required frequency response with a rational function (case of IIR filters) or with a polynomial approximation (case of FIR filters). In both cases, the methodology used is the closed

Due to the lack of literature regarding practical implementation for generic IIR filters, we developed a new methodology to compute the transfer function: the idea, deeply analysed in the next section, is to start from a generic transfer function for an analog lowpass filter with the following form

3.1

From this formula, we can come to the

• The analog filter design technique is very advanced and well tested, so it is suitable the usage of those procedures already in use for the analog filters.

• Most of the design methodologies for the analog filters are based on quite simple design formulae in closed form. Therefore, also these design methodologies are quite simply implemented.

In transforming an analog system in a digital one, we need to obtain the transfer function in the discrete domain (the function in the

A second requirement is that if you start from a stable analog filter, you must obtain a stable digital filter. That is, the digital filter should have poles, in the

Among several design methodologies, for our system we choose the bilinear transformation method [5]. This methodology, in contrast with other methods such as the impulse invariant one, or those based on numerical resolution of the differential equations, do not show aliasing problems. In fact, the method is based on the numerical integration of the differential equation that describes the filter, and completely maps the imaginary axis of the

Fig. 3.3. Bilinear transformation where x is a pole and * is a zero.

The bilinear transformation, which is given by the following formula

3.2

converts a polynomial expression in the s domain (for instance

At this point, it is worth to point out, which relation exists between the frequency responses of

3.3

where Ω represents the digital angular frequency and T the sampling period. This

3.4

The Ω value that minimises the distance between

3.5

where ω is the analog angular frequency.

Fig. 3.4. How frequency warping affects amplitude responses:
a yellow shaded box represents the transfer function in digital domain, while a red shaded box represents is for the analog domain.
Angular frequencies are in rad/s.

As you can see from figure 3.4, you can consider as linear, only the first part at low frequencies because the curve can be approximated by a straight line. For higher frequencies there is a growing compression passing from the continuous domain to the discrete one. In fact, the range 0 ≤ ω ≤ ∞ is mapped into the range 0 ≤ ω ≤ π/2T [rad/s].

3.6

It is well known [5] that the z-transfer function for this system is

3.7

The filter attenuation, in decibel, is defined as

3.8

with

3.9

Depending on the approximation of the function L, you can obtain different filter characteristics (Butterworth, Chebyshev, and elliptical). However, the computation of the coefficients (see details in the following sections) is independent from the approximations used. In fact, the computation of the coefficients depends only on the kind of filter chosen (lowpass, highpass, bandpass, and bandstop). The transform implementing the different filters comes from the following considerations.

Starting from a normalised bandpass filter, it is possible to obtain a generic filter through a specific exchange of parameters. Let me consider, for instance, a normalised transfer function

3.10

in

3.11

then

3.12

This leads to map the

Fig. 3.5 Lowpass to lowpass filter transformation.

Finally, we obtain again a lowpass filter (denormalised), but with angular frequency limits given by ω

3.13

The new domain is shown in figure 3.6.

Fig. 3.6 Lowpass to highpass filter transformation.

To obtain a bandpass filter from a lowpass one, you need to set

3.14

where

Fig. 3.7 Lowpass to bandpass filter transformation.

Last, the case of a bandstop filter from a lowpass one (figure 3.8.)

3.15

Fig. 3.8 Lowpass to bandstop filter transformation.

The following table summarises the four cases:

Table 3.1 Filter transformations, with a lowpass filter as a starting point.

The values of the constants ω,

Table 3.2.

Table 3.3.

To implement the transform from

3.16

where

3.17

where

3.18

The form is a division of second-degree polynomial products, with a first-degree polynomial in case we have an odd number of roots. Without loss of generality, we can consider couples of complex conjugated roots plus, eventually, a real root. In fact, this real root forms the first-degree polynomial; the complex roots form the second-degree polynomial with real coefficients. For instance, even in the case of real roots, we can always refer to a second-degree polynomial, built from binomial products (which form is (

Replacing

Lowpass

3.19

with

3.20

Highpass

3.21

with

3.22

Bandpass

3.23

with

3.24

Bandstop

3.25

with

3.26

Applying the bilinear transformation

3.27

where

Lowpass

3.28

where

Highpass

3.29

For the Bandpass case, the poles are coming from a fourth degree polynomial:

3.30

The typical expression for the fourth degree terms is

3.31

where

3.32

Bandstop

3.33

where

3.34

In this case the

Once we have

3.35

This expression allows you to implement the filter in the direct form.

We can see from tables 3.2 and 3.3 that λ,

3.36

Replacing the above values into the products coefficients, the result is a new

Table 3.4.

Table 3.5.

At this point, it is possible to implement every kind of filter. In the following sections, we describe some of the most common filters. The filter design starts from the approximation of the attenuation function. The most simply approximation is the

An analog filter, for instance a lowpass one with Butterworth approximation, can be designed considering the attenuation function in the following polynomial form

3.37

such that

3.38

Another requirement is that the derivatives of the Taylor series

3.39

In other words, with

3.40

In order to have a normalised approximation, i.e.

3.41

Because the roots

3.42

where the

3.43

All these considerations lead to an IIR filter with Butterworth approximation, whose main characteristic is to be monotonic in both the pass and rejection bands, and with an amplitude response as flat as possible in the pass band (figure 3.9.)

Fig. 3.9 Bode Diagram of the response module of a lowpass Butterworth filter.

For a

All the 2

If

3.44

That is

3.45

So setting

3.46

where

3.47

The minimum value is obtained applying the equality sign.

Table 3.6.

Regarding the above table, we indicated with

Ω

Considering the general transfer function

3.48

If the filter requirements are given, for instance, specifying the maximum approximation error in the pass band, a better approach could be to evenly spread the precision of the approximation in the pass band, or in the rejection band, or in both the bands.

To achieve this result, you can use the Chebyshev approximation for the attenuation function

Fig. 3.10. Bode Diagram of the response module of a lowpass Chebyshev filter: with respect to the figure 3.9, here we used 3 poles instead of 6.

The main advantage of this type of filter, unlike the Butterworth ones, is that given the same design requirements, the filter order is lower (i.e. we need a lower

3.49

where the

3.50

Once again,

A Chebyshev filter differs from the Butterworth one, also in the way the minimum number

3.51

where

3.52

For ω=ω

3.53

Where

3.54

Therefore, for ω

3.55

Nothing is formally changed for the transition factor

Table 3.7 Transition Factor for the Chebyshev filters: see also Table 3.6

Considering the general transfer function

3.56

The basic idea behind the elliptic filters comes considering that if you evenly spread the error over the whole pass band, as previously shown, than it is possible to match the filter design requirements with a lower filter order than when the error can grow monotonically (see Butterworth filter). Given these considerations, it is easy to think to evenly spread the error also over the rejection band. One way is the use an approximation coming from the elliptical function of

The normalised transfer function of the elliptical filter is more complex than the previous ones, and it has the following form

3.57

where

3.58

where

3.59

where

3.60

We still need to introduce another parameter Λ

3.61

Finally

3.62

In order to represent the transfer function in more compact form, we need to define also the following parameters:

3.63

where the value of

3.64

The transfer function is then

3.65

Figure 3.11 shows the Bode diagram of the impulse response module for an elliptical filter. (The design requirements are the same as for the previous cases.)

Fig. 3.11. Bode Diagram of the response module of a lowpass elliptical filter.

Considering the general transfer function

3.66

Table 3.8 shows how to transform the design of a lowpass for the others types: highpass, bandpass, and bandstop filters.

Table 3.8

Generally speaking, the choice between the several networks depends on the coefficients quantisation. In fact, it is well known that the error on a coefficient causes a shift of the root (pole or zero) in the complex plane, leading to a possible filter stability problem. This issue is particular important in the hardware implementations, rather than in the software ones: in our case, we use a numerical representation with 32-bit floating point, which allow us to move the problem from the design phase to the test phase [9]. Our main problem, therefore, becomes the speed performance. Hence, our best network choice is the one with the less number of operations.

To implement the IIR filters, we adopted a direct form (see figure 3.12.). The use of this simple form will help us to achieve real time performances and to avoid big memory overheads:

3.67

Fig. 3.12. Structure to implement an IIR filter in direct form.