A class for single-pole infinite impulse response filters or exponential moving average filters.
More...
template<uint8_t K, class uint_t>
class EMA< K, uint_t >
A class for single-pole infinite impulse response filters or exponential moving average filters.
Optimized implementation of the difference equation with a slight optimization by using a factor of two as the pole location (this means that no division or floating point operations are required).
Difference equation: \( y[n] = \alpha·x[n]+(1-\alpha)·y[n-1] \) where \( \alpha = \left(\frac{1}{2}\right)^{K} \), \( x \) is the input sequence, and \( y \) is the output sequence.
An in-depth explanation of the EMA filter
- Template Parameters
-
K | The amount of bits to shift by. This determines the location of the pole in the EMA transfer function, and therefore the cut-off frequency.
The higher this number, the more filtering takes place.
The pole location is \( 1 - 2^{-K} \). |
uint_t | The (signed) integer type to use for the input, intermediate values and the output. Should be at least \( M+K \) bits wide, where \( M \) is the maximum number of bits of the input. In case of the Arduino's built-in ADC, \( M = 10 = \log_2(1024) \). |
Definition at line 42 of file EMA.hpp.