TExcelTAD
Home › Signals, Systems & Digital Filters for Engineers › Signals and DSP Exercises

Signals and DSP Exercises

These exercises cover the whole course in its order. Work each one by hand first, with units on every number, then check it with a few lines of Python (the program at the end checks several answers at once). Each answer links back to the lesson to revisit.

Signals and systems

1. Power and rms. A sensor output is v(t)=2 V+3 V⋅sin⁡(2π⋅400 Hz⋅t)v(t) = 2\ \text{V} + 3\ \text{V}\cdot\sin(2\pi \cdot 400\ \text{Hz} \cdot t). What is its rms value, and what power does it deliver into 600 Ω600\ \Omega?

Answer

P=22+32/2=8.5 V2P = 2^2 + 3^2/2 = 8.5\ \text{V}^2, Vrms=2.92 VV_\text{rms} = 2.92\ \text{V}; into 600 Ω600\ \Omega: 8.5/600=14.2 mW8.5/600 = 14.2\ \text{mW}. Review: Signal Classes.

2. Discrete periodicity. A 1.5 kHz1.5\ \text{kHz} tone is sampled at 8 kSa/s8\ \text{kSa/s}. After how many samples do the samples repeat?

Answer

f0/fs=1500/8000=3/16f_0/f_s = 1500/8000 = 3/16: every 16 samples (3 cycles). Review: Signal Classes.

3. Properties. Classify y[n]=x[n] x[n−1]y[n] = x[n]\,x[n-1].

Answer

Non-linear (doubling xx quadruples yy), time invariant, causal, stable (bounded inputs give bounded products), with memory. Review: System Properties.

4. Convolution. Convolve {1,2,1}\{1, 2, 1\} with {1,−1}\{1, -1\} and check with the sum rule.

Answer

{1,1,−1,−1}\{1, 1, -1, -1\}; sums: 4×0=04 \times 0 = 0. Review: Discrete Convolution.

5. A pulse through an RC. A 4 V4\ \text{V} pulse lasting 1 ms1\ \text{ms} drives an RC low-pass with τ=2 ms\tau = 2\ \text{ms}. What is the peak output?

Answer

4(1−e−0.5)=1.57 V4(1 - e^{-0.5}) = 1.57\ \text{V} at the end of the pulse. Review: Continuous-Time Convolution.

6. Discretising an RC. An RC with τ=5 ms\tau = 5\ \text{ms} is imitated at T=0.5 msT = 0.5\ \text{ms}. Give the exact (zero-order-hold) and forward-Euler poles.

Answer

e−0.1=0.9048e^{-0.1} = 0.9048 and 1−0.1=0.91 - 0.1 = 0.9. Review: Difference Equations.

7. Moving average. A 10-sample average runs at 500 Sa/s500\ \text{Sa/s}. Where are its nulls and what is its delay?

Answer

At multiples of 50 Hz50\ \text{Hz}; 4.54.5 samples =9 ms= 9\ \text{ms}. Review: Frequency Response.

Transforms

8. Second-order system. H(s)=1000s2+20s+10 000H(s) = \dfrac{1000}{s^2 + 20s + 10\,000}. Find ωn\omega_n, ζ\zeta, the DC gain, the step overshoot and ∣H(jωn)∣\lvert H(j\omega_n) \rvert.

Answer

ωn=100 rad/s\omega_n = 100\ \text{rad/s}, 2ζωn=202\zeta\omega_n = 20 so ζ=0.1\zeta = 0.1; DC gain 0.10.1; overshoot e−π⋅0.1/0.99=72.9 %e^{-\pi \cdot 0.1/\sqrt{0.99}} = 72.9\,\%; ∣H(jωn)∣=0.1/(2×0.1)=0.5\lvert H(j\omega_n) \rvert = 0.1/(2 \times 0.1) = 0.5. Review: Laplace for Systems.

9. A DC blocker. H(z)=1−z−11−0.9z−1H(z) = \dfrac{1 - z^{-1}}{1 - 0.9z^{-1}}. What are its DC and Nyquist gains? What kind of filter is it?

Answer

H(1)=0H(1) = 0, H(−1)=2/1.9=1.053H(-1) = 2/1.9 = 1.053: a high-pass (DC blocker) with its pole at 0.90.9. Review: The z-Transform.

10. Notch design. Design a 60 Hz60\ \text{Hz} notch at fs=1 kSa/sf_s = 1\ \text{kSa/s} with poles at r=0.99r = 0.99. Give the denominator and the approximate notch width.

