Theo Verelst Filter Page

Last Update: april 5, 2005


Introduction

Filters in electronics and electrical engineering are usually circuits with allow certain frequencies in a circuit to be emphasized or others suppressed.

In general, linear filters in Network Theory are circuits with at least on input and one output with overall stable behaviour, influenced by at least one significant frequency dependent element a: a reactance, usually a capacitor or a coil, which in the continuous realm are the only such elements except for delay lines or transmission lines.

In the digital domain much confusion seems to exist about what a filter is exactly, and what can be said about such circuits, though in EE the fine discipline of Network Theory and Circuits and Systems, and certainly Electronics can be consulted to answer a lot of important questions, but it is essential in the case of sampled, Time Discrete systems that we get our theoretics right before assuming all kinds of wild things about Digital Filters.

In the strong and theoretical discipline of Network Theory (wherein the author holds a Master of Science Degree from Delft University), we can for continuous circuits, that is 'real' electronics circuits with actual parts, compute the behaviour of any filter with infinite accuracy, given we know the part characteristics, even following computerizable computation steps. This is, as EEs will know, a major part of the first and second year foundation laid in the study for any such engineer, and of profound theoretical value, and a fairly attractive theory, at least I found it pleasing enough.

Basically, by filling all the circuit elements in a complex matrix according to given rules (which can be proven mathematically) and inverting this matrix some way (for isntance gaussian elimination with row exchange) we can find all the complex voltages and currents in any physically realizable network (with no bad short circuits) and from this compute the transfer function and the frequency (or time) behaviour of the network or filter. For any network, no matter how big or complex. On this page I'll see if I can pay some attention to this, and automated ways to do this and also to compute the transfer function symbolically, which can be advantageous, and is interesting, and maybe I'll make a bwise/maxima combination program to do this automatically.

To begin with , my first motivation is to be able to say theoretically founded things about audio filters, which then can be realized also in the digital (sampled) domain, with certain precautions taken, and which will lead to good and decent filters for Digital Signal Processing application in a  sound synthesizer which I have made, and which already works.



Because of the popularity of the subject, starting already years ago when I was in highschool and programmed such things on a TRS80 computer (...) it is important to understand a lot of appoximations and theoretical errors which are made in the field of digital signal processing and filtering therein, so we start with a section about the most inportant theoretical considerations in the digital/sampled domain of signal processing, even though it might seem more natural to start with an introduction to analog circuits and filtering an computation in that field.


Digital Signals and their theory

It can hardly be overstated or overstressed: digital signals and their processing is not as almighty as some computer oriented people may want to think, there are stringent, binding, and essential theoretically founded rules which must be obeyed to take part in this branch of sport to be ultimately succesfuill and to be theoretically sound. Note that the essence of analog signal processing and computations is well founded already for about a century at least, from the time of the early radios and the advent of quantum physics (both areas I'm certainly not new to), and that the relative newcomer digital signal processing since the foundation time of computers of the modern kind (lets say after Turing and Neumann) has received a lot of attention and in electrical engineering has a solid basis (to begin with) in the first or second year course of Information Theory.

Lets phrase the most important 'laws' from that field.

First, a continuous signal can be sampled at a certain rate, the 'sampling rate' preferably fixed (without getting into even more advanced problems) by 'sampling' the voltage or magnitude of the analog signal at a precise moment in time, the sample moment, and then stored in some memory for later use.

Second, in most, though certainly not all, cases, that signal is not just sampled, or made discrete, in time sense, but also in amplitude sense, which is called quantization of the signal amplitude, which usually takes place in the Analog to Digital converter unit. So we have a continuous signal which goes into this unit, and at the output we have a time and amplitude discrete signal, in the form of a string of zeros and ones, like in computer words, which (hopefully) represent the same signal.

Now there appear two problems: the amplitude quantisation cannot be undone, and the chopping of the signal into samples can possibly not be undone. Once the voltage of a sample has been measured and stored in a computer with some accuracy, lets say 16 bits, it is impossible to know from a sample more accurately than a 2^-16 th  part what the original signal voltage was, and that is unrecoverable, so hopefully that error is small or unnoticable in practice (which it rarely is).

The sampling accuracy is another matter. Shannon theory says that when the original analog, unsamped (and unquantized) signal contains no frequency components (according to Fourier analysis) higher than half the sampling frequency, and the sampling is perfect, without quantisation errors, the original analog (!) sugnal can be regenerated from the samples by a perfect reconstruction filter, in error free form, as in mathematically correct. That would of course require the use of infinite accuracy samples, but still, that is a powerfull thesis to start from.

The problem is how we can make sure that we comply with this frequency range condition, called the Nyquist rate sampling frequency, because most natural, analog signals will have all kinds of frequencies in them. Some signals may have a gairly certain upper frequency in its frequency analysis picture, so we can take the sampling rate a bit higher than twice this highest frequency. Most signals will not by nature be hard-bounded to a certain frequency range, so would possibly have to be filtered to cut off all frequencies higher than the Nyquist required upper frequency.

This filtering takes us immedeately to one of the big issues of the field: assuring the Shannon Sampling theorem is not not violated, filtering a signal to contain no frequencies above half the sampling frequency is NEVER perfectly possible in practice, except for very special cases, and then usually only theoretically.

So if we start with a signal which is not frequency limited to half the sampling rate, we always have a problem digitising and sampling it, per definition. There are solutions which for certain practical cases and for a certain required accuracy may work, and even work well, but the whole idea of perfect filtering is not quite possible. At the very least all filters of practical kind will have phase distortion problems, and also no filter perferctly filters all frequencies above a certain frequency, there is at best talk of a certain diminishing of higher frequencies, which hopefully is sufficient for the purpose. For instance when higher frequencie components start to become smaller in the signal amplitude then the quanitsation error, it might be considered sufficient filtering.

The next source of error is when we go from the discrete or computer signal back to the analog domain, for instance the DA converter of a sound card.and is called the signal reconstruction problem. The reconstruction filter is that wonderfull idea of taking the samples of the time discrete signal., and putting them back into the analog domain, which in theory can be done without error at all, assuming correct sampling has taken place. In practice the length and especially the complexity of the reconstruction filter is pretty amazing, to get close to perfection. CD players  and all other digital audio equipment will not get close to doing this reconstruciton perfectly, really, believe me. It depens on what you call perfect enough, but the higher frequencies require a lot of work to get reconstructed well, on the basis of what is called the sinc function for each sample.

See for instance Sampled Signal Reconstruction in Tcl driven Maxima .


The basic 1st order electronic filter analyzed

r:1000;
c:1/1000000;
h(w):=(1/(%i*w*c))/(r+1/(%i*w*c));
plot2d([abs(h(2*%pi*w)),carg(h(2*%pi*w))],[w,0,10000]);
float(abs(h(2*%pi/(2*%pi*r*c))));