template<size_t N, typename Tval = double, typename Tcoeff = Tval>
class eeros::control::MAFilter< N, Tval, Tcoeff >
A moving average filter (MAFilter) block is used to filter an input signal. The output signal value depends linearly on the current and various past input signal values. This is achieved by multiplying the current and the past values with the specified coefficients. The results are accumulated and lead to the output signal value. The following terms represents the operation performed in this block.
y[t] = c[0]*x[t-N] + c[1]*x[t-N+1] + ... + c[N]*x[t]
Outp = c[0]*prev[0] + c[1]*prev[1] + ... + c[N]*Inp
MAFilter is a class template with two type and one non-type template arguments. The two type template arguments specify the types which are used for the values and the coefficients when the class template is instanciated. The non-type template argument specifies the number of coefficients and the number of concidered past values respectively.
- Template Parameters
-
N | - number of coefficients |
Tval | - value type (double - default type) |
Tcoeff | - coefficients type (Tval - default value) |
- Since
- v0.6
template<size_t N, typename Tval = double, typename Tcoeff = Tval>
Runs the filter algorithm.
Performs the calculation of the filtered output signal value. Multiplies the current and past input signal values with the coefficients. The coefficients weight the current and past input signal values. Finally, the resulting values are accumulated and yield to the output signal value if the filter instance is enabled. Otherwise, the output signal value is set to the actual input signal value.
The timestamp value will not be altered.
- See also
- enable()
-
disable()
Implements eeros::Runnable.