Signal Processing/Digital Filters

Digital Filters

edit

Digital filters are by essence sampled systems. The input and output signals are represented by samples with equal time distance.

FIR Filters

edit

Finite Impulse Response (FIR) filters are characterized by a time response depending only on a given number of the last samples of the input signal. In other terms: once the input signal has fallen to zero, the filter output will do the same after a given number of sampling periods.

The output   is given by a linear combination of the last input samples  .

 

The coefficients   give the weight for the combination. They also correspond to the coefficients of the numerator of the z-domain filter transfer function.

The following figure shows an FIR filter of order  :

 

For linear phase filters, the coefficient values are symmetric around the middle one and the delay line can be folded back around this middle point in order to reduce the number of multiplications.

The transfer function of FIR filters only pocesses a numerator. This corresponds to an all-zero filter.

FIR filters typically require high orders, in the magnitude of several hundreds. Thus the choice of this kind of filters will need a great amount of hardware or CPU. Despite of this, one reason to choose a FIR filter implementation is the ability to achieve a linear phase response, which can be a requirement in some cases. Nevertheless, the filter designer has the possibility to choose IIR filters with a good phase linearity in the passband, such as Bessel filters, or to design an allpass filter to correct the phase response of a standard IIR filter.

Average Filters

edit

As its name states, an average filter (or Simple Moving Average filter, SMA filter) calculates the average of the   last samples of a signal

 

It is the simplest form of an FIR filter, with all coefficients being equal.

The transfer function of an average filter is given by:

 

The transfer function of an average filter has   equally spaced zeroes along the frequency axis. However, the zero at DC is masked by the pole of the filter. Hence, there is a larger lobe a DC which accounts for the filter passband.

Weighted moving average

edit

Weighted moving average filters add a weight to the samples in order to give more importance to some of them

 

The weights may vary linearly or exponentially.

Recursive implementation

edit

The recursive implementation of a moving average filter bases on the fact that the output for 2 subsequent output samples is made out of the sum of the same set of input samples except for the first and the last one.

 

Cascaded Integrator-Comb (CIC) implementation

edit

A Cascaded integrator-comb filter (CIC) is a special technique for implementing average filters placed in series. The series placement of the average filters enhances the first lobe at DC compared to all other lobes.

A CIC filter implements the transfer function of   average filters, each calculating the average of   samples. Its transfer function is thus given by:

 

CIC filters are used for decimating the number of samples of a signal by a factor of   or, in others terms, to resample a signal at a lower frequency, throwing away   samples out of  . The factor   indicates how much of the first lobe is used by the signal. The number of average filter stages,  , indicates how well other frequency bands are damped, at the expense of a less flat transfer function around DC.

The CIC structure allows to implement the whole system with only adders and registers, not using any multipliers which are greedy in terms of hardware.

Downsampling by a factor of   allows to increase the signal resolution by   bits.

IIR Filters

edit

Canonical filters

edit

Canonical filters implement a filter transfer function with a number of delay elements equal to the filter order, one multiplier per numerator coefficient, one multiplier per denominator coefficient and a series of adders. Similarily to active filters canonical structures, this kind of circuits showed to be very sensitive to element values: a small change in a coefficients had a large effect on the transfer function.

Here too, the design of active filters has shifted from canonical filters to other structures such as chains of second order sections or leapfrog filters.

Chain of Second Order Sections

edit

A second order section, often referred as biquad, implements a second order transfer function. The transfer function of a filter can be split into a product of transfer functions each associated to a pair of poles and possibly a pair of zeroes. If the transfer function's order is odd, then a first order section has to be added to the chain. This section is associated to the real pole and to the real zero if there is one.

The most known filter biquad structures are

  • direct-form 1
  • direct-form 2
  • direct-form 1 transposed
  • direct-form 2 transposed

The direct-form 2 transposed of the following figure is especially interesting in terms of required hardware as well as signal and coefficient quantization.

 

Digital Leapfrog Filters

edit

Filter Structure

edit

Digital leapfrog filters base on the simulation of analog active leapfrog filters. The incentive for this choice is to inherit from the excellent passband sensitivity properties of the original ladder circuit.

The following 4th order all-pole lowpass leapfrog filter

 

can be implemented as a digital circuit by replacing the analog integrators with accumulators.

 

Replacing the analog integrators with accumulators corresponds to simplify the Z-transform to  , which are the two first terms of the Taylor series of  . This approximation is good enough for filters where the sampling frequency is much higher than the signal bandwidth.

Transfer Function

edit

The state space representation of the preceeding filter can be written as:

 


From this equation set, one can write the A, B, C, D matrices as:

 
 
 
 

From this representation, signal processing tools such as Octave or Matlab allow to plot the filter's frequency response or to examine its zeroes and poles.

In the digital leapfrog filter, the relative values of the coefficients set the shape of the transfer function (Butterworth, Chebyshev, …), whereas their amplitudes set the cutoff frequency. Dividing all coefficients by a factor of two shifts the cutoff frequency down by one octave (also a factor of two).

A special case is the Buterworth 3rd order filter which has time constants with relative values of 1, 1/2 and 1. Due to that, this filter can be implemented in hardware without any multiplier, but using shifts instead.

Autoregressive Filters (AR)

edit

Autoregressive (AR) models are process models in the form:

 

Where u(n) is the output of the model, x(n) is the input of the model, and u(n - m) are previous samples of the model output value. These filters are called "autoregressive" because output values are calculated based on regressions of the previous output values. AR processes can be represented by an all-pole filter.

ARMA Filters

edit

Autoregressive Moving-Average (ARMA) filters are combinations of AR and MA filters. The output of the filter is given as a linear combination of both the weighted input and weighted output samples:

 

ARMA processes can be considered as a digital IIR filter, with both poles and zeros.

Yule-Walker Equations

edit

AR filters are preferred in many instances because they can be analyzed using the Yule-Walker equations. MA and ARMA processes, on the other hand, can be analyzed by complicated nonlinear equations which are difficult to study and model.

If we have an AR process with tap-weight coefficients a (a vector of a(n), a(n - 1), ...) an input of x(n), and an output of y(n), we can use the yule-walker equations. We say that σx2 is the variance of the input signal. We treat the input data signal as a random signal, even if it is a deterministic signal, because we do not know what the value will be until we receive it. We can express the Yule-Walker equations as:


[Yule-Walker Equations]

 

Where R is the cross-correlation matrix of the process output

 

And r is the autocorrelation matrix of the process output:

 

Variance

edit

We can show that:

 

We can express the input signal variance as:

 

Or, expanding and substituting in for r(0), we can relate the output variance of the process to the input variance: