Kyros Engineering Engineering Tools
Home › Tools › IIR Biquad Designer
// DSP tools Proto v0.1BiquadsCMSIS-DSPQ15 / Q31

IIR Biquad Designer

Design a Butterworth, Chebyshev or elliptic IIR filter as a cascade of second-order sections, see what it does in float32, Q31 and Q15, and copy CMSIS-DSP code that drops into firmware.

Runs entirely in your browser. Nothing is uploaded.

1 · Filter

Hz

2 · Order and edges

Hz
Hz

2 · Spec (minimum order)

Hz
Hz
Hz
Hz

3 · Ripple and attenuation

dB
dB

4 · Implementation

samples

Result

Order
—
Max pole radius
—
−3 dB point(s)
—
Group delay
—
——

Frequency response

Poles, zeros and sections

#b0, b1, b2a1, a2|p|f₀Q

Rows use the textbook sign, H(z) = (b0 + b1 z⁻¹ + b2 z⁻²) / (1 + a1 z⁻¹ + a2 z⁻²). Sections run top to bottom; scipy puts the poles nearest the unit circle last. The small dots are the Q15 poles.

Time response

Coefficient quantization check

The same cascade with its coefficients rounded the way each target stores them. Q15 and Q31 use one CMSIS postShift for the whole cascade.

FormatpostShiftPassband ΔStopband peakMax |p|Status

Pole radius by section

#|p| double|p| Q31|p| Q15Q15 Δ|p|1 − |p|

Export


      
// How it works

From an analog prototype to biquads in firmware

The design follows the same chain as scipy.signal, and the coefficients match it to about 1e-12. An analog low-pass prototype with its cutoff at 1 rad/s is turned into the response you asked for (low-pass, high-pass, band-pass or band-stop). The bilinear transform then maps it to the z-plane. Because the bilinear transform squeezes the whole analog frequency axis into 0 … fs/2, the edges are pre-warped first so they land exactly where you set them:

Ω = 2·fs·tan(π·f / fs) pre-warped analog edge s = 2·fs·(z − 1) / (z + 1) bilinear transform H(z) = k · Π (b0 + b1 z⁻¹ + b2 z⁻²) / (1 + a1 z⁻¹ + a2 z⁻²)

What the edge frequency means depends on the family. Butterworth: the −3 dB point. Chebyshev I and elliptic: the passband edge, where the loss reaches Rp. Chebyshev II: the stopband edge, where the attenuation reaches Rs. With "minimum order from a spec" the tool runs scipy's buttord, cheb1ord, cheb2ord or ellipord on your pass and stop edges and designs at the order they return.

Why second-order sections

A single high-order polynomial puts all the poles in two long coefficient vectors, and rounding those coefficients moves the poles a long way. Splitting the filter into biquads keeps each pole pair in its own two coefficients. The pairing follows scipy's zpk2sos: start from the pole nearest the unit circle, give it the nearest zero, and put those sections last. That keeps the high-gain, high-Q sections at the end of the chain, where the earlier sections have already removed out-of-band energy.

CMSIS-DSP conventions

df1_f32 / df2T_f32 / df1_q31 : {b0, b1, b2, a1, a2} per stage df1_q15 : {b0, 0, b1, b2, a1, a2} per stage (the 0 enables 16-bit SIMD) kernel : y[n] = b0·x[n] + b1·x[n−1] + b2·x[n−2] + a1·y[n−1] + a2·y[n−2] ⇒ export a1, a2 = −(textbook a1, a2) fixed point : stored word = round(c · 2^15 / 2^postShift) (2^31 for Q31)

CMSIS adds the feedback terms, so the exported a1 and a2 have the opposite sign to the table above. This is the most common bug in hand-ported biquads. The filter usually still runs, but the poles are mirrored and the response is wrong. The fixed-point kernels need every coefficient in [−1, 1). The library scales the accumulator by 2^postShift, so the tool picks the smallest shift that fits every coefficient. A numerator of [1, 2, 1] needs postShift 2, because 2/2 = 1.0 is just outside Q15. The L∞ option rescales each section so that the gain from the input to its output peaks at 0 dB, which leaves headroom for the 16-bit state.

The quantization check

Each format's coefficients are rounded exactly as the target stores them, and the tool recomputes the response and the pole radii from the rounded values. Poles close to z = 1 are the sensitive ones. That happens with a low cutoff relative to the sample rate, with a high order, or with a narrow band. There, a Q15 step of 3e-5 in a1 or a2 can be a large fraction of the distance to the unit circle. The status turns serious when a pole moves by more than a quarter of its distance to the circle or the passband shifts by more than 1 dB. It turns critical when a pole reaches the circle. The usual fixes are float32, Q31, a lower sample rate (decimate first), or a lower order.

Limits

References

  1. SciPy, scipy.signal: iirfilter, buttap/cheb1ap/cheb2ap/ellipap, bilinear_zpk, zpk2sos, buttord/ellipord (BSD-3-Clause). This tool's design code is a JavaScript port of these routines, and its tests check it against scipy 1.18.
  2. Arm, CMSIS-DSP library, arm_biquad_cascade_df1_f32, _df2T_f32, _df1_q15, _df1_q31 and their init functions, github.com/ARM-software/CMSIS-DSP (Apache-2.0).
  3. A. V. Oppenheim, R. W. Schafer, Discrete-Time Signal Processing, 3rd ed., Pearson, 2010: bilinear transform, frequency warping, cascade structures.
  4. S. J. Orfanidis, "Lecture notes on elliptic filter design," Rutgers University, 2006: degree equation and Landen transformations (the method behind scipy's ellipap).
  5. M. Abramowitz, I. A. Stegun, Handbook of Mathematical Functions, §16.4 and §17.6: Jacobi elliptic functions and the arithmetic-geometric mean.
  6. L. B. Jackson, "On the interaction of roundoff noise and dynamic range in digital filters," Bell System Technical Journal 49(2), 1970: L∞ / L2 section scaling.

Filter misbehaving on the target?

Kyros builds signal chains end to end: the analog front end, the converter, and the fixed-point firmware that has to keep the filter stable at temperature and in production.

Talk about your project →