# A Guide To Digital Filtering

|Understanding filters is actually simpler than it may first seem. Creating a filter is another story; it’s like being able to drive a car without having to know the intricate details of how the engine and its electronics work. When dealing with filters there are two separate issues: one to do with the sampling rate and frequency content; and the other is to do with the characteristics of filters which applies whether they are analogue or digital filters.

First let us deal with the terminology of filters. This all comes from the days when all processing was analogue.

A **low pass filter** is one which ideally passes through all frequencies up to its **cut-off frequency** and then passes nothing above the cut-off frequency. An ideal **high pass filter** is exactly the opposite: it passes nothing below the cut-off and everything above. An ideal **band pass filter** is just like a combined low pass and high pass filter in series, and so has two cut-off frequencies. The low pass cut-off determines the highest frequency passed whilst the high pass filter sets the lowest frequency passed through the filter. Just think about it! There is, of course, a **band reject filter** which is exactly the opposite of the band pass filter and is like a low pass and a high pass filter joined in parallel.

That’s the ideal situation with perfect cut-offs. However, in any implementation, either digital or analogue, this perfect situation is not possible. In the following we will just discuss a low pass filter. With any type of filter this is all about the cut off **edge** or **edges**, what applies to one “edge” applies to any other one.

What we are asking a low pass filter to do is in effect to have a unity gain up to the cut-off frequency and a zero gain above it. The slope of the curve from the unity gain towards the intended zero gain is called the **cut-off rate**. The ideal low pass filter requires an infinite cut-off rate. This is not physically possible so in any filter there is a finite cut-off rate. What this is saying is that any implementation cannot change the gain instantly, so in some sense the filter gain has to turn a ”corner” from being a flat unity gain to one that is falling “rapidly”. This corner is not “square” but is “rounded”. So, first, how do we define the effective “action point” of what we call the cut-off frequency?

The standard accepted definition of the cut-off frequency is that it is the frequency of a sine wave whose power has been reduced by half. Now the power in a sine wave is the amplitude squared and half power is of course 0.5*amplitude squared. Expressing this ratio in dB terms it is the frequency where the power is reduced by 10*log(0.5) dB. This corresponds to -3.0103dB and hence we have the terminology of the **3dB point** as defining the effective cut-off frequency.

How fast the filter reduces the power in the output above the cut-off is of course determined by the cut-off rate. Traditionally, this rate is expressed in terms of so many dBs per octave or in dBs per decade. A somewhat slow rate by modern standards is 24dB/octave. What that in effect means is that if we had a cut-off frequency of *f* then the power in a sinewave at a frequency of *2f* is a 24 dB reduction; in amplitude terms this means the sinewave amplitude is reduced to around 6% of its original level. The calculation is not exact as we are already 3dB down at *f* but also the characteristic does not immediately attain the target rate. Incidentally, an approximate conversion between dB/octave and dB/decade is that for all practical purposes 6dB/octave = 20 dB/decade.

The upshot is that any low pass filter allows frequencies above the cut-off frequency through but attenuated by in general an ever increasing amount as the frequencies are further above the cut-off frequency. In passing, note that some filter implementations have a finite ‘floor’ so they might go down say -120dB and no further. The benefit of that form of implementation is often a much higher cut-off rate and in digital terms a higher real time capability.

The gain characteristic of a 24 dB/octave Butterworth type lowpass filter is shown below. In this example the 3dB cut-off frequency was 400 Hz. This is a gain versus frequency plot and it is evident that there will be frequencies of over 400Hz being passed through. At first sight, on a linear amplitude plot (Figure 1) it looks like we have nothing of significance passing above something like 1kHz.

If the characteristic is shown on a dB scale, as in Figure 2, then we can clearly appreciate that frequencies much higher than 1Khz or so are passed through.

At 4kHz the attenuation is -80dB, in modern signal processing this level is still significant. Using a much higher cut-off rate of say 96dB/octave gives a characteristic as below. This looks of course just like the previous one until you look at the dB scale. Now attenuation is -100dB at 800Hz and at 4Khz it is around -320dB. A 100dB reduction is an amplitude factor of 0.00001 whilst -320dB is a factor of 10e-16 (0.0000000000000001).

Because of the finite cut-off rate it is advantageous to sample at a higher rate than the minimum necessary. But what is the minimum rate? It is all to do, of course, with the sample rate and what is called the **Nyquist frequency**. The Nyquist frequency is simply half the sample rate. The importance of this is that when digitising a signal any frequency component above the Nyquist frequency will be folded back into the frequency range zero to Nyquist. This is known as **aliasing**. What does that mean? Rather than go through the mathematics a simple example is more illustrative. If we had used a sample rate of 1kHz, so Nyquist is 500Hz, and we observe a frequency component at 300Hz then that could have been genuinely from something at 300Hz, or from 700Hz or from 1300Hz, and so on because the infinite analogue frequency range is folded back concertina style into the zero to Nyquist frequency range. Once this has happened there is no way of recovering the situation except in certain pathological circumstances such as there was only one frequency component in the whole infinite frequency range. Aliasing occurs just because we sampled the signal, sampling causes aliasing. So the only solution is to use **analogue antialiasing filters** as the first step before any digital sampling occurs.

