Chebyshev I and Chebyshev II filters: what are the advantages and disadvantages? And what is the syntax of Chebyshev, explained with ASN Filterscript

### Posts

IIR (infinite impulse response) filters are generally chosen for applications where linear phase is not too important and memory is limited. They have been widely deployed in audio equalisation, biomedical sensor signal processing, IoT/IIoT smart sensors and high-speed telecommunication/RF applications and form a critical building block in algorithmic design.

**Advantages **

- Low implementation footprint: requires less coefficients and memory than FIR filters in order to satisfy a similar set of specifications, i.e., cut-off frequency and stopband attenuation.
- Low latency: suitable for real-time control and very high-speed RF applications by virtue of the low coefficient footprint.
- May be used for mimicking the characteristics of analog filters using s-z plane mapping transforms.

**Disadvantages**

- Non-linear phase characteristics.
- Requires more scaling and numeric overflow analysis when implemented in fixed point.
- Less numerically stable than their FIR (finite impulse response) counterparts, due to the feedback paths.

## Definition

An IIR filter is categorised by its theoretically infinite impulse response,

y(n)=\sum_{k=0}^{\infty}h(k)x(n-k)

\)

Practically speaking, it is not possible to compute the output of an IIR using this equation. Therefore, the equation may be re-written in terms of a finite number of poles \(p\) and zeros \(q\), as defined by the linear constant coefficient difference equation given by:

y(n)=\sum_{k=0}^{q}b(k)x(n-k)-\sum_{k=1}^{p}a(k)y(n-k)

\)

where, \(a(k)\) and \(b(k)\) are the filter’s denominator and numerator polynomial coefficients, who’s roots are equal to the filter’s **poles** and **zeros** respectively. Thus, a relationship between the difference equation and the z-transform (transfer function) may therefore be defined by using the z-transform delay property such that,

\sum_{k=0}^{q}b(k)x(n-k)-\sum_{k=1}^{p}a(k)y(n-k)\quad\stackrel{\displaystyle\mathcal{Z}}{\longleftrightarrow}\quad\frac{\sum\limits_{k=0}^q b(k)z^{-k}}{1+\sum\limits_{k=1}^p a(k)z^{-k}}

\)

As seen, the **transfer function** is a frequency domain representation of the filter. Notice also that the **poles** act on the **output** **data**, and the **zeros** on the **input** **data**. Since the poles act on the output data, and affect stability, it is essential that their radii **remain inside the unit circle **(i.e. <1) for BIBO (bounded input, bounded output) stability. The radii of the zeros are less critical, as they do not affect filter stability. This is the primary reason why all-zero FIR (finite impulse response) filters are always stable.

A discussion of IIR filter structures for both fixed point and floating point can be found here.

## Classical IIR design methods

A discussion of the most commonly used or classical IIR design methods (Butterworth, Chebyshev and Elliptic) will now follow. For anybody looking for more general examples, please visit the ASN blog for the many articles on the subject.

ASN Filter Designer’s graphical designer supports the design of the following four IIR classical design methods:

- Butterworth
- Chebyshev Type I
- Chebyshev Type II
- Elliptic

The algorithm used for the computation first designs an analog filter (via an analog design prototype) with the desired filter specifications specified by the graphical design markers – i.e. pass/stopband ripple and cut-off frequencies. The resulting analog filter is then transformed via the Bilinear z-transform into its discrete equivalent for realisation.

Biquad implementations are advocated for numerical stability.

The Bessel prototype is not supported, as the Bilinear transform warps the linear phase characteristics. However, a Bessel filter design method is available in ASN FilterScript.

As discussed below, each method has its pros and cons, but in general the **Elliptic method should be considered as the first choice as it meets the design specifications with the lowest order** of any of the methods. However, this desirable property comes at the expense of ripple in both the passband and stopband, and very non-linear passband phase characteristics. Therefore, the Elliptic filter should only be used in applications where memory is limited and passband phase linearity is less important.

The Butterworth and Chebyshev Type II methods have flat passbands (no ripple), making them a good choice for DC and low frequency measurement applications, such as bridge sensors (e.g. loadcells). However, this desirable property comes at the expense of wider transition bands, resulting in low passband to stopband transition (slow roll-off). The Chebyshev Type I and Elliptic methods roll-off faster but have passband ripple and very non-linear passband phase characteristics.

## Comparison of classical design methods

The frequency response charts shown below, show the differences between the various design prototype methods for a **5th order lowpass filter with the same specifications**. As seen, the Butterworth response is the slowest to roll-off and the Elliptic the fastest.

**Elliptic**

Elliptic filters offer steeper roll-off characteristics than Butterworth or Chebyshev filters, but are equiripple in both the passband and the stopband. In general, Elliptic filters meet the design specifications with the lowest order of any of the methods discussed herein.

**Filter characteristics**

- Fastest roll-off of all supported prototypes
- Equiripple in both the passband and stopband
- Lowest order filter of all supported prototypes
- Non-linear passband phase characteristics
- Good choice for real-time control and high-throughput (RF applications) applications

## Butterworth

Butterworth filters have a magnitude response that is maximally flat in the passband and monotonic overall, making them a good choice for DC and low frequency measurement applications, such as loadcells. However, this highly desirable ‘smoothness’ comes at the price of decreased roll-off steepness. As a consequence, the **Butterworth method has the slowest roll-off characteristics of all the methods** discussed herein.

**Filter characteristics**

- Smooth monotonic response (no ripple)
- Slowest roll-off for equivalent order
- Highest order of all supported prototypes
- More linear passband phase response than all other methods
- Good choice for DC measurement and audio applications

## Chebyshev Type I

