![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
sef
Dependencies: mbed
Fork of Bewegungen_mit_Sensor by
Diff: LowpassFilter.h
- Revision:
- 1:d40ff07e2fe0
diff -r 96f88638114b -r d40ff07e2fe0 LowpassFilter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LowpassFilter.h Wed May 10 09:14:12 2017 +0000 @@ -0,0 +1,36 @@ +#ifndef LOWPASS_FILTER_H_ +#define LOWPASS_FILTER_H_ + +#include <cstdlib> +#include <cmath> + +//E. Hess +//LowpassFilter.cpp + +/** + * This class implements a time-discrete 2nd order low-pass filter for a series of data values. + * This filter can typically be used within a periodic task that takes measurements that need + * to be filtered, like speed or position values. + */ +class LowpassFilter { + + public: + + LowpassFilter(); + virtual ~LowpassFilter(); + void reset(); + void reset(float value); + void setPeriod(float period); + void setFrequency(float frequency); + float getFrequency(); + float filter(float value); + + private: + + float period; + float frequency; + float a11, a12, a21, a22, b1, b2; + float x1, x2; +}; + +#endif