# Intro to Filtering

To play off the last post, the second most common block in circuits is the filter. While amplifiers help us increase our signal and make them bigger to do more with them, they tend to have some nasty effects on the signal quality. In order to improve this, we want to get rid of the undesired parts of our new signal by filtering out items such as harmonics, noise, or DC bias. This process is called “filtering”.

Filtering has two main components: an amplitude change, and a phase change. In the time domain, this means we change how far up our signal goes up and down, as well as moving it left or right (but realistically, only to the right, since we can’t go faster than time). So let’s say we have some arbitrary input signal:

$$V_{in} = A\sin(wt)$$

After our filter, we’ll get something like this:

$$V_{out} = AB_{filt} \sin(wt-\phi)$$

The sign of $\phi$ doesn’t really matter, due to the nature of a periodic function wrapping around. We just need to remember that we always delay our signals, as we can’t go faster than our input ever.

We talked about RL and RC filters and their responses in the past, but let’s see what they do to a real signal now. The best way to treat filters is do so linearly. Break up each individual signal, see what the filter does to it at that frequency, then put the pieces back together. As we learned previously, we can make a square wave from a bunch of sine waves. These filters will help us change different sine waves from our signal, and therefore the sum of them will be different. Let’s start with a simple example input (TRI(x,f) means we have a triangle wave with amplitude x, frequency f):

$$V_{in} = 2.5 + \text{TRI}(2.5, 100)$$

Now if we put it through a high and low pass filter, let’s see how our outputs differ.

* Simple RC Filter (3dB = 200Hz) with Triangle input
r1 n1 n0 20k
c1 n1 0 1uF
Vin n0 0 0 pulse(0 5 0 5m 5m .1m 10m)

.tran 100u 100m
.print tran v(n0) v(n1)
.end



And the corresponding highpass filter:

* Simple RL Filter (3dB = 200Hz) with Triangle input
r1 n1 n0 100
l1 n1 0 10mH
Vin n0 0 0 pulse(0 5 0 5m 5m .1m 10m)

.tran 100u 100m
.print tran v(n0) v(n1)
.end



Now let’s see our outputs. In the lowpass case (cutoff 200Hz), we got a sine wave-ish back! All those faster sine waves that made the corners sharp and pointy have their amplitude reduced plenty. This only leaves us with the fundamental sine wave, the big one that sets the main frequency. We also see that the amplitude got a lot smaller, and the wave got shifted over by about half a period. Right there we see our amplitude and phase change for the fundamental.

Now in the highpass case (cutoff 200Hz as well), we got something even crazier. The wave shifted down, because we filtered our DC signal. Then, this filter actually acted as an integrator! We took a linear input, and integrated it to get a constant output - obviously scaled by some magnitude value. Again, there was serious attenuation to reduce the amplitude, as well as another phase shift to the right.