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