In modern sampling systems like Prosig’s P8000 series things get a little more ‘interesting’ due to the cost, complexity and repeatability of high cut-off rate analogue filters. The solution is that such systems actually sample very much higher than one may think. This then allows use of simpler and more repeatable analogue filters as the anti-aliasing element. Having handled the anti-aliasing, then high performance digital filters and decimation can safely reduce the sample rate. . But these filters still need a ‘safety’ margin because of the finite cut-off rate. So, classically, the anti-alias cut-off frequency is set by default to 0.4 of the sampling frequency. So if you sample at say 10kHz the valid frequency range is up to 4kHz but the range shown will be to the Nyquist frequency of 5kHz.

Let’s walk through an example step by step.

Let us suppose we captured a signal sampled at 5000 samples per second per channel, also assume that the signal has frequency content from zero to more than the Nyquist frequency.

The acquired signal would have been anti-alias filtered when it was captured assuming of course that the acquisition system that captured it had sufficient anti-alias filtering such as within a Prosig system.

This anti-alias filter would have set the upper bandwidth limit of the acquired signal. In most acquisition systems the anti-alias filter will be set automatically to the 0.4 * sample rate frequency unless it is changed by the user. So the effective bandwidth is from 0Hz to (0.4 * Sample rate), that is in our example from 0Hz to 2000Hz.

So, in summary, the signal is sampled at 5000Hz, but the frequency content is only reliable up to 2000Hz.

Now, in Prosig’s DATS software, any standard frequency analysis will show results up to the Nyquist frequency, in our example up to 2500Hz. “Why?” I hear you ask? The reason is so that you can see there is nothing of significance in the guard band above the normal Nyquist frequency. This is less useful these days, but in former times with less able anti-alias filters it was very important. Now, it’s just important as part of ensuring quality; and of course when handling signals imported from other sources.

This does not mean that at 2000Hz the content just stops or ends, if means that at 2000Hz the signal will be attenuated by about 3dB. As a general guide one should never draw any conclusions on data above the 3dB point cut-off frequency.

The frequencies above this point will be attenuated still further, the rate that they are attenuated is the cut-off rate, the higher the cut-off rate the more attenuation is applied to frequency’s above the 3dB point.

If we had acquired a ‘white noise’ signal, which is a signal that has equal power at all frequencies, and then did an **Auto Spectral Density** or **ASD**, sometimes called a **Power Spectrum Density** or **PSD**, on the acquired data it would look something like the figure below. Essentially this shows the filter characteristic and we see it turning at 2000Hz. It does not mean there were no frequencies above 2000Hz, rather it means the anti-alias filters have done their best to remove them.

Then, in our example, if a further filter, which of course will be a digital implementation, was applied as say a low pass filter at 400Hz, then 400Hz would be the new 3dB point. The digital filter would have its own roll off rate based on the type of filter, the number of passes, the algorithm and the parameters used to drive the algorithm generally. In the figure below quite a ‘gentle’ cut-off rate was used to show how the filter was removing content and then came to the point where there was effectively no energy because of the anti-alias filter.

Actually the filter continues to remove content as is shown by overlaying the two ASD curves.

The sample rate and the frequency shown on the X-axis are related, the Fourier Transform will provide us with data to half the sample rate (the Nyquist frequency). So the X-axis will go to half the sample rate, regardless of the filters that have or have not been used.

So, in summary, the filter cut-off frequency is the 3dB point, this means at the filter frequency the content of the signal will have been attenuated by 3dB, which is the half power point.

If you want to visualise this very clearly then show the Auto Spectral Density as a linear plot rather than a dB plot. The ASD is a “power” type so in this example the half power point is at the 0.02 amplitude level as shown by the horizontal line.

#### Dr Colin Mercer

#### Latest posts by Dr Colin Mercer (see all)

- Is That Tone Significant? – The Prominence Ratio - September 18, 2013
- A Guide To Digital Filtering - June 4, 2013
- Wide Band Integrators – What Are They? - June 15, 2012

Compliments for your interesting and well explained articles Dr Mercer!

In this article there is a small oversight while talking about the antialiasing filters. It’s written that “classically, the anti-alias cut-off frequency is set by default to 0.4 of the Nyquist frequency”, but I guess you are referring to the sampling frequency instead.

I would like to ask if you could also write an article about decimation.

Thank you

Thank you Dr. Colin Mercer for the wonderful articles.

There’s a typo in the post. When it says “So, classically, the anti-alias cut-off frequency is set by default to 0.4 of the Nyquist frequency”, it should be “Sample frequency” instead.

Hello Andrew, thanks for the feedback. Well spotted!