Libary for PM2.
Dependencies: LSM9DS1 RangeFinder FastPWM
Dependents: PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board ... more
LowpassFilter.h@32:bb074bb17d39, 2022-06-22 (annotated)
- Committer:
- pmic
- Date:
- Wed Jun 22 14:05:13 2022 +0000
- Revision:
- 32:bb074bb17d39
- Parent:
- 4:9c003c402033
Updated SensorBar so it is not blocking the program if it is not connected
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pmic | 0:86129f1b4a93 | 1 | /* |
| pmic | 0:86129f1b4a93 | 2 | * LowpassFilter.h |
| pmic | 0:86129f1b4a93 | 3 | * Copyright (c) 2018, ZHAW |
| pmic | 0:86129f1b4a93 | 4 | * All rights reserved. |
| pmic | 0:86129f1b4a93 | 5 | */ |
| pmic | 0:86129f1b4a93 | 6 | |
| pmic | 0:86129f1b4a93 | 7 | #ifndef LOWPASS_FILTER_H_ |
| pmic | 0:86129f1b4a93 | 8 | #define LOWPASS_FILTER_H_ |
| pmic | 0:86129f1b4a93 | 9 | |
| pmic | 0:86129f1b4a93 | 10 | #include <cstdlib> |
| pmic | 0:86129f1b4a93 | 11 | |
| pmic | 0:86129f1b4a93 | 12 | /** |
| pmic | 0:86129f1b4a93 | 13 | * This class implements a time-discrete 2nd order lowpass filter for a series of data values. |
| pmic | 0:86129f1b4a93 | 14 | * This filter can typically be used within a periodic task that takes measurements that need |
| pmic | 0:86129f1b4a93 | 15 | * to be filtered, like speed or position values. |
| pmic | 0:86129f1b4a93 | 16 | */ |
| pmic | 4:9c003c402033 | 17 | class LowpassFilter |
| pmic | 4:9c003c402033 | 18 | { |
| pmic | 4:9c003c402033 | 19 | |
| pmic | 4:9c003c402033 | 20 | public: |
| pmic | 4:9c003c402033 | 21 | |
| pmic | 4:9c003c402033 | 22 | LowpassFilter(); |
| pmic | 4:9c003c402033 | 23 | virtual ~LowpassFilter(); |
| pmic | 4:9c003c402033 | 24 | void reset(); |
| pmic | 4:9c003c402033 | 25 | void reset(float value); |
| pmic | 4:9c003c402033 | 26 | void setPeriod(float period); |
| pmic | 4:9c003c402033 | 27 | void setFrequency(float frequency); |
| pmic | 4:9c003c402033 | 28 | float getFrequency(); |
| pmic | 4:9c003c402033 | 29 | float filter(float value); |
| pmic | 4:9c003c402033 | 30 | |
| pmic | 4:9c003c402033 | 31 | private: |
| pmic | 4:9c003c402033 | 32 | |
| pmic | 4:9c003c402033 | 33 | float period; |
| pmic | 4:9c003c402033 | 34 | float frequency; |
| pmic | 4:9c003c402033 | 35 | float a11, a12, a21, a22, b1, b2; |
| pmic | 4:9c003c402033 | 36 | float x1, x2; |
| pmic | 0:86129f1b4a93 | 37 | }; |
| pmic | 0:86129f1b4a93 | 38 | |
| pmic | 0:86129f1b4a93 | 39 | #endif /* LOWPASS_FILTER_H_ */ |
| pmic | 0:86129f1b4a93 | 40 | |
| pmic | 0:86129f1b4a93 | 41 |
