DSP - Digital signal processing

Analog and digital filters

In signal processing, the function of a filter is to remove unwanted parts of the signal, such as random noise, or to extract useful parts of the signal, such as the components lying within a certain frequency range.
The following block diagram illustrates the basic idea.


raw (unfiltered) signal -> FILTER -> filtered signal

There are two main kinds of filter, analog and digital. They are quite different in their physical makeup and in how they work.

An analog filter uses analog electronic circuits made up from components such as resistors, capacitors and op amps to produce the required filtering effect. Such filter circuits are widely used in such applications as noise reduction, video signal enhancement, graphic equalisers in hi-fi systems, and many other areas.
There are well-established standard techniques for designing an analog filter circuit for a given requirement. At all stages, the signal being filtered is an electrical voltage or current which is the direct analogue of the physical quantity (e.g. a sound or video signal or transducer output) involved.
A digital filter uses a digital processor to perform numerical calculations on sampled values of the signal. The processor may be a general-purpose computer such as a PC, or a specialised DSP (Digital Signal Processor) chip.
The analog input signal must first be sampled and digitised using an ADC (analog to digital converter). The resulting binary numbers, representing successive sampled values of the input signal, are transferred to the processor, which carries out numerical calculations on them. These calculations typically involve multiplying the input values by constants and adding the products together. If necessary, the results of these calculations, which now represent sampled values of the filtered signal, are output through a DAC (digital to analog converter) to convert the signal back to analog form.
Note that in a digital filter, the signal is represented by a sequence of numbers, rather than a voltage or current.
The following diagram shows the basic setup of such a system.


Advantages of digital filters

The following list gives some of the main advantages of digital over analog filters.
  1. A digital filter is programmable, i.e. its operation is determined by a program stored in the processor's memory. This means the digital filter can easily be changed without affecting the circuitry (hardware). An analog filter can only be changed by redesigning the filter circuit.
  2. Digital filters are easily designed, tested and implemented on a general-purpose computer or workstation.
  3. The characteristics of analog filter circuits (particularly those containing active components) are subject to drift and are dependent on temperature. Digital filters do not suffer from these problems, and so are extremelystable with respect both to time and temperature.
  4. Unlike their analog counterparts, digital filters can handle low frequency signals accurately. As the speed of DSP technology continues to increase, digital filters are being applied to high frequency signals in the RF (radio frequency) domain, which in the past was the exclusive preserve of analog technology.
  5. Digital filters are very much more versatile in their ability to process signals in a variety of ways; this includes the ability of some types of digital filter to adapt to changes in the characteristics of the signal.



Fast DSP processors can handle complex combinations of filters in parallel or cascade (series), making the hardware requirements relatively simple and compact in comparison with the equivalent analog circuitry.



Operation of digital filters

In the next few sections, we will develop the basic theory of the operation of digital filters. This is essential to an understanding of how digital filters are designed and used. First of all, we need to introduce a basic notation.
Suppose the "raw" signal which is to be digitally filtered is in the form of a voltage waveform described by the function
V = x (t)
where t is time.
This signal is sampled at time intervals h (the sampling interval). The sampled value at time t = ih is
xi = x (ih)
Thus the digital values transferred from the ADC to the processor can be represented by the sequence
x0, x1, x2, x3, ...
corresponding to the values of the signal waveform at times t = 0, h, 2h, 3h, ... (where t = 0 is the instant at which sampling begins).
At time t = nh (where n is some positive integer), the values available to the processor, stored in memory, are
x0, x1, x2, x3, ... , xn
Note that the sampled values xn+1, xn+2 etc. are not available as they haven't happened yet!
The digital output from the processor to the DAC consists of the sequence of values
y0, y1, y2, y3, ... , yn
In general, the value of yn is calculated from the values x0, x1, x2, x3, ... , xn. The way in which the y's are calculated from the x's determines the filtering action of the digital filter.
In the next section, we will look at some examples of simple digital filters.

Order of a digital filter

The order of a digital filter can be defined as the number of previous inputs (stored in the processor's memory) used to calculate the current output.
This is illustrated by the filters given as examples in the previous section.

Example (1): yn = xn
This is a zero order filter, since the current output yn depends only on the current input xn and not on any previous inputs.


Example (2): yn = Kxn
The order of this filter is again zero, since no previous outputs are required to give the current output value.


Example (3): yn = xn-1
This is a first order filter, as one previous input (xn-1) is required to calculate yn. (Note that this filter is classed as first-order because it uses one previous input, even though the current input is not used).


Example (4): yn = xn - xn-1
This is again a first order filter, since one previous input value is required to give the current output.


Example (5): yn = (xn + xn-1) / 2
The order of this filter is again equal to 1 since it uses just one previous input value.


Example (6): yn = (xn + xn-1 + xn-2) / 3
To compute the current output yn, two previous inputs (xn-1 and xn-2) are needed; this is therefore a second-order filter.


Example (7): yn = (xn - xn-2) / 2
The filter order is again 2, since the processor must store two previous inputs in order to compute the current output. This is unaffected by the absence of an explicit xn-1 term in the filter expression.

The order of a digital filter may be any positive integer. A zero-order filter (such as those in examples (1) and (2) above) is possible, but somewhat trivial, since it does not really filter the input signal in the accepted sense.


Digital filter coefficients

All of the digital filter examples given in the previous section can be written in the following general forms:

Zero order:yn = a0xn
First order:yn = a0xn + a1xn-1
Second order:yn = a0xn + a1xn-1 + a2xn-2
Similar expressions can be developed for filters of any order.


The constants a0, a1, a2, ... appearing in these expressions are called the filter coefficients. The values of these coefficients determine the characteristics of a particular filter.The table opposite gives the values of the coefficients of each of the filters given as examples in the previous section.
ExampleOrdera0a1a2
101--
20K--
3101-
411-1-
511/21/2-
621/31/31/3
721/20-1/2