---
title: "Problem set 10: designing filters and rate converters"
heading: "Problem set 10: from specifications to FIR and IIR filters, word lengths, notches and multistage decimators"
eyebrow: S7 · Problem set 10
type: problems
---

::: hook
These problems turn the filter and multirate lessons (6 to 26) into designs: starting from band edges in hertz, ripple and attenuation, delay or cost limits, and ending with orders, coefficients, word lengths and stage plans.
:::

::: pool
pick: 12

::: check
kind: parts
given: A = 40 | 60 | 80; p = 3 | 10; d = 1 | 2; s = 48 | 96

## A lowpass at {s} kHz must pass {p} kHz and reject {A} dB from {p} + {d} kHz, by Kaiser window.

::: part
answer: 0.1102*(A - 8.7)*step(A - 50) + (0.5842*(A - 21)^0.4 + 0.07886*(A - 21))*step(50 - A)
tolerance: 0.5%

### What β?

::: misses
- [any] Kaiser's formula for β.
:::
:::

::: part
answer: (A - 8)/(2.285*2*pi*d/s)
tolerance: 0.5%

### What order does Kaiser's formula give?

::: misses
- [any] $(A - 8)/(2.285\Delta\omega)$ with $\Delta\omega = 2\pi\Delta f/f_s$.
:::
:::
:::

::: check
kind: parts
given: d = 0.5 | 1 | 2; s = 44.1 | 48

## A 53 dB lowpass at {s} kHz has a {d} kHz transition band.

::: part
answer: 8*pi/(2*pi*d/s)
tolerance: 0.5%

### What order does a Hamming window need (main lobe 8π/M)?

::: misses
- [any] $M = 8\pi/\Delta\omega$.
:::
:::

::: part
answer: 45/(2.285*2*pi*d/s)
tolerance: 0.5%

### And a Kaiser window for the same 53 dB?

::: misses
- [any] $(53 - 8)/(2.285\Delta\omega)$.
:::
:::
:::

::: check
kind: parts
given: R = 0.1 | 0.5; A = 60 | 80; d = 0.5 | 2; s = 16 | 48

## An equiripple lowpass at {s} kHz may ripple {R} dB in its passband, must reject {A} dB, and has a {d} kHz transition.

::: part
answer: (-10*log((10^(R/20) - 1)/(10^(R/20) + 1)*10^(-A/20)) - 13)/(2.324*2*pi*d/s)
tolerance: 0.5%

### What order does Kaiser's estimate give?

::: misses
- [any] $\frac{-10\log(\delta_1\delta_2) - 13}{2.324\Delta\omega}$.
:::
:::

::: part
answer: (-10*log((10^(R/20) - 1)/(10^(R/20) + 1)*10^(-A/20)) - 13)/(2.324*2*pi*d/s)/2/(s*1000)*1000
unit: ms
tolerance: 0.5%

### What delay does that linear-phase filter add?

::: misses
- [any] M/2 samples.
:::
:::
:::

::: check
kind: parts
given: p = 2 | 4; t = 3 | 6; A = 30 | 50; s = 16 | 44.1

## A bilinear Butterworth lowpass at {s} kHz may lose 1 dB up to {p} kHz and must lose {A} dB from {t} kHz.

::: part
answer: 2*s*1000*tan(pi*p/s)/(2*pi)/1000
unit: kHz
tolerance: 0.5%

### At what analog frequency must the prototype's passband edge sit (prewarped, T = 1/f_s)?

::: misses
- [p] Prewarp: $\Omega = \frac2T\tan\frac{\omega}{2}$.
- [any] $\frac{f_s}{\pi}\tan\frac{\pi f_p}{f_s}$ in hertz.
:::
:::

::: part
answer: ceil(log((10^(A/10) - 1)/(10^0.1 - 1))/(2*log(tan(pi*t/s)/tan(pi*p/s))) - 1e-9)
unit: poles
tolerance: 0

### What order does it need?

::: misses
- [any] $N \ge \frac{\log[(10^{A/10} - 1)/(10^{0.1} - 1)]}{2\log(\Omega_s/\Omega_p)}$ with prewarped edges.
:::
:::
:::

::: check
kind: parts
given: N = 31 | 101 | 255; s = 8 | 48 | 192

## A linear-phase FIR with {N} taps runs at {s} kHz.

::: part
answer: (N - 1)/2/(s*1000)*1000
unit: ms
tolerance: 0.5%

### What is its delay?

::: misses
- [N/(s*1000)*1000] Half the length: (N − 1)/2 samples.
- [any] (N − 1)/2 samples.
:::
:::
:::

::: check
kind: parts
given: a = 0.9 | 0.99 | 0.999; S = 80 | 100

## A first-order recursive filter with pole {a} rounds once per sample; its output noise must sit {S} dB below full scale.

::: part
answer: 10*log(1/(1 - a^2))
unit: dB
tolerance: 0.5%

### What noise gain does the pole give?

::: misses
- [any] $1/(1 - a^2)$.
:::
:::

::: part
answer: ceil((S - 10*log(12) + 10*log(1/(1 - a^2)))/6.02 - 1e-9)
unit: bits
tolerance: 0

### How many fractional bits B does it need?

::: misses
- [any] Smallest B with $10\log_{10}\frac{2^{-2B}}{12(1 - a^2)} \le -S$.
:::
:::
:::

::: check
kind: parts
given: f = 50 | 60; B = 2 | 5 | 10; s = 1 | 8

