![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Totale Testversion
Dependencies: mbed
Fork of DrehungMitStopp by
LowpassFilter.h@5:24350e6fc9d7, 2017-05-21 (annotated)
- Committer:
- freunjor
- Date:
- Sun May 21 15:29:46 2017 +0000
- Revision:
- 5:24350e6fc9d7
- Parent:
- 1:d40ff07e2fe0
mainmix_1 pro min;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EHess | 1:d40ff07e2fe0 | 1 | #ifndef LOWPASS_FILTER_H_ |
EHess | 1:d40ff07e2fe0 | 2 | #define LOWPASS_FILTER_H_ |
EHess | 1:d40ff07e2fe0 | 3 | |
EHess | 1:d40ff07e2fe0 | 4 | #include <cstdlib> |
EHess | 1:d40ff07e2fe0 | 5 | #include <cmath> |
EHess | 1:d40ff07e2fe0 | 6 | |
EHess | 1:d40ff07e2fe0 | 7 | //E. Hess |
EHess | 1:d40ff07e2fe0 | 8 | //LowpassFilter.cpp |
EHess | 1:d40ff07e2fe0 | 9 | |
EHess | 1:d40ff07e2fe0 | 10 | /** |
EHess | 1:d40ff07e2fe0 | 11 | * This class implements a time-discrete 2nd order low-pass filter for a series of data values. |
EHess | 1:d40ff07e2fe0 | 12 | * This filter can typically be used within a periodic task that takes measurements that need |
EHess | 1:d40ff07e2fe0 | 13 | * to be filtered, like speed or position values. |
EHess | 1:d40ff07e2fe0 | 14 | */ |
EHess | 1:d40ff07e2fe0 | 15 | class LowpassFilter { |
EHess | 1:d40ff07e2fe0 | 16 | |
EHess | 1:d40ff07e2fe0 | 17 | public: |
EHess | 1:d40ff07e2fe0 | 18 | |
EHess | 1:d40ff07e2fe0 | 19 | LowpassFilter(); |
EHess | 1:d40ff07e2fe0 | 20 | virtual ~LowpassFilter(); |
EHess | 1:d40ff07e2fe0 | 21 | void reset(); |
EHess | 1:d40ff07e2fe0 | 22 | void reset(float value); |
EHess | 1:d40ff07e2fe0 | 23 | void setPeriod(float period); |
EHess | 1:d40ff07e2fe0 | 24 | void setFrequency(float frequency); |
EHess | 1:d40ff07e2fe0 | 25 | float getFrequency(); |
EHess | 1:d40ff07e2fe0 | 26 | float filter(float value); |
EHess | 1:d40ff07e2fe0 | 27 | |
EHess | 1:d40ff07e2fe0 | 28 | private: |
EHess | 1:d40ff07e2fe0 | 29 | |
EHess | 1:d40ff07e2fe0 | 30 | float period; |
EHess | 1:d40ff07e2fe0 | 31 | float frequency; |
EHess | 1:d40ff07e2fe0 | 32 | float a11, a12, a21, a22, b1, b2; |
EHess | 1:d40ff07e2fe0 | 33 | float x1, x2; |
EHess | 1:d40ff07e2fe0 | 34 | }; |
EHess | 1:d40ff07e2fe0 | 35 | |
EHess | 1:d40ff07e2fe0 | 36 | #endif |