Answer

Ω0=0.12π\Omega_0 = 0.12\pi; a=[1,−2(0.99)cos⁡(0.12π),0.992]=[1,−1.8410,0.9801]a = [1, -2(0.99)\cos(0.12\pi), 0.99^2] = [1, -1.8410, 0.9801]; width ≈(1−r)fs/π=3.2 Hz\approx (1 - r)f_s/\pi = 3.2\ \text{Hz}. Review: Poles and Zeros in z.

Sampling and conversion

11. Where does it land? A 9 kHz9\ \text{kHz} interferer reaches an ADC sampling at 8 kSa/s8\ \text{kSa/s} whose band of interest is 00 to 2 kHz2\ \text{kHz}. Where does it appear?

Answer

∣9−8∣=1 kHz\lvert 9 - 8 \rvert = 1\ \text{kHz}, inside the band: it must be removed before sampling. Review: The Sampling Theorem.

12. Anti-alias attenuation. A 4th-order Butterworth low-pass at 2 kHz2\ \text{kHz} precedes an ADC. Estimate its attenuation at 7.3 kHz7.3\ \text{kHz}.

Answer

10log⁡10(1+(7.3/2)8)=45.0 dB10\log_{10}(1 + (7.3/2)^8) = 45.0\ \text{dB} (80log⁡103.6580 \log_{10}3.65 asymptotically): a 0.5 V0.5\ \text{V} interferer becomes about 2.8 mV2.8\ \text{mV}. Review: Anti-Alias Filters.

13. Sinc droop. A zero-order-hold DAC runs at 48 kSa/s48\ \text{kSa/s}. What is its droop at 20 kHz20\ \text{kHz}?

Answer

20log⁡10∣sinc⁡(20/48)∣=−2.64 dB20\log_{10}\lvert\operatorname{sinc}(20/48)\rvert = -2.64\ \text{dB}. Review: Reconstruction and DACs.

14. Quantisation. A 16-bit converter digitises a sine at −40 dBFS-40\ \text{dBFS}. What is its signal-to-quantisation-noise ratio?

Answer

98.1−40=58.1 dB98.1 - 40 = 58.1\ \text{dB}. Review: Quantisation.

DFT and spectral analysis

15. Bins. N=1000N = 1000 samples at fs=1 kSa/sf_s = 1\ \text{kSa/s}. What is the bin spacing, and which bin holds 50 Hz50\ \text{Hz}? How do you scale rfft to get the amplitude of a sine?

Answer

1 Hz1\ \text{Hz}; bin 50; multiply ∣X[k]∣\lvert X[k] \rvert by 2/N2/N (not for DC or Nyquist). Review: The DFT and FFT.

16. Windows. Which window would you choose to measure the amplitude of a tone between bins to 0.1 dB0.1\ \text{dB}, and which to find a weak tone close to a strong one?

Answer