Chebyshev Type I filters are equiripple in the passband and monotonic in the stopband. As such, Type I filters roll off faster than Chebyshev Type II and Butterworth filters, but at the expense of greater passband ripple.

**Filter characteristics**

- Passband ripple
- Maximally flat stopband
- Faster roll-off than Butterworth and Chebyshev Type II
- Good compromise between Elliptic and Butterworth

## Chebyshev Type II

Chebyshev Type II filters are monotonic in the passband and equiripple in the stopband making them a good choice for bridge sensor applications. Although filters designed using the Type II method are slower to roll-off than those designed with the Chebyshev Type I method, the roll-off is faster than those designed with the Butterworth method.

**Filter characteristics**

- Maximally flat passband
- Faster roll-off than Butterworth
- Slower roll-off than Chebyshev Type I
- Good choice for DC measurement applications

For many IoT sensor measurement applications, an IIR or FIR filter is just one of the many components needed for an algorithm. This could be a powerline interference canceller for a biomedical application or even a simpler DC loadcell filter. In many cases, it is necessary to integrate a filter into a complete algorithm in another domain.

Matlab is a well-established numerical computing language developed by the Mathworks that allows for the design of algorithms, matrix data manipulations and data analysis. The product offers a broad range of algorithms and support functions for signal processing applications, and as such is very popular amongst many scientists and engineers worldwide.

## ASN Filter Designer automatic code generator for Matlab

The ASN Filter Designer greatly simplifies exporting a designed filter to Matlab via its automatic code generator. The code generator supports all aspects of the ASN Filter Designer, allowing for a complete design comprised of H1, H2 and H3 filters and math operators to be fully integrated with an algorithm in Matlab.

The Matlab code generator can be accessed via the filter summary options (as shown on the right). Selecting this option will automatically generate a Matlab `.m`

file based on the current design.

A convenient shortcut to the relevant Framework files and examples is available in the Filter summary toolbar via the folder symbol (see left).

Using the three framework files, you may build a demo of your choice based on the exported filter(s) specifications. The **framework supports both Real and Complex filters in floating point** only.

In order to use the generated code in Matlab without the need for Signal Processing Toolbox, the following three framework files are provided in the ASN Filter Designer’s `\Matlab`

directory:

`ASNFDMatlabFilterData.m`

`ASNFDMatlabImport.m`

`ASNFDFilter.m`

These framework files do not have any special Matlab toolbox dependences, and the example script `ASNFDMatlabDemo.m`

demonstrates the simplicity with which the framework can be integrated into your application for your designed filter. Several example filters generated via the automatic code generator are given within `ASNFDMatlabDemo.m`

in order to get you going!

## Comparing the results to Matlab’s Signal Processing Toolbox

It’s sometimes informative to compare the results of the ASN Filter Designer’s DSP library functions to that of Matlab’s Signal Processing Toolbox.

Designing an IIR Chebyshev Type I filter with the following specifications:

Fs: | 500Hz |

Passband frequency: | 0-25Hz |

Type: | Lowpass |

Method: | Chebyshev Type I |

Stopband attenuation @ 125Hz: | ≥ 80 dB |

Passband ripple: | ≤ 0.1dB |

Order: | 5 |

Graphically entering the specifications into the ASN Filter Designer, and fine tuning the design marker positions, the tool automatically designs the filter as a Biquad cascade. Notice that the tool automatically finds the required filter order, and in essence – automatically produces the filter’s exact technical specification!

The frequency response of a 5th order IIR Chebyshev Type I lowpass filter meeting the specifications is shown below:

The resulting filter coefficients are:

Designing the same filter in Matlab using Signal Processing Toolbox:

Fs=500; Rp=0.1; Rs=80; F=2*[25,125]/Fs; [N,Wn]=cheb1ord(F(1),F(2),Rp,Rs) [z, p, k] = cheby1(N,Rp,Wn,'low'); % design lowpass [sos,g]=zp2sos(z,p,k,'up') % generate SOS form

Running the script, we get the following, where each row of `sos`

is a biquad arranged as: ` b0 b1 b2 a0 a1 a2 `

Analysing both sets of numerator and denominator coefficients, we get exactly the same result! But what about the gain? Matlab outputs a net gain, `g = 3.0096e-05`

but the ASN Filter Designer optimally assigns a gain to each biquad. Thus, combining the biquad section gains, i.e. ` 0.078643, 0.013823 `

and `0.027685`

results in a net gain of `3.0096e-05`

, which is exactly the same net gain as Matlab!

Conclusion: the ASN Filter Designer’s DSP IIR library functions completely match Matlab’s Signal Processing Toolbox results!!

The complete automatically generated code is shown below, where it can be seen that the biquad gains have been pre-multiplied with the feedforward coefficients.

## Using the generated code with Signal Processing Toolbox

If you have Signal Processing Toolbox installed, then you may directly use the generated coefficients given in SOS with the `sosfilt()`

command, e.g.

Clear all; ASNFD_SOS=[ 0.07864301814, 0.07864301814, 0.00000000000, 1.00000000000,-0.84271396371, 0.00000000000;... 0.01382289248, 0.02764578495, 0.01382289248, 1.00000000000,-1.70536517618, 0.76065674608;... 0.02768538360, 0.05537076720, 0.02768538360, 1.00000000000,-1.79181447713, 0.90255601154;... ]; y=sosfilt(ASNFD_SOS, x); % x is your input data plot(x,y); % plot results

As seen, it is as simple as copying and pasting the filter coefficients from the ASN Filter Designer’s filter summary into a Matlab script.

### Advanced Solutions Nederland B.V.

Maanlander 47

3824 MN Amersfoort

The Netherlands

Tel: +31 652460840

General enquiries: info@advsolned.com

Technical support: support@advsolned.com

Sales enquiries: sales@advsolned.com