## A notch removes {f} Hz hum at {s} kHz with a 3 dB bandwidth of {B} Hz: zeros on the unit circle at ±ω₀, poles at radius r.

::: part
answer: 1 - pi*B/(s*1000)
tolerance: 0.001%

### What pole radius gives that bandwidth (Δω ≈ 2(1 − r))?

::: misses
- [any] $r = 1 - \pi B/f_s$.
:::
:::

::: part
answer: -2*cos(2*pi*f/(s*1000))
tolerance: 0.5%

### What is the zero polynomial's middle coefficient, in $1 + bz^{-1} + z^{-2}$?

::: misses
- [any] $b = -2\cos\omega_0$.
:::
:::
:::

::: check
kind: parts
given: s = 64 | 128; p = 3 | 6; o = 8 | 16

## A decimator takes {s} kHz to {o} kHz, keeping 0 to {p} kHz and rejecting 60 dB in single-stage design.

::: part
answer: 52/(2.285*2*pi*(o/2 - p)/s)
tolerance: 0.5%

### What order does a single stage need (stopband from {o}/2 kHz)?

::: misses
- [any] Kaiser's order with Δf = $f_{out}/2 - f_p$ at the input rate.
:::
:::

::: part
answer: 52/(2.285*2*pi*(o/2 - p)/s)/(s/o)
unit: multiplications
tolerance: 0.5%

### How many multiplications per input sample does its polyphase form need?

::: misses
- [any] Taps over the decimation factor.
:::
:::
:::

::: check
kind: parts
given: s = 64 | 128; A = 60 | 80

## A {s} kHz signal is decimated to 8 kHz keeping 0–3 kHz at {A} dB, in two stages: first to 16 kHz, then by 2.

::: part
answer: (A - 8)/(2.285*2*pi*10/s)
tolerance: 0.5%

### What order does stage 1 need (it may let 3 to 13 kHz be its transition)?

::: misses
- [any] Δf = 16 − 3 − 3 = 10 kHz at the input rate.
:::
:::

::: part
answer: (A - 8)/(2.285*2*pi*1/16)
tolerance: 0.5%

### And stage 2 (3 to 4 kHz at 16 kHz)?

::: misses
- [any] Δf = 1 kHz at 16 kHz.
:::
:::
:::

::: check
kind: parts
given: N = 3 | 4 | 5; R = 16 | 32; A = 60 | 80; p = 0.1 | 0.2

## A CIC decimator (R = {R}) must reject {A} dB at the band aliasing onto a passband edge of {p} of the output rate.

::: part
answer: -20*log(abs(sin(pi*(1 - p))/(R*sin(pi*(1 - p)/R))))
unit: dB
tolerance: 0.5%

### What does one stage reject there?

::: misses
- [any] One stage's response at ν = 1 − ν_p.
:::
:::

::: part
answer: ceil(A/(-20*log(abs(sin(pi*(1 - p))/(R*sin(pi*(1 - p)/R))))) - 1e-9)
unit: stages
tolerance: 0

### How many stages does it need?

::: misses
- [any] The requirement over one stage's rejection, rounded up.
:::
:::
:::

::: check
kind: parts
given: s = 6 | 48; f = 50 | 60

## A comb $1 - z^{-N}$ must null {f} Hz and all its harmonics at {s} kHz.

::: part
answer: s*1000/f
tolerance: 0.5%

### What delay N does it need?

::: misses
- [any] $N = f_s/f_0$.
:::
:::
:::

::: check
kind: parts
given: P = 128 | 1024 | 8192; s = 16 | 48

## A {P}-tap filter runs by overlap-save with FFTs four times its length at {s} kHz.

::: part
answer: 4*(4*P*log(4*P)/log(2) + 4*P)/(3*P + 1)
tolerance: 0.5%

### How many real multiplications per output?

::: misses
- [any] $4(N\log_2N + N)/(N - P + 1)$ with N = 4P.
:::
:::

::: part
answer: (3*P + 1)/(s*1000)*1000
unit: ms
tolerance: 0.5%

### What latency does a block add?

::: misses
- [any] N − P + 1 samples.
:::
:::
:::

::: check
kind: parts
given: r = 0.9 | 0.98; B = 8 | 12

## A biquad's $a_2 = r^2$ with r = {r} is rounded to {B} fractional bits.

::: part
answer: sqrt(round(r^2*2^B)/2^B)
tolerance: 0.001%

### What pole radius results?

::: misses
- [any] $\sqrt{\text{round}(r^22^B)/2^B}$.
:::
:::
:::

::: check
kind: parts
given: N = 23 | 47 | 95; s = 96 | 768

## A halfband filter of {N} taps (N = 4K − 1) decimates a {s} kHz signal by 2.

::: part
answer: (N + 1)/4
unit: multiplications
tolerance: 0

### How many multiplications per output does it need?

::: misses
- [any] K = (N + 1)/4.
:::
:::

::: part
answer: (N + 1)/4*s*1000/2/1e6
unit: M/s
tolerance: 0.5%

### How many million a second?

::: misses
- [any] K times the output rate.
:::
:::
:::

::: check
kind: parts
given: M = 4 | 8 | 16; P = 12 | 32

## An interpolator by {M} uses a {P}M-tap polyphase filter.

::: part
answer: P
unit: multiplications
tolerance: 0

### How many multiplications does each output need?

::: misses
- [any] One subfilter of P taps.
:::
:::
:::
:::
