This video demonstrates the application of the bilinear (or Tustin) transform to convert analog filter prototypes into digital filters for real-time implementation on microcontrollers. Using an RC low-pass filter as an example, the host details the mathematical derivation of the bilinear transform and the necessary frequency pre-warping technique, contrasting its superior frequency domain match with the simpler but less accurate backward Euler method. The entire process, from theoretical conversion to practical C code implementation, is showcased on a custom STM32H7-based digital guitar effects processing unit, featuring variable cutoff frequency control and real-time frequency response analysis.
Summarizing the Bilinear Transform for Digital Filters
0:00 Digital Filter Implementation: The video introduces the use of the bilinear (Tustin) transform to create digital filters from analog prototypes, demonstrating an RC low-pass filter simulation on an STM32 microcontroller.
0:44 Custom DSP Unit: The demonstration platform is a custom digital guitar effects processing unit, featuring an STM32H7 microcontroller, audio codec (ADC/DAC), and control interfaces (ADCs, switches, potentiometers) for real-time audio signal processing.
2:37 Discretization Basics: Discretization is explained as the conversion of continuous-time (analog) systems/signals, typically represented by differential equations, into digital discrete-time (sampled) systems/signals, represented by difference equations. This allows for flexible, software-based implementation, avoiding analog component tolerances.
3:57 Methods of Conversion: Various methods for converting analog prototypes to digital systems are discussed, including direct digital design, response matching (impulse, step, ramp invariance), and algebraic transforms (backward difference/Euler and bilinear).
5:09 Backward Difference Method: This method is intuitive and simple, approximating continuous-time derivatives with discrete-time derivatives. However, it offers a poor frequency domain match between analog prototypes and their digital equivalents.
6:04 Bilinear (Tustin) Transform: This alternative method, though more tedious due to requiring frequency pre-warping, provides a much better frequency domain match. Its derivation involves relationships between Laplace (S) and Z transforms.
8:18 Frequency Warping and Pre-Warping: A key aspect of the bilinear transform is frequency warping, a nonlinear mapping from continuous to discrete frequency ranges. To compensate, critical frequencies (e.g., cutoff) must be "pre-warped" using a specific tangent-based equation to ensure accuracy at the desired points.
9:41 RC Low-Pass Filter Example: The process for an RC low-pass filter is detailed: deriving its differential equation, converting it to an S-domain transfer function, applying the bilinear transform to get a Z-domain transfer function, and finally converting to a real-time difference equation for implementation.
13:42 Frequency Domain Performance Comparison: Visualized Bode plots (magnitude and phase vs. frequency) show that the bilinear transform with pre-warping achieves a significantly better match to the analog prototype's frequency response, especially at the cutoff frequency, compared to the backward Euler method.
15:39 Real-Time Code Implementation: The C code for the filter on the STM32 is detailed, showing how coefficients are calculated (including pre-warping) and how the difference equation is applied in an update function, using a struct for persistent memory.
21:09 Live Demonstration: The digital filter's real-time performance is verified using a Quantasylum QA403 audio analyzer, demonstrating the variable cutoff frequency of the implemented filter by adjusting a potentiometer.
22:42 Conclusion & Takeaway: The bilinear transform, while more mathematically involved, is recommended for applications requiring a precise frequency domain match to analog filter designs, offering flexibility and tunability in digital systems.