Arduino Filters master
Filter library for Arduino
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
NonNormalizingIIRFilter< NB, NA, T > Class Template Reference

#include <Filters/IIRFilter.hpp>

Detailed Description

template<uint8_t NB, uint8_t NA, class T>
class NonNormalizingIIRFilter< NB, NA, T >

Infinite Impulse Response filter implementation that does not normalize the coefficients upon initialization, the division by \( a_0 \) is carried out on each filter iteration.

This class is slower than NormalizingIIRFilter, but it works better for integer types, because it has no rounding error on the coefficients.

Implements the following difference equation using the Direct-Form 1 implementation:

\[ y[n] = \frac{1}{a_0} \left(\sum_{i=0}^{N_b-1} b_i \cdot x[n-i] - \sum_{i=1}^{N_a-1} a_i \cdot y[n-i] \right) \]

Definition at line 27 of file IIRFilter.hpp.

+ Collaboration diagram for NonNormalizingIIRFilter< NB, NA, T >:

Public Member Functions

 NonNormalizingIIRFilter (const AH::Array< T, NB > &b_coefficients, const AH::Array< T, NA > &a_coefficients)
 Construct a new Non-Normalizing IIR Filter object. More...
 
 NonNormalizingIIRFilter (const TransferFunction< NB, NA, T > &tf)
 
operator() (T input)
 Update the internal state with the new input \( x[n] \) and return the new output \( y[n] \). More...
 

Private Attributes

uint8_t index_b = 0
 
uint8_t index_a = 0
 
AH::Array< T, NB > x = {}
 Previous inputs. More...
 
AH::Array< T, MAy = {}
 Previous outputs. More...
 
AH::Array< T, 2 *NB - 1 > b_coefficients
 Numerator coefficients. More...
 
AH::Array< T, 2 *MA - 1 > a_coefficients
 Denominator coefficients. More...
 
a0
 

Static Private Attributes

static constexpr uint8_t MA = NA - 1
 

Constructor & Destructor Documentation

◆ NonNormalizingIIRFilter() [1/2]

NonNormalizingIIRFilter ( const AH::Array< T, NB > &  b_coefficients,
const AH::Array< T, NA > &  a_coefficients 
)
inline

Construct a new Non-Normalizing IIR Filter object.

The coefficients \( b \) and \( a \) can be derived from the transfer function:

\[ H(z) = \frac{b_0 + b_1 z^{-1} + \ldots + b_{N_b} z ^{-N_b}} {a_0 + a_1 z^{-1} + \ldots + a_{N_b} z ^{-N_a}} \]

Parameters
b_coefficientsThe coefficients of the transfer function numerator.
a_coefficientsThe coefficients of the transfer function denominator.

Definition at line 45 of file IIRFilter.hpp.

◆ NonNormalizingIIRFilter() [2/2]

NonNormalizingIIRFilter ( const TransferFunction< NB, NA, T > &  tf)
inline

Definition at line 54 of file IIRFilter.hpp.

Member Function Documentation

◆ operator()()

T operator() ( input)
inline

Update the internal state with the new input \( x[n] \) and return the new output \( y[n] \).

Parameters
inputThe new input \( x[n] \).
Returns
The new output \( y[n] \).

Definition at line 65 of file IIRFilter.hpp.

Member Data Documentation

◆ MA

constexpr uint8_t MA = NA - 1
staticconstexprprivate

Definition at line 99 of file IIRFilter.hpp.

◆ index_b

uint8_t index_b = 0
private

Definition at line 100 of file IIRFilter.hpp.

◆ index_a

uint8_t index_a = 0
private

Definition at line 100 of file IIRFilter.hpp.

◆ x

AH::Array<T, NB> x = {}
private

Previous inputs.

Definition at line 101 of file IIRFilter.hpp.

◆ y

AH::Array<T, MA> y = {}
private

Previous outputs.

Definition at line 102 of file IIRFilter.hpp.

◆ b_coefficients

AH::Array<T, 2 * NB - 1> b_coefficients
private

Numerator coefficients.

Definition at line 103 of file IIRFilter.hpp.

◆ a_coefficients

AH::Array<T, 2 * MA - 1> a_coefficients
private

Denominator coefficients.

Definition at line 104 of file IIRFilter.hpp.

◆ a0

T a0
private

Definition at line 105 of file IIRFilter.hpp.


The documentation for this class was generated from the following file: