# Signals and Systems/Filter Design

The Laplace transform allows analyzing the frequency response of circuits based on the differential equations of their capacitive and inductive components. Filter design starts with finding the proper transfer function in order to amplify selected parts of a signal and to damp other ones as a function of their frequency.

Choosing the proper filter structure and deriving the coefficient values is a further topic prensented in the wikibook Signal Processing which deals with the application of signal and systems.

## Brick-wall filters[edit | edit source]

Separating signal from noise or different signals in the same transmission channel basing on their frequency content is best done with a brick-wall filter which shows full transmission in the passband and complete attenuation in the nearby stopbands, with abrupt transitions.

This can be done with the help of the Fourier transform which provides complete information of the frequency content of a given signal. Having calculated a Fourier transform, one can zero out unwanted frequency contents and calculate the inverse Fourier Transform, in order to provide the signal filtered with a brick-wall gauge.

The Fourier transform being given by:

one finds out that the Fourier transform integral, with its infinite bounds, would have to be calculated from the day of the creation of our universe and all the way up to the day of its decay before the integral could have been fully calculated. And only then can the ideal brick-wall filtered signal be delivered.

In more technical terms, the ideal brick-wall filter suffers from an infinite latency.

## Analog filters[edit | edit source]

The analysis of analog circuits shows that their outputs are related to their input by a set of differential equations. The Laplace transform rewrites these differential equations as a set of linear equations of the complex variable . With this, a polynomial function multiplying the Laplace transform of the input signal can be equated to another polynomial function multiplying the Laplace transform of the ouput signal:

Thus, the transfer function of a realizable analog filter can be written as the ratio of two polynomial functions of :

Hence, the problem of analog filter design is to find a pair of polynomial functions which, put together, best approximate the ideal but not realizable brick-wall transfer function.

In the early days of electric signal processing, scientists have come up with filter functions which are still largely used today. The functions they have devised are all of lowpass type. Frequency transformation techniques allow to find polynomials for other filter types such as highpass and bandpass.

## The Complex Plane[edit | edit source]

The transfer function of an analog filter is the ratio of two polynomial functions of :

The variable is a complex number which can be written as . The complex plane is a plane with the imaginary axis vertical and the horizontal axis as the real part.

The roots of the transfer function numerator polynom are called the transfer function *zeroes*.
The roots of the transfer function denominator polynom are called the transfer function *poles*.

The transfer function can be written as a function of its zeroes , its poles and an additional gain factor in the form:

The poles and the zeroes of a transfer function can be drawn in the complex plane. Their position provide information about the frequency response of the system. Indeed, the frequency response is equal to the transfer function taken for , which is along the imaginary axis.

### Effect of Poles[edit | edit source]

A stable LTI system has all its poles on the left side half plane of .

If a pole would be located on the imaginary axis, at , then the factor of the transfer function would be infinite at the point and so would the global frequency response . A special case of this is the integrator: it has a pole at , and indeed has a long-term infinite output for a constant, non-zero, input.

For poles close to the imaginary axis, the frequency response takes a large amplitude for frequencies close to them. In other words, poles close to the imaginary axis indicate the passband.

### Effect of Zeros[edit | edit source]

If a zero is located on the imaginary axis, at , then the factor of the transfer function is zero at the point and so is the global frequency response .

Zeroes on, or close to the imaginary axis indicate the stopband.

## Designing Filters[edit | edit source]

Devising the proper transfer function for a given filter function goes through the following steps:

- selecting a normalized filter function
- transforming and scaling the function for the particular needs

The coefficients of the numerator and denominator coefficients are finally used to calculate the element values of a selected filter circuit.

### Example: Lowpass Filter[edit | edit source]

A reduced version of CCITT G712 input filter specification, giving only the lowpass part, is shown in the plot on the side.

The passband goes up to and allows a maximal ripple of . The stopband requires an attenuation of at and an attenuation of above .

#### Filter Function[edit | edit source]

As a first step, we have to choose a filter function.

