Tool
Design the active filter that turns a square wave into a clean sine. Pick the filter type, order and Q, then see the waveform, the harmonics that remain, the noise and what each op-amp stage has to handle.
A square wave is a sine at its own frequency plus a long series of harmonics. Filtering away the harmonics leaves the sine. This tool computes exactly which harmonics a given filter lets through, builds every stage as a real op-amp circuit, and checks the things that go wrong in practice: too much distortion, too much noise, clipping inside a high-Q stage, or an op-amp that is too slow.
A square wave switching between a low and a high level with duty cycle D contains a DC level plus harmonics at every multiple n of the frequency f0:
DC = V_low + (V_high − V_low) · D c_n = 2 (V_high − V_low) / (n π) · |sin(n π D)| · sinc(n π f0 t_edge)At 50 % duty only the odd harmonics exist, at 1/3, 1/5, 1/7 … of the fundamental. That 3rd harmonic at −9.5 dB is the one the filter has to work hardest on. At any other duty cycle the even harmonics appear too, starting with the 2nd, which is much harder to remove because it sits only an octave above the fundamental. A finite edge time (rise and fall time, modelled as a trapezoid) makes the high harmonics fall faster than 1/n. The total harmonic distortion of the output is
THD = √(c₂² + c₃² + c₄² + …) / c₁ (measured at the filter output, up to the 255th harmonic)The poles of the prototypes are calculated directly. Butterworth and Chebyshev use their closed-form pole positions, and Bessel uses the roots of the reverse Bessel polynomial, scaled so the −3 dB point lands on the cutoff. Each complex pole pair becomes one second-order stage with
f_stage = f_c · |p| Q = |p| / (2 · |Re p|) (a real pole becomes a first-order RC stage)The resistor level sets the impedance of every stage. Higher values make the capacitors smaller but add thermal noise. Each stage card shows the calculated part values.
Every part in the stage cards can be changed. Capacitors usually come in fewer values than resistors, so a common workflow is to pick capacitors you have and let the resistors follow. Two modes decide what happens:
Calculated resistor values are rarely standard values. Find combo next to each resistor opens the Resistor Combination Finder in a new tab with that value filled in, to build it from one to five standard resistors. To see what a single standard resistor does instead, switch to “Parts set the response” and type it in.
A high-Q stage has a gain peak near its own frequency. Placed first, it receives the full square wave and can overshoot or clip. Placed last, it receives an already smoothed signal. The common rule is therefore low Q first. The stage table shows the peak voltage and the steepest slope (slew rate) at every stage output, computed from the real waveform at that point, and compares them with the op-amp’s swing and slew rate.
An op-amp circuit only does exactly what its resistors and capacitors say while the op-amp’s own gain is far larger than the gain the circuit asks from it. That requested gain is the noise gain, 1/β, where β is the fraction of the output fed back to the inverting input. The op-amp’s open-loop gain falls with frequency as roughly GBW / f, so the margin that is left over, the loop gain, is:
loop gain ≈ (GBW / f) / noise gainThe signal itself may only be 20 kHz, but that isn’t the point. At 20 kHz a 10 MHz op-amp has an open-loop gain of 500. A follower (Sallen-Key, buffer) asks for a gain of 1, leaving a loop gain of 500. A multiple-feedback band-pass with Q = 3 asks for a noise gain of 2Q² + 1 = 19 at its centre, leaving only 26. The smaller the loop gain, the more the stage’s gain, frequency and Q shift away from the design. The error is roughly 1 / loop gain, so a loop gain of 26 gives about 4 % in the complex response, which mostly shows up as a phase shift of about 2°.
The well-known rule of thumb asks for a loop gain of at least 100 (40 dB) at the stage frequency, which keeps every error below about 1 %:
Sallen-Key, RC, notch: GBW ≥ 100 · f_stage · max(Q, 1) multiple feedback, gain: GBW ≥ 100 · f_stage · noise gainThat rule is conservative. Instead of only applying it, this tool simulates every stage with a real op-amp: a single-pole model with 100 dB of DC gain and the GBW you enter. A Sallen-Key stage uses its exact equation with a non-ideal follower (gain K = A/(1 + A)). The other stages use H_real = H_ideal / (1 + noise gain / A). All charts and numbers include this effect. The frequency response also shows the whole filter with ideal op-amps as a dashed line, and the op-amp tile and the stage table show how much the finite GBW changes the result. If the change is negligible, the op-amp is fast enough, even when the rule of thumb asks for more.
The noise calculation and the slew-rate check still assume ideal op-amp gain.
Every stage adds noise, and every following stage shapes it. Per stage, the tool solves the circuit’s node equations to find how each source reaches that stage’s output:
op-amp: e_n(f) = e_n · √(1 + f_corner / f) × the stage’s noise transfer resistors: √(4 k T R) × the transfer from that resistor to the output source: e_source × the whole filter’s responseEach stage’s noise is then multiplied by the response of all the stages after it, and the contributions are added as powers. The total is integrated from 1 Hz (or f0/1000) up to the op-amp’s gain-bandwidth, where the op-amp stops amplifying. Three things often surprise people:
The notch stage’s resistor noise is an approximation (2.5·R input-referred). The other stages are solved exactly for an ideal op-amp.
The drift tile shows how much the output amplitude, phase and THD change if the input frequency moves by the given percentage. Component tolerances have the same effect: a 1 % capacitor shifts a stage’s frequency by about 1 %. High-Q stages, band-pass filters and notches are the most sensitive.