![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
xx
Fork of PES1 by
EncoderCounter/LowpassFilter.h@18:6547e54ac803, 2017-05-09 (annotated)
- Committer:
- itslinear
- Date:
- Tue May 09 13:21:49 2017 +0000
- Revision:
- 18:6547e54ac803
f?r holdi;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
itslinear | 18:6547e54ac803 | 1 | /* |
itslinear | 18:6547e54ac803 | 2 | * LowpassFilter.h |
itslinear | 18:6547e54ac803 | 3 | * Copyright (c) 2016, ZHAW |
itslinear | 18:6547e54ac803 | 4 | * All rights reserved. |
itslinear | 18:6547e54ac803 | 5 | */ |
itslinear | 18:6547e54ac803 | 6 | |
itslinear | 18:6547e54ac803 | 7 | #ifndef LOWPASS_FILTER_H_ |
itslinear | 18:6547e54ac803 | 8 | #define LOWPASS_FILTER_H_ |
itslinear | 18:6547e54ac803 | 9 | |
itslinear | 18:6547e54ac803 | 10 | #include <cstdlib> |
itslinear | 18:6547e54ac803 | 11 | #include <cmath> |
itslinear | 18:6547e54ac803 | 12 | |
itslinear | 18:6547e54ac803 | 13 | /** |
itslinear | 18:6547e54ac803 | 14 | * This class implements a time-discrete 2nd order low-pass filter for a series of data values. |
itslinear | 18:6547e54ac803 | 15 | * This filter can typically be used within a periodic task that takes measurements that need |
itslinear | 18:6547e54ac803 | 16 | * to be filtered, like speed or position values. |
itslinear | 18:6547e54ac803 | 17 | */ |
itslinear | 18:6547e54ac803 | 18 | class LowpassFilter { |
itslinear | 18:6547e54ac803 | 19 | |
itslinear | 18:6547e54ac803 | 20 | public: |
itslinear | 18:6547e54ac803 | 21 | |
itslinear | 18:6547e54ac803 | 22 | LowpassFilter(); |
itslinear | 18:6547e54ac803 | 23 | virtual ~LowpassFilter(); |
itslinear | 18:6547e54ac803 | 24 | void reset(); |
itslinear | 18:6547e54ac803 | 25 | void reset(float value); |
itslinear | 18:6547e54ac803 | 26 | void setPeriod(float period); |
itslinear | 18:6547e54ac803 | 27 | void setFrequency(float frequency); |
itslinear | 18:6547e54ac803 | 28 | float getFrequency(); |
itslinear | 18:6547e54ac803 | 29 | float filter(float value); |
itslinear | 18:6547e54ac803 | 30 | |
itslinear | 18:6547e54ac803 | 31 | private: |
itslinear | 18:6547e54ac803 | 32 | |
itslinear | 18:6547e54ac803 | 33 | float period; |
itslinear | 18:6547e54ac803 | 34 | float frequency; |
itslinear | 18:6547e54ac803 | 35 | float a11, a12, a21, a22, b1, b2; |
itslinear | 18:6547e54ac803 | 36 | float x1, x2; |
itslinear | 18:6547e54ac803 | 37 | }; |
itslinear | 18:6547e54ac803 | 38 | |
itslinear | 18:6547e54ac803 | 39 | #endif /* LOWPASS_FILTER_H_ */ |