Digital Signal Processing/Digital Filters
Digital Filters can be very complicated devices, but they must be able to map to the difference equations of the filter design. This means that since difference equations only have a limited number of operations available (addition and multiplication), digital filters only have limited operations that they need to handle as well. There are only a handful of basic components to a digital filter, although these few components can be arranged in complex ways to make complicated filters.
There are two types of filters in the digital realm: Infinite Impulse Response (IIR) filters, and Finite Impulse Response (FIR) filters. This page will attempt to discuss the differences between the two filter types, and the pros and cons of each.
We will start the discussion with FIR filters, which are conceptually the easiest to understand and the easiest to design. However, FIR filters suffer from low efficiency, and creating an FIR to meet a given spec requires more hardware than an equivalent IIR filter. However, an FIR filter with symmetric coefficients is guaranteed to have linear phase. This is important in some applications.
If we define the discrete time impulse function as
the response of an FIR filter to δ[n], denoted as h[n], will decay to zero after a finite number of samples. The transfer function of an FIR filter contains only zeros and either no poles or poles only at the origin.
Filtering a time-series in Octave/Sciplot
First create some points for a time series. In this case we'll create one second of random data sampled at 44 kHz.
sampling_t = 1/44000; t = 0:sampling_t:1; x = rand(size(t));
Have a look at the time series
Have a look at its spectrum (it is mostly uniform, what we would expect from noise)
Now we'll use a built-in function to create a third order Butterworth low-pass filter with cutoff frequency pi*0.1 radians
[b,a] = butter(3,0.1)
Now filter the time series.
y = filter(b,a,x);
Have a look at the first 100 points of the filtered data.
hold on plot(y(1:100)) plot(x(1:100)) hold off
Check its spectrogram
Now look at the magnitude of the FFT
IIR Filters (infinite impulse response filter)
IIR filters are harder to design than the FIR filters, but the benefits are extraordinary: IIR filters are an order of magnitude more efficient than an equivalent FIR filter. Even though FIR is easier to design, IIR will do the same work with fewer components, and fewer components translate directly to less money. IIR filters differ from FIR filters because they always contain feedback elements in the circuit, which can make the transfer functions more complicated to work with.
The transfer function of an IIR filter contains both poles and zeros. Its impulse response never decays to zero (though it may get so close to zero that the response cannot be represented with the number of bits available in the system).
High-pass and Low-pass
High-Pass and Low-Pass filters are the simplest forms of digital filters, and they are relatively easy to design to specifications. This page will discuss high-pass and low-pass transfer functions, and the implementations of each as FIR and IIR designs.
Band-pass Filters are like a combination of a high-pass and a low-pass filter. Only specific bands are allowed to pass through the filter. Frequencies that are too high or too low will be rejected by the filter.
Notch filters are the complement of Band-pass filters in that they only stop a certain narrow band of frequency information, and allow all other data to pass without problem.
The direct complement of a bandpass filter is called a bandstop filter. A notch filter is essentially a very narrow bandstop filter.
Comb Filters, as their name implies, look like a hair comb. They have many "teeth", which in essence are notches in the transfer function where information is removed. These notches are spaced evenly across the spectrum, so they are only useful for removing noise that appear at regular frequency intervals.
The All-pass filter is a filter that has a unity magnitude response for all frequencies. It does not affect the frequency response of a filter. The All-pass filter does affect the phase response of the system. For example, if an IIR filter is designed to meet a prescribed magnitude response often the phase response of the system will become non-linear. To correct for this non-linearity an All-pass filter is cascaded with the IIR filter so that the overall response(IIR+All-pass) has a constant group delay.
Canonic and Non-Canonic
Canonic filters are filters where the order of the transfer function matches the number of delay units in the filter. conversely, Noncanonic filters are when the filter has more delay units than the order of the transfer function. In general, IIR filters are noncanonic, and FIR filters are canonic. This is not always the case, however.
Here is an example of a non-canonical 2nd order filter: File:NonCanonical DSP Filter.JPG
Notice that in the canonical filter, the system order (2) equals the number of delay units in the filter (2). In the non-canonical version, the system order is not equal to the number of delays (4 delay units). Both filters perform the same task, however the canonical version will be easier to implement in digital hardware, because you will need fewer delay units. However, this drawback nearly disappears if several second order IIR's are cascaded, as they can share delay elements. In this case, the only "extra" delay elements are those on the input side of the first section.
There are some basic notations that we will be using:
- ωp Pass-band cut off frequency
- ωs Stop-band cut off frequency
- δp Pass-band ripple peak magnitude
- δs Stop-band ripple peak magnitude