Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qlibs::rms Class Reference

RMS calculator object. More...

#include <rms.hpp>

Inheritance diagram for qlibs::rms:
qlibs::smootherEXPW qlibs::smootherMWM2 qlibs::smootherLPF1 qlibs::smoother qlibs::smoother qlibs::tdl qlibs::smoother

Public Member Functions

virtual ~rms ()
 
 rms ()=default
 
real_t update (const real_t x) noexcept
 Computes the moving root mean square (RMS) of the input signal. The object uses both the exponential weighting method and the sliding window method to compute the moving RMS.
 
bool setup (real_t *const window, const size_t wsize) noexcept
 Initialize the RMS instance by setting the default optimal parameters.
 
template<size_t windowSize>
bool setup (real_t(&win)[windowSize]) noexcept
 Initialize the RMS instance by setting the default optimal parameters.
 
bool setParams (const real_t l, const real_t a) noexcept
 Change the recursive parameters for the moving RMS estimator.
 
- Public Member Functions inherited from qlibs::smootherEXPW
virtual ~smootherEXPW ()
 
bool setup (const real_t lam=0.8_re)
 Setup an initialize the Exponential weighting filter.
 
real_t smooth (const real_t x) override
 Perform the smooth operation recursively for the input signal x.
 
- Public Member Functions inherited from qlibs::smoother
virtual ~smoother ()
 
bool isInitialized (void) const
 Check if the smoother filter is initialized.
 
bool reset (void)
 Reset the the smoother filter.
 
- Public Member Functions inherited from qlibs::smootherMWM2
virtual ~smootherMWM2 ()
 
bool setup (real_t *window, const size_t w_size)
 Setup an initialize the Moving Window Median filter.
 
template<size_t windowSize>
bool setup (real_t(&window)[windowSize])
 Setup an initialize the Moving Window Median filter.
 
real_t smooth (const real_t x) override
 Perform the smooth operation recursively for the input signal x.
 
- Public Member Functions inherited from qlibs::tdl
virtual ~tdl ()
 
 tdl ()=default
 
 tdl (real_t *const area, const size_t n, const real_t initVal=0.0_re)
 Constructor for the Tapped Delay Line (TDL) instance.
 
template<size_t numberOfDelays>
 tdl (real_t(&area)[numberOfDelays], const real_t initVal=0.0_re) noexcept
 Constructor for the Tapped Delay Line (TDL) instance.
 
void setup (real_t *const area, const size_t n, const real_t initVal=0.0_re) noexcept
 Setup and initialize a Tapped Delay Line (TDL) instance by setting the default optimal parameters.
 
template<size_t numberOfDelays>
void setup (real_t(&area)[numberOfDelays], const real_t initVal=0.0_re) noexcept
 Setup and initialize a Tapped Delay Line (TDL) instance by setting the default optimal parameters.
 
void flush (const real_t initVal=0.0_re) noexcept
 Clears all delays from the TDL and sets them to the specified value.
 
real_t getOldest (void) const noexcept
 Get the oldest sample from the TDL x(k-n)
 
real_t getRecent (void) const noexcept
 Get the most recent sample from the TDL x(k)
 
real_t getAtIndex (const size_t i) const noexcept
 Get the specified delayed sample from the TDL x(k-i)
 
void insertSample (const real_t sample) noexcept
 Insert a new sample to the TDL removing the oldest sample.
 
const real_toperator[] (int index) noexcept
 Get the specified delayed sample from the TDL x(k-i)
 
void operator() (const real_t sample) noexcept
 Insert a new sample to the TDL removing the oldest sample.
 
bool isInitialized (void) const
 Check if the TDL has been initialized.
 
- Public Member Functions inherited from qlibs::smootherLPF1
virtual ~smootherLPF1 ()
 
bool setup (const real_t a=0.9_re)
 Setup an initialize the 1st order Low-Pass Filter.
 
real_t smooth (const real_t x) override
 Perform the smooth operation recursively for the input signal x.
 

Detailed Description

RMS calculator object.

Constructor & Destructor Documentation

◆ ~rms()

virtual qlibs::rms::~rms ( )
inlinevirtual

◆ rms()

qlibs::rms::rms ( )
default

Member Function Documentation

◆ setParams()

bool rms::setParams ( const real_t l,
const real_t a )
noexcept

Change the recursive parameters for the moving RMS estimator.

Parameters
[in]lExponential weighting factor, specified as a positive real scalar in the range [0,1]. A forgetting factor of 0.9 gives more weight to the older data than does a forgetting factor of 0.1. A forgetting factor of 1.0 indicates infinite memory. All the past samples are given an equal weight.
[in]aA parameter to tune the 2nd stage filter. Should be a value between [ 0 < a < 1 ]. A higher value will result in a smoother output but also increasing the convergence time.
Returns
true on success, otherwise returns false.

◆ setup() [1/2]

bool rms::setup ( real_t *const window,
const size_t wsize )
noexcept

Initialize the RMS instance by setting the default optimal parameters.

Parameters
[in]windowA pointer to the window storage, an array of wsize elements.
[in]wsizeThe window size.
Returns
true on success, otherwise returns false.

◆ setup() [2/2]

template<size_t windowSize>
bool qlibs::rms::setup ( real_t(&) win[windowSize])
inlinenoexcept

Initialize the RMS instance by setting the default optimal parameters.

Parameters
[in]winThe array for the window storage
Returns
true on success, otherwise returns false.

◆ update()

real_t rms::update ( const real_t x)
noexcept

Computes the moving root mean square (RMS) of the input signal. The object uses both the exponential weighting method and the sliding window method to compute the moving RMS.

Note
For a 50-60Hz sine waveform leave default parameters, use a window of 8 samples and make sure you call the this method at a rate of 1mS. In this configuration you will obtain an optimal estimate that converges in a cycle of the wave
Parameters
[in]xThe raw signal.
Returns
A recursive estimation of the RMS for the incoming signal x.