Flat-top (scalloping about 0.01 dB0.01\ \text{dB}); a low-sidelobe window such as Hann or Blackman–Harris for the weak neighbour (the rectangular window's skirts hide it). Review: Leakage and Windows.

17. Resolution. Two tones are 1.5 Hz1.5\ \text{Hz} apart. Does zero padding a 0.5 s0.5\ \text{s} record help separate them? What record length is needed with a Hann window?

Answer

No: padding interpolates the same blurred spectrum. Resolution needs TT of roughly 2/Δf≈1.3 s2/\Delta f \approx 1.3\ \text{s} for Hann; the lesson's tones are resolved from T=1.5 sT = 1.5\ \text{s}. Review: Resolution and Zero Padding.

18. Noise density. White noise of 1 mV1\ \text{mV} rms is sampled at 10 kSa/s10\ \text{kSa/s}. What is its one-sided density, and the noise in a 100 Hz100\ \text{Hz} band?

Answer

1 mV/5000 Hz=14.1 μV/Hz1\ \text{mV}/\sqrt{5000\ \text{Hz}} = 14.1\ \mu\text{V}/\sqrt{\text{Hz}}; 14.1×100=141 μV14.1 \times \sqrt{100} = 141\ \mu\text{V}. Review: Spectral Estimation.

19. STFT frame. Why can't one frame length show both the exact frequency of a chirp and the exact time of a short burst?

Answer

A frame of length TT gives frequency resolution of order 1/T1/T and time resolution of order TT: long frames sharpen frequency and smear time, short frames the reverse. Review: Spectrograms.

Filter design

20. Specification. Convert Ap=1 dBA_p = 1\ \text{dB} and As=60 dBA_s = 60\ \text{dB} into δp\delta_p and δs\delta_s.

Answer

δp=(101/20−1)/(101/20+1)=0.0575\delta_p = (10^{1/20} - 1)/(10^{1/20} + 1) = 0.0575, δs=10−3\delta_s = 10^{-3}. Review: Filter Specifications.

21. FIR methods. For the mask fs=8 kHzf_s = 8\ \text{kHz}, pass to 1 kHz1\ \text{kHz} (1 dB), stop from 1.5 kHz1.5\ \text{kHz} (60 dB), the Kaiser window needs 60 taps and Parks–McClellan 36. Why the difference, and what is the delay of each?

Answer

The window method's ripple is set by the stopband and is wasted in the passband; equiripple spreads the error evenly to the limits. Delays (N−1)/2(N - 1)/2: 29.529.5 samples =3.69 ms= 3.69\ \text{ms} and 17.517.5 samples =2.19 ms= 2.19\ \text{ms}. Review: FIR Window Design, Equiripple FIR.

22. IIR orders. For the same mask, Butterworth needs order 16, Chebyshev 8 and elliptic 6. Name one reason to choose each anyway.

Answer

Butterworth: maximally flat, gentle phase; Chebyshev I: fewer poles with a flat stopband; elliptic: the lowest order (cost), when ripple in both bands is acceptable. Review: Analog Prototypes.

23. Pre-warping. A bilinear-transform design needs a 1 kHz1\ \text{kHz} cutoff at fs=8 kSa/sf_s = 8\ \text{kSa/s}. What analog cutoff must the prototype have?

Answer

fa=fsπtan⁡(πfd/fs)=8000πtan⁡(π/8)=1054.8 Hzf_a = \frac{f_s}{\pi}\tan(\pi f_d/f_s) = \frac{8000}{\pi}\tan(\pi/8) = 1054.8\ \text{Hz}. Review: The Bilinear Transform.

24. Why biquads? An 8th-order elliptic low-pass at 1 kHz1\ \text{kHz}, fs=48 kSa/sf_s = 48\ \text{kSa/s}, has its largest pole at radius 0.9970.997. What happens if its single 8th-order denominator is rounded to 16 fractional bits, and how do second-order sections avoid it?

Answer

The poles of a high-order polynomial are very sensitive to coefficient errors: the rounded polynomial has a pole at radius 1.241.24 (unstable). Each biquad's poles depend only on its own two coefficients, so rounding moves them slightly and they stay inside. Review: Biquads and SOS.

Implementation and multirate

25. Fixed point. A Q15 accumulator receives 35 00035\,000. What does it hold with wrap-around, and with saturation?

Answer

35 000−65 536=−30 53635\,000 - 65\,536 = -30\,536 with wrap-around; 32 76732\,767 with saturation. Review: Filter Structures and Fixed Point.

26. Latency budget. Audio at 48 kSa/s48\ \text{kSa/s} is processed in 64-sample blocks with ping-pong buffers. Which part of the latency does the block size set, and how do you reduce it?

Answer

Ping-pong buffering costs at least two blocks, 2×64/48 000=2.67 ms2 \times 64/48\,000 = 2.67\ \text{ms}; the converters' delays and the filter's own group delay come on top (4.67 ms4.67\ \text{ms} in total for the lesson's example with a 129-tap FIR). Smaller blocks cut the buffering at the price of more interrupts per second. Review: Real-Time DSP.

27. Decimation. Why must a signal be low-pass filtered before keeping every third sample at 48 kSa/s48\ \text{kSa/s}, and what does a polyphase decimator save?

Answer

Anything above the new Nyquist frequency (8 kHz8\ \text{kHz}) aliases (a 10 kHz10\ \text{kHz} tone lands at 6 kHz6\ \text{kHz}). A polyphase structure computes only the outputs that are kept, a factor of 3 fewer multiplications. Review: Multirate.

28. CIC word length. A CIC decimator with R=16R = 16, N=4N = 4 stages takes 12-bit input. What is its DC gain and the register width it needs?

Answer

(RM)N=164=65 536=216(RM)^N = 16^4 = 65\,536 = 2^{16}; registers of 12+16=2812 + 16 = 28 bits, and two's-complement wrap-around in the integrators is then harmless. Review: CIC Filters.

Advanced filtering and applications

29. Delay estimation. Two microphone channels at 48 kSa/s48\ \text{kSa/s} correlate best at a lag of 12 samples. What path difference is that at 343 m/s343\ \text{m/s}?

Answer

12/48 000×343=0.0858 m=8.6 cm12/48\,000 \times 343 = 0.0858\ \text{m} = 8.6\ \text{cm}. Review: Correlation and Matched Filtering.

30. LMS step. A 16-tap LMS filter sees white input with σx2=0.5\sigma_x^2 = 0.5. Give the stability bound and the weights' time constant for μ=0.01\mu = 0.01.

Answer

μ<2/(16×0.5)=0.25\mu < 2/(16 \times 0.5) = 0.25; time constant 1/(0.01×0.5)=2001/(0.01 \times 0.5) = 200 samples. Review: Adaptive Filters.

31. FM bandwidth. A 3 kHz3\ \text{kHz} tone frequency-modulates a carrier with 5 kHz5\ \text{kHz} deviation. What is β\beta and the Carson bandwidth?

Answer

β=5/3=1.67\beta = 5/3 = 1.67; B=2(5+3)=16 kHzB = 2(5 + 3) = 16\ \text{kHz}. Review: Modulation.

32. Requirements. A design meets its mask in floating point with 0.2 dB0.2\ \text{dB} to spare and will run with 16-bit coefficients. What should you check before signing it off?

Answer

Re-check the mask with quantised coefficients (the mini project's designs lose up to about 1 dB1\ \text{dB} of stopband attenuation), the pole radii, internal overflow and scaling, limit cycles, the processor load and the latency. Review: Applications, Mini Project.

Check several answers in Python

python · try it yourself
import numpy as np
from scipy.signal import freqz, butter

print(f"1.  rms {np.sqrt(2**2 + 3**2 / 2):.3f} V, power {1e3 * 8.5 / 600:.2f} mW")
print(f"5.  peak {4 * (1 - np.exp(-0.5)):.3f} V")
print(f"8.  overshoot {100 * np.exp(-np.pi * 0.1 / np.sqrt(1 - 0.01)):.1f} %")
_, H = freqz([1, -1], [1, -0.9], worN=[0.0, 0.5], fs=1.0)
print(f"9.  |H| at DC {abs(H[0]):.3f}, at Nyquist {abs(H[1]):.4f}")
W0 = 2 * np.pi * 60 / 1000
print(f"10. a = [1, {-2 * 0.99 * np.cos(W0):.4f}, {0.99**2:.4f}], width {(1 - 0.99) * 1000 / np.pi:.2f} Hz")
print(f"12. attenuation {10 * np.log10(1 + (7.3 / 2) ** 8):.1f} dB")
print(f"13. droop {20 * np.log10(np.sinc(20 / 48)):.2f} dB")
print(f"23. pre-warped cutoff {8000 / np.pi * np.tan(np.pi * 1000 / 8000):.1f} Hz")
b, a = butter(1, 1000, fs=8000)
_, H = freqz(b, a, worN=[1000.0], fs=8000)
print(f"    check: butter(1, 1000, fs=8000) gives {20 * np.log10(abs(H[0])):.2f} dB at 1 kHz")
print(f"28. CIC gain {16**4}, register bits {12 + int(np.log2(16**4))}")
print(f"29. path difference {100 * 12 / 48000 * 343:.2f} cm")
1.  rms 2.915 V, power 14.17 mW
5.  peak 1.574 V
8.  overshoot 72.9 %
9.  |H| at DC 0.000, at Nyquist 1.0526
10. a = [1, -1.8410, 0.9801], width 3.18 Hz
12. attenuation 45.0 dB
13. droop -2.64 dB
23. pre-warped cutoff 1054.8 Hz
    check: butter(1, 1000, fs=8000) gives -3.01 dB at 1 kHz
28. CIC gain 65536, register bits 28
29. path difference 8.58 cm

Test yourself

Which change improves the frequency resolution of an FFT analysis?

  1. zero padding
  2. a longer record
  3. a higher sampling rate with the same N
  4. a flat-top window

A filter must keep pulse shapes intact. Which design fits?

  1. elliptic IIR
  2. symmetric FIR (linear phase)
  3. Chebyshev I IIR
  4. a single-pole smoother

The best order of operations for an ADC channel with out-of-band interference is

  1. sample, then filter digitally
  2. analog anti-alias filter, then sample, then digital filtering and decimation
  3. decimate, then anti-alias filter
  4. quantise, then filter in analog

Why are high-order IIR filters implemented as cascades of biquads?

  1. fewer coefficients
  2. their poles are far less sensitive to coefficient rounding
  3. they have linear phase
  4. they need no state