template<uint8_t A = 10>
class EWMA_average< A >
Implements an Exponentially Weighted Moving Average (EWMA).
The EWMA_average
class calculates the Exponentially Weighted Moving Average (EMA), Double EMA (DEMA), and Triple EMA (TEMA) for a given input series. It uses integer math for efficiency, making it suitable for systems with limited computational power.
- Template Parameters
-
A | The smoothing factor, which determines the weight of recent values in the average. |
- The smoothing factor is rounded to the nearest power of 2 for faster integer calculations.
- EMA provides a smoothed average of the input series.
- DEMA and TEMA offer improved responsiveness, especially for peak inputs.
- The class is optimized for use in embedded systems like Arduino.
Cloud Immunity Tuning
For PV router applications, cloud immunity is crucial to prevent relay chattering:
TEMA (getAverageT()) is recommended for relay control as it provides:
- Best immunity to brief cloud shadows (5-60 seconds)
- Good responsiveness to genuine load changes
- Optimal balance for most installations
Filter Comparison:
- EMA (getAverageS()): Basic smoothing, most responsive, least cloud immunity
- DEMA (getAverageD()): Better cloud immunity, good responsiveness
- TEMA (getAverageT()): Best cloud immunity, excellent responsiveness to real changes
Tuning Guidelines:
- Template parameter A should be:
delay_minutes * 60 / sample_period_seconds
- For 5-second sampling: A = delay_minutes * 12
- Recommended delays: 1-3 minutes for most installations
Definition at line 107 of file ewma_avg.hpp.
Add a new value and update the EMA, DEMA, and TEMA.
This method processes a new input value and updates the Exponentially Weighted Moving Average (EMA), Double EMA (DEMA), and Triple EMA (TEMA).
- Parameters
-
input | The new input value to process. |
Definition at line 118 of file ewma_avg.hpp.