ggg
LowpassFilter.h@0:df3d4b033d11, 2019-02-27 (annotated)
- Committer:
- cittecla
- Date:
- Wed Feb 27 15:14:27 2019 +0000
- Revision:
- 0:df3d4b033d11
P1 finished
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cittecla | 0:df3d4b033d11 | 1 | /* |
cittecla | 0:df3d4b033d11 | 2 | * LowpassFilter.h |
cittecla | 0:df3d4b033d11 | 3 | * Copyright (c) 2019, ZHAW |
cittecla | 0:df3d4b033d11 | 4 | * All rights reserved. |
cittecla | 0:df3d4b033d11 | 5 | */ |
cittecla | 0:df3d4b033d11 | 6 | |
cittecla | 0:df3d4b033d11 | 7 | #ifndef LOWPASS_FILTER_H_ |
cittecla | 0:df3d4b033d11 | 8 | #define LOWPASS_FILTER_H_ |
cittecla | 0:df3d4b033d11 | 9 | |
cittecla | 0:df3d4b033d11 | 10 | #include <cstdlib> |
cittecla | 0:df3d4b033d11 | 11 | |
cittecla | 0:df3d4b033d11 | 12 | /** |
cittecla | 0:df3d4b033d11 | 13 | * This class implements a time-discrete 2nd order lowpass filter for a series of data values. |
cittecla | 0:df3d4b033d11 | 14 | * This filter can typically be used within a periodic task that takes measurements that need |
cittecla | 0:df3d4b033d11 | 15 | * to be filtered, like speed or position values. |
cittecla | 0:df3d4b033d11 | 16 | */ |
cittecla | 0:df3d4b033d11 | 17 | class LowpassFilter { |
cittecla | 0:df3d4b033d11 | 18 | |
cittecla | 0:df3d4b033d11 | 19 | public: |
cittecla | 0:df3d4b033d11 | 20 | |
cittecla | 0:df3d4b033d11 | 21 | LowpassFilter(); |
cittecla | 0:df3d4b033d11 | 22 | virtual ~LowpassFilter(); |
cittecla | 0:df3d4b033d11 | 23 | void reset(); |
cittecla | 0:df3d4b033d11 | 24 | void reset(float value); |
cittecla | 0:df3d4b033d11 | 25 | void setPeriod(float period); |
cittecla | 0:df3d4b033d11 | 26 | void setFrequency(float frequency); |
cittecla | 0:df3d4b033d11 | 27 | float getFrequency(); |
cittecla | 0:df3d4b033d11 | 28 | float filter(float value); |
cittecla | 0:df3d4b033d11 | 29 | |
cittecla | 0:df3d4b033d11 | 30 | private: |
cittecla | 0:df3d4b033d11 | 31 | |
cittecla | 0:df3d4b033d11 | 32 | float period; |
cittecla | 0:df3d4b033d11 | 33 | float frequency; |
cittecla | 0:df3d4b033d11 | 34 | float a11, a12, a21, a22, b1, b2; |
cittecla | 0:df3d4b033d11 | 35 | float x1, x2; |
cittecla | 0:df3d4b033d11 | 36 | }; |
cittecla | 0:df3d4b033d11 | 37 | |
cittecla | 0:df3d4b033d11 | 38 | #endif /* LOWPASS_FILTER_H_ */ |