Arduino Helpers master
Utility library for Arduino
Public Member Functions | Private Attributes | List of all members
EMA_f Class Reference

#include <AH/Filters/EMA.hpp>

Detailed Description

A class for single-pole infinite impulse response filters or exponential moving average filters.

This version uses floating point maths.

Difference equation: \( y[n] = \alpha·x[n]+(1-\alpha)·y[n-1] \) \( x \) is the input sequence, and \( y \) is the output sequence.

[An in-depth explanation of the EMA filter] (https://tttapa.github.io/Pages/Mathematics/Systems-and-Control-Theory/Digital-filters/Exponential%20Moving%20Average/)

Definition at line 153 of file EMA.hpp.

+ Collaboration diagram for EMA_f:

Public Member Functions

 EMA_f (float pole)
 Create an exponential moving average filter with a pole at the given location. More...
 
float filter (float value)
 Filter the input: Given \( x[n] \), calculate \( y[n] \). More...
 
float operator() (float value)
 Filter the input: Given \( x[n] \), calculate \( y[n] \). More...
 

Private Attributes

float alpha
 
float filtered = 0
 

Constructor & Destructor Documentation

◆ EMA_f()

EMA_f ( float  pole)
inline

Create an exponential moving average filter with a pole at the given location.

Parameters
poleThe pole of the filter ( \(1-\alpha\)).
Should be a value in the range \( \left[0,1\right) \).
Zero means no filtering, and closer to one means more filtering.

Definition at line 165 of file EMA.hpp.

Member Function Documentation

◆ filter()

float filter ( float  value)
inline

Filter the input: Given \( x[n] \), calculate \( y[n] \).

Parameters
valueThe new raw input value.
Returns
The new filtered output value.

Definition at line 174 of file EMA.hpp.

◆ operator()()

float operator() ( float  value)
inline

Filter the input: Given \( x[n] \), calculate \( y[n] \).

Parameters
valueThe new raw input value.
Returns
The new filtered output value.

Definition at line 180 of file EMA.hpp.

Member Data Documentation

◆ alpha

float alpha
private

Definition at line 183 of file EMA.hpp.

◆ filtered

float filtered = 0
private

Definition at line 184 of file EMA.hpp.


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