Such a signal is in figure 1a, a signal with some high frequency component. Its spectrum would then resemble what is in figure 1b; for sake of simplicity, and for focusing on the topic of interest, the spectrum is designed with sharp edges, which is of course not the real case.
The result of sampling the signal in figure 1a and 1b is shown in figure 2. It is obtained repeating the original spectrum around fs, 2fs, 3fs, and so on. As an effect of this, some contribution in the spectrum is “folded back” into the frequency range of the original spectrum: the signal is hopelessly distorted. This effect is called aliasing.
Fig. 1a – Signal in the time domain having high frequency components
Fig. 1b – Signal spectrum of waveform in figure 1a, showing the high frequency content of the signal
There are two possible solutions to this behavior, and they can, of course, be used together. The first one is to increase the sampling frequency fs in order to prevent spectra to overlap. This is often the first thing that people do, but we have to remember that increasing fs has as a consequence increased requirements on the whole system (more computations/higher speed computations).
The second possible solution is to use a low pass filter that removes the high frequency content from the signal spectrum; this filter is called anti-alias filter. You can see how the anti-alias filter work referring to figure 2, but this time using a low pass filter to limit the signal bandwidth to fs/2 maximum. See figure 3a. As a result of the low-pass, anti-alias filter the periodic repetition of the spectra due to sampling will not give place to any distortion. In fact, no spectra in the sampled signal have overlapping tails (Fig. 3b).
Fig. 2 – Spectrum of the signal in figure 1a with high frequency content, sampled at a rate fs
Fig. 3a – Spectrum of the signal of interest and suggested low-pass filter (brick-wall filter)
Fig. 3b – Periodic repetition of the spectra, caused by sampling. The use of a low-pass filter like the one designed above allows to avoid distortion
An example that can help understanding the alias phenomenon is that of a high frequency sinusoidal wave, which is sampled at a far too low sampling rate. In figure 4a a high frequency sinusoid in blue is plotted. As a result of the too low sampling frequency we take into consideration (as an example) the points (red dots) shown on the figure itself. The result is that the system will perceive the signal as a sinusoid of much lower frequency. It is instructive to look at this example in the frequency domain also. The Fourier transform of a sinusoidal waveform is as shown in figure 4b: two “spikes” at the fundamental frequency f0 and –f0 (the negative frequency axis is a useful “mathematical trick”). This said, if now the sinusoid is sampled at a frequency which is lower than 2*f0, the spectrum of figure 4c results, where the highlighted “spike” is not part of the original spectrum but it is located at low frequencies, within the range 0 to fs/2 which is where we normally expect to have the basic spectrum of interest of the signal.
Fig. 4a – Aliasing: the red sinewave is created by the erroneous (too slow) operation of sampling. A new low frequency wave (red) is detected
Fig. 4b – Fourier transform (spectrum) of a sinewave
Fig. 4c – Effects of low frequency sampling on the spectrum in figure 4b
Here is another example of the consequences of “erroneous” sampling of the ADC. We have it in front of us every day when we are watching a movie in TV: car wheels. When the car starts moving, its wheels will seem to be rotating first clockwise, then counterclockwise, then clockwise again and so on. This is exactly what we have described above: the wheel rotation is the sinusoidal signal. The TV set itself performs a sampling operation. The wheel-sinusoid will start from the origin and move to the right along the frequency axis, while the car is accelerating. At some point around fs/2 the component of the first repetition of the spectrum will come into the low frequency range (which is what our eye can detect and see). Since this portion of the spectrum corresponds to the “negative frequency axis” the wheel seems to start spinning counterclockwise. And so on. Refer to figure 5.
Fig. 5 – Effects of sampling on wheels rotating at increasing speed
The use of the anti-alias low pass filter should be clear from the discussion above. In order to avoid the distortion of the signal of interest caused by high frequency spectral components that are folded back in the low frequency range by the sampling operation, the filter is designed to have a flat transfer function in the range of frequencies where the spectrum of the signal of interest is located (let’s say from 0 Hz to fm Hz) and to reach the maximum attenuation at fs/2. This will guarantee that all high frequency components (that could be folded back) are highly attenuated.
How to design the low pass filter
The previous section has presented the reasons for using a low-pass filter as the very first block in the digital processing system. The question is then: how should it be designed?
The design of an analog filter is a quite well known topic: there is a huge amount of literature that can help. The implementation details won’t be examined; the design specs only will be derived.
Before that, it is probably wise to remember that there are a number of different filter topologies, each with its own characteristics and advantages. The most common ones are:
1. Maximally flat (or Butterworth): the transfer function in the pass-band interval is the flattest possible
2. Bessel: the phase is linear; this is a must in many applications, unfortunately it is accompanied by an amplitude transfer function that transitions very slowly from pass-band to stop-band
3. Chebyshev (type 1): some ripple in the pass-band is allowed in order to get a small transition band
4. Chebyshev (type 2): some ripple in the stop-band is allowed in order to get a small transition band
5. Elliptic: some ripple is allowed both in the pass-band and in the stop-band; the great advantage is that the transition band is very sharp.
Reverting to the design specs, the generalized filter transfer function in figure 6a will be considered. In order to avoid the distortion caused by aliasing, the point fa should correspond to fs/2. The cut-off frequency fc should be close to fm, that is the maximum frequency of the spectrum of interest. This is shown in figure 6b.
Fig. 6a – Generic low-pass filter transfer function
Fig. 6b – Generic low-pass filter and spectrum of interest
The values selected here are just an example. Different values can be used in a real application; for instance a relaxation of fc
is very likely. Of course the pass-band could be smaller and the fa point could appear earlier (at a lower frequency). However the steeper the transition band, the larger the order of the filter.
The other key parameter to define the filter is the required attenuation. A result, which is derived in Appendix 1, defines the signal to noise ratio of an ADC having N-bit resolution.
[eq. 1]
This means that should we have a 10 bit resolution ADC, the signal to noise ratio would be:
[eq. 2]
While with a 12 bit ADC, we would have:
[eq. 3]
The design target is then to select an attenuation value of the anti-alias filter that is close to the SNR of the ADC. The contribution to noise from the ADC should be comparable with the noise floor at the filter output. There is in fact no reason to have, say, 100 dB attenuation when using a 12 bit ADC, whose SNR is, as we have seen, 72 dB. Remember that a greater attenuation means a higher order filter, that is more components, more complexity and, at the very end, higher costs.
Anti-alias filters are analog filters. Traditional techniques of analog filters design can be used; there is a huge amount of books and software tools available to study and implement such filters. Analog filters can be:
1. Passive
2. Active
Passive filters are designed using only passive components (resistors, capacitors, inductances) and they are normally used when frequencies of interests (the cut-off frequency for example) are in the order of a few hundreds of thousands of Hertz and above.
Active filters use the very versatile operational amplifiers, plus resistors and capacitors to implement filters in the lower end of the frequency axis. The vast majority of anti-alias filters are active filters. The reason for this choice stems from the fact that the maximum bandwidth of many signals that can be processed by digital systems is usually in this range. On the other side, passive filters designed to operate at (very) low frequency require the use of inductances and capacitance of high value, which means big, heavy and expensive components (plus a number of non-negligible electrical effects).
There are many different techniques that can be used to design and implement active filters; and many different topologies may be used. A very common one is the Sallen-Key topology, which allows designing first and second order blocks that can be cascaded to realize analog filter of any order. See figures 7a and 7b. (See Appendix 3)
Fig 7a – First order Sallen – Key filter
Fig 7b – Second order Sallen – Key filter
Here below the main steps in the design of the anti-alias filter:
1. Select the filter family. A good starting point is to use the Butterworth approximation, because of its simplicity
2. Define the cut-off frequency, based on the maximum signal frequency (Figg. 6a and 6b)
3. Determine the required attenuation, considering the number of bits of the Analog to Digital Converter block that follows in the chain
4. Determine, from the result of the two preceding steps, the filter order. In the case of a Butterworth filter, this can be easily done using the spreadsheet ButterworthFilter. For other filter families, there is a number of excellent books that can help.
5. Check the order is reasonable. It is impossible to say, in general terms, what “reasonable” is, because this depends on the signal at hand and on the available budget; however, any order higher than 8 is likely to be too much).
6. Select the circuit topology to implement the filter in hardware. A possible solution is presented in the Spreadsheet ButterworthFilter.xls and in Appendix 3. Of course, textbooks on filters present a much wider selection of circuits to choose from.
= = = =
Butterworth (see pdf in attachment)
This spreadsheet computes the transfer function of the Butterworth approximation of a low pass filter. It also plots the corresponding function in the frequency domain. The vertical axis labels are fixed (but can be changed by user).
The requested input values are:
1. Cutoff frequency [KHz]: this is the frequency at which the transfer function is reduced by 3 dB. It represents the pass-band of the filter (frequency fc).
2. Order: order of the filter
3. Plot min freq [KHz]: this is the minimum value of the frequency axis used in the plot operation
4. Plot max freq [KHz]: this is the maximum value of the frequency axis used in the plot operation
These values are green bold because the user can change them.
Below is the computed table with three columns:
1. Frequency f
2. Module of the transfer function
3. Logarithm (base 10) of the module of the transfer function
The plot of the transfer function is also available.
Pdf file: Butterworth
= = = =
Appendix 3
Sallen – Key Filters
Many different techniques may be used to design an active analog filter. In general the equation that approximates the transfer function of a low pass filter is of the form:
eq. A3.1
where Pn(s) is a polynomial in s with zeroes in the left-hand plane.
In the following, the Butterworth implementation Pn(s) = Bn(s) of eq. A3-1 will be developed. In this case:
eq. A3.2
The Excel spreadsheet Butterworth allows plotting this filter transfer function.
Table A3.1 lists the Butterworth polynomials in s up to n = 8.
Table A3.1
It is easy to see that there are two kinds of terms in the polynomials above: first and second order terms.
The first order term can be expressed as:
eq. A3.3
The second term can be expressed as:
eq. A3.4
where:
eq. A3.5
is the 3 dB frequency and k is called the damping factor and equals one-half the coefficient of s in each quadratic factor in Table A3.1.
Consider now the two circuits that, using an operational amplifier, implement the transfer function above (Figg. 7a and 7b)
Starting from the second order circuit, it can be shown that its transfer function is:
eq. A3.6
Equating term by term the coefficients at the denominators in eq. A3.4 and A3.6, the result is:
eq. A3.7a
eq. A3.7b
Considering the first term circuit, provided that eq. A3.7a is satisfied, the gain (AV0) may be chosen arbitrarily.