Analog filters, part 2: let it ring
A continuation of the gentle intro to analog signal filtering. In today's episode: the Sallen-Key topology.
In an earlier article on analog signal filtering, we talked about basic RC filters. My thesis was simple: that despite the efforts of Wikipedia editors, the behavior of these devices can be understood and modeled without resorting to obtuse jargon or advanced math.
The main subject of that article was a rudimentary first-order RC lowpass filter, constructed the following way:
To readers with good intuition about capacitors, the qualitative analysis should be simple. At low frequencies, the cap has a high impedance, so sine waveforms pass through unhindered. At high frequencies, the capacitor behaves like a low-impedance shunt to the ground — and the amplitude of the waveform is greatly reduced.
To make this a bit less hand-wavy, we also derived the formula for a midpoint frequency where the resistance of the resistor matches the reactance of the capacitor:
We established that at this particular frequency, commonly referred to as “cutoff”, the output sine wave is attenuated to √½ (~70%) of the input amplitude. Last but not least, we plotted the filter’s behavior across a range of frequencies on a log scale:
Toward the end of the article, I noted two practical problems with this design: the attenuation slope is not particularly steep, and there is a pronounced, rolling transition between the passband and stopband region. This is a far cry from the “brick wall” response that some users might be aiming for.
Today, let’s have a look at how to solve these issues in real life.
Bending the slope
If we have a way to attenuate high frequencies while passing low-frequency signals largely unchanged, the most obvious way to beef it up is to use the filter twice:
If component values are chosen correctly, this layout has the effect of doubling the rate of attenuation; in other words, it reduces the amplitude by a factor of four every time we double the input frequency.
For optimal performance, all stages need to have the same corner frequency and the impedance of every subsequent stage must be markedly higher than that of the preceding one. This last constraint is usually not a big deal when chaining together two filters — but it can be difficult to construct higher-order devices.
An obvious solution is to add op-amps configured as voltage followers in between the stages. This isolates the filters from each other, and prevents excessive output loading:
The frequency response of chained RC lowpass filters is shown below:
In principle, the approach works, but one problem remains: no matter how many RC filters we stack, there’s still a pronounced bend in between the bandpass and bandstop portions of the curve. In all cases, the center frequency is the same — fc = 1/2πRC — but the attenuation at fc increases with the number of stages. Two stages reduce the amplitude to 50%; four stages push it down to 25%. Meanwhile, the customary “cutoff” point — corresponding to an amplitude of ~70% — keeps inching toward DC.
To fix this, we need more powerful sorcery.
Paging doctor Sallen-Key
Recall from the earlier article that standard analog filters behave correctly in the special case of a steady sine wave. For radio, this works because the carrier signals are near-perfect sines that are modulated at a comparatively glacial pace. For audio, the filters don’t actually do what we assume — but their effects sound natural because they mimic real-world acoustic phenomena.
And so, if you’re a filter designer concerned only with steady sine waves, there is a simple (if seemingly deranged) solution to the issue at hand: just make the circuit slightly resonant around fc. If we can get that waveform to constructively interfere with a reflected copy of itself, we get a localized spike in “loudness” — and turn that ugly curve into a nice, pointy knee. Sure, interesting things will happen if the input waveform doesn’t resemble a sinusoid — but most of the time, the trick works every time!
There are many ways to build resonant circuits, but a particularly clever and low-component approach is known as the Sallen-Key topology. The lowpass version can be derived from a familiar, passive second-order RC filter paired with an output-side voltage follower:
To turn this into the actual Sallen-Key topology, the first capacitor is disconnected from the ground, and hooked up to the output of the voltage follower:
The modification is not obvious, so let’s analyze it starting with the case of a low-frequency input signal. As we approach DC, both capacitors will exhibit high impedance, so the circuit’s output voltage will be predominantly influenced by the signal path through the two resistors. The op-amp doesn’t appreciably load its inputs, so the resistors do nothing, and Vout must be approximately the same as Vin:
Conversely, at high frequencies, C2 has a very low impedance compared to R2; in effect, any input signal should be more or less shunted to the ground, and the output should sit around zero volts:
So far, we seem to have a pretty standard lowpass filter. But next, let’s consider the midpoint frequency. Recall that this is the point where the complex impedances of resistors and capacitors will have the same magnitude. At a given frequency not far from fc, the equivalent circuit might be visualized roughly this way:
In effect, we have an attenuated, frequency-dependent positive feedback path between the op-amp’s output and its non-inverting input leg; critically, this feedback loop vanishes the moment we get sufficiently far away from fc, instead reverting to one of the two scenarios we discussed before.
This is pretty cool. The amount of feedback is controlled by the ratio of component values, and is usually expressed using the “Q factor” — a value representing the amplitude boost at fc. The filter’s frequency response for various Q factors is shown below:
At Q = ½, the curvature is identical to the optimally-designed non-resonant second-order RC filter. At Q = √½, we get a maximally flat response without any overshoot. At Q = 1, a tiny bit of ripple is present on the low-frequency side. Finally, at higher Q factors, the ripple becomes profound and is present on both sides of fc.
The formulas for calculating the filter’s response are derived analogously to what we did in an earlier article, although the process is a chore due to the sheer number of variables involved. If you’re willing to take my word for it, the familiar-looking formula for the center frequency is:
In the same vein, the following is the formula for the Q factor:
In practice, we don’t need this many degrees of freedom in circuit design. In particular, the filter can be built with two identical resistors (R) and two complementary capacitances centered around a common midpoint (Cref):
This greatly simplifies the math:
With these constraints in place, we can pick R and Cref to dial in a specific center frequency (and perhaps the desired input impedance or noise floor). Next, we simply pick n for the desired Q factor, and calculate the capacitances: C1 = Cref ⋅ n and C2 = Cref / n.
…but at what price?
Well, right. Resonant filters are a special can of worms. The distortion introduced by non-resonant RC filters can be problematic, but is also fairly localized and easy to model. For example, a non-resonant lowpass will just round the edges of a square wave:
Resonant filters, on the other hand, essentially turn into (damped) oscillators when presented with an input pulse. The following oscilloscope trace shows profound ringing in response to square wave spikes (at Q = 5):
Of course, analog filters can be designed to have more complex frequency responses, impulse responses, phase characteristics, and so on; digital filters don’t even need to operate in the sine-wave domain. But the design process always involves balancing some really messy trade-offs; a perfect, universal signal filter simply doesn’t exist.
For a thematic catalog of articles on this blog, click here.
I tend to reserve the term “distortion” to nonlinear effects. Everything you have described here is perfectly linear as long as you don’t approach clipping.
Yes. the impulse response may look gnarly in the time domain, but that’s mostly an inherent time/frequency effect. .
Great article. In this Sallen-Key filter, would it be possible to reduce the distorsion by putting a resistor just after the capacitor C1?