Programs such as Octave or Matlab provide functions which allow to determine the minimal filter order required to fulfill a given specification. This is a good help when choosing from the possible functions.

Let's however here arbitrarily choose a Butterworth transfer function.

#### Normalized Filter Function[edit | edit source]

The following Octave script allows to plot the amplitudes of normalized Butterworth transfer functions from order 8 to 16.

#------------------------------------------------------------------------------- # Specifications # fs = 40E3; fPass = 3000; rPass = 0.125; fStop1 = 4000; rStop1 = 14; fStop2 = 4600; rStop2 = 32; pointNb = 1000; AdbMin = 40; makeGraphics = 1; figureIndex = 0; #=============================================================================== # Normalized filter function # wLog = 2*pi*logspace(-1, 1, pointNb); fc = 0.87; Adb = []; for order = 8:16 [num, den] = butter(order, 2*pi, 's'); while ( length(num) < length(den) ) num = [0, num]; endwhile; Adb = [Adb; 20*log10(abs(freqs(num, den, wLog)))]; endfor Adb(Adb < -AdbMin) = -AdbMin; figureIndex = figureIndex+1; figure(figureIndex); semilogx(wLog/(2*pi), Adb); hold on; semilogx([wLog(1)/(2*pi), fc, fc], -[rPass, rPass, AdbMin], 'r'); semilogx([fStop1*fc/fPass, fStop1*fc/fPass, fStop2*fc/fPass, fStop2*fc/fPass, wLog(length(wLog))/(2*pi)], ... -[0 , rStop1, rStop1, rStop2, rStop2 ], 'r'); hold off; axis([wLog(1)/(2*pi), wLog(length(wLog))/(2*pi), -AdbMin, 0]); grid; xlabel('frequency [Hz]'); ylabel('amplitude [dB]'); if (makeGraphics != 0) print -dsvg g712_butterworth_normalized.svg endif

The following figure shows the result: one needs at least a 13th order Butterworth filter to meet the specifications.

On the graph, one can note that all the amplitude responses go through the same point at -3 dB.

The specification frequencies have been scaled down to fit to the normalized cutoff frequency of 1 Hz.
In the script, one might have noted an additional scaling factor of `fc = 0.87`

: this is due to the fact that the corner cutoff amplitude is -0.125 dB and not -3 dB.
That value has been adjusted by hand for this example.
Again, Octave or Matlab scripts automate this task.

#### Denormalized Filter Function[edit | edit source]

The frequency scaling of the normalized transfer function is done by replacing

The following Octave script does this by multiplying the numerator and denominator coefficients by the appropriate power of .

#------------------------------------------------------------------------------- # Denormalized filter function # order = 13; wLog = 2*pi*logspace(2, 5, pointNb); fc = 0.87; [num, den] = butter(order, 2*pi, 's'); while ( length(num) < length(den) ) num = [0, num]; endwhile; for index = 1:order+1 num(index) = num(index) * (fPass/fc)^(index-1); den(index) = den(index) * (fPass/fc)^(index-1); endfor Adb = 20*log10(abs(freqs(num, den, wLog))); Adb(Adb < -AdbMin) = -AdbMin; figureIndex = figureIndex+1; figure(figureIndex); semilogx(wLog/(2*pi), Adb); hold on; semilogx([wLog(1)/(2*pi), fPass, fPass], -[rPass, rPass, AdbMin], 'r'); semilogx([fStop1, fStop1, fStop2, fStop2, wLog(length(wLog))/(2*pi)], ... -[0 , rStop1, rStop1, rStop2, rStop2 ], 'r'); hold off; axis([wLog(1)/(2*pi), wLog(length(wLog))/(2*pi), -AdbMin, 0]); grid; xlabel('frequency [Hz]'); ylabel('amplitude [dB]'); if (makeGraphics != 0) print -dsvg g712_butterworth.svg endif

The coefficients of the numerator and denominator coefficients are now ready to be used to calculate the element values of a selected filter circuit.