|
Filters 1.0
LPF, HPF, BPF, BSF, SRL
|
The Filters library is a C++ library providing discrete-time digital signal filtering algorithms for applications such as sensor signal processing, signal conditioning, robotics, control systems, and embedded systems.
The library provides templated filter implementations that support different numeric data types such as float and double.
All filters are organized under the filter namespace and further grouped according to their filter type.
The library currently provides the following digital filters:
The filters provide interfaces for configuration, parameter modification, signal processing, state reset, and retrieval of filter parameters.
Low-pass filters attenuate high-frequency components while allowing low-frequency components of the input signal to pass.
Available implementations:
High-pass filters attenuate low-frequency components and DC components while allowing higher-frequency components to pass.
Available implementations:
Band-pass filters allow frequency components around a specified center frequency to pass while attenuating frequency components below and above the passband.
Available implementation:
Band-stop filters attenuate frequency components within a specified frequency band while allowing frequencies below and above the stopband to pass.
Available implementation:
The filters are configured using their frequency parameters and sampling time.
First-order low-pass and high-pass filters can be configured using:
where:
fc is the cutoff frequency in Hz.dt is the sampling time in seconds.Second-order low-pass and high-pass filters use the same configuration interface:
The second-order filters use a prewarped cutoff frequency during their digital filter design.
Band-pass and band-stop filters are configured using center frequency, bandwidth, and sampling time:
where:
f0 is the center frequency in Hz.B is the bandwidth in Hz.dt is the sampling time in seconds.For the second-order band-pass and band-stop filters, the quality factor is defined as:
![\[Q = \frac{f_0}{B}
\]](form_0.png)
The filter classes provide an update() function for processing individual input samples.
A typical usage sequence is:
The update() function processes one input sample and returns the corresponding filtered output sample.
Each filter maintains internal state required for discrete-time signal processing.
The state can be reset using the reset() function:
Resetting a filter clears its previous signal samples and startup state.
The filters provide setter and getter functions for their configurable parameters.
Common parameters include:
The sampling frequency is calculated from the sampling time as:
![\[f_s = \frac{1}{dt}
\]](form_1.png)
The library uses the following namespace hierarchy:
The filter implementations are organized according to their filter category.
The filter classes provide a consistent interface for configuring and processing signals.
Typical operations include:
Individual filter classes may additionally provide parameter-specific setters and getters.
The filter classes are implemented as C++ templates:
This allows the same filter implementation to be used with different numeric data types.
A first-order low-pass filter can be used as follows:
A second-order band-pass filter can be configured as:
A second-order band-stop filter can be configured as: