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