Lab 3 Primer#
Digital filters have several benefits compared to their analog counterparts
Design can be modified/tuned with software changes only
Exact initial conditions can be enforced
Scale to extremely high order
Can be designed for perfectly linear phase
Digital filters are used in a plethora of applications. To name a few,
Speech and audio
Image, video, and computer vision
Sonar, radar, and medical imaging
Digital communication (wifi, cellular, etc)
Review of LTI systems and filters#
Finite impulse response (FIR) filters#
For a causal discrete-time FIR filter, each output sample
This is often visualized as a ‘tapped delay line’
FIR filter design#
For typical frequency selective filters, the design goals are threefold
Minimize distortion of the signal in the passband(s)
Attenuate the stopband as much as possible
Keep the order of the filter low
As an example, consider the design of a bandpass filter. Ideally, the passband would have a gain of 0 dB and the two stopbands would have a gain of
Better frequency selectivity vs lower delay
Performance in the passband(s) vs performance in the stopband(s)
The Parks-McClellan algorithm (aka equiripple) produces a set of filter coefficients that is optimal in the sense that it minimizes the worst deviation between the actual response and the desired response. When using this method, we have control over several parameters:
Filter order
Lower order will provide shorter delay
Higher order will provide better frequency selectivity
Relative weights
Specifies how to weight each passband and stopband when computing the error that is minimized by the algorithm
Location of transition regions (specified by
and )Transition regions cause to much distortion to function as a passband but not enough attenuation to function as a stopband
Smaller transition region increases the amount of usable bandwidth
Larger transition region will provide better performance in the passband and stopband
Other FIR filter design methods include least-squares and window design methods.
Frame-based processing#
For a real-time system, data is constantly flowing in from the ADC and out to the DAC. We can configure how many samples to collect between interrupt triggers from the ADC.
In the extreme case, we can trigger an interrupt each time a new sample is available and immediately compute one output sample of the filter. alternatively, we can wait until a frame of
There are a number of advantages to a frame-based implementation:
Less overhead
Each interrupt requires a fixed number of processor cycles
.For sample-by-sample processing, this cost is incurred for each sample
For frame-based processing, this is reduced to
per sample
Computational advantages
Algorithms to filter
samples can be more efficient than algorithms that operate sample-by-sampleAllows use of single instruction multiple data (SIMD) operations
Memory advantages
In some systems, large blocks of memory can be moved more efficiently.
Caching may be more efficient with large frames
IIR Filters#
For a causal discrete-time IIR filter, each output sample
The choice to subtract the feedback terms rather than add them is arbitrary, but this is conventional because it leads to a slightly simpler expression of the transfer function in the z-domain
Numerical errors#
With finite precision data types, many sequences of operations can be carried out with perfect accuracy. For example:
>> single(7.2)*single(13.8)*single(1.0)
99.36
In general however, operations using finite precision data types (such as single precision floating point) are subject to numerical errors. For example:
>> single(7.2)*single(13.8e-35)*single(1.0e35)
99.35999
These numerical errors can cause serious issues in the design and implementation of IIR filters.
Cascade of biquads#
Previously, the transfer function was expressed in terms of the coefficients
A downside of this representation is that, even if all