Marco Oehler / Mbed 2 deprecated ROME2

Dependencies:   mbed

Committer:
oehlemar
Date:
Mon Feb 24 16:05:50 2020 +0000
Revision:
0:7ee4c6416e08
ROME2 P1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
oehlemar 0:7ee4c6416e08 1 /*
oehlemar 0:7ee4c6416e08 2 * LowpassFilter.h
oehlemar 0:7ee4c6416e08 3 * Copyright (c) 2020, ZHAW
oehlemar 0:7ee4c6416e08 4 * All rights reserved.
oehlemar 0:7ee4c6416e08 5 */
oehlemar 0:7ee4c6416e08 6
oehlemar 0:7ee4c6416e08 7 #ifndef LOWPASS_FILTER_H_
oehlemar 0:7ee4c6416e08 8 #define LOWPASS_FILTER_H_
oehlemar 0:7ee4c6416e08 9
oehlemar 0:7ee4c6416e08 10 #include <cstdlib>
oehlemar 0:7ee4c6416e08 11
oehlemar 0:7ee4c6416e08 12 /**
oehlemar 0:7ee4c6416e08 13 * This class implements a time-discrete 2nd order lowpass filter for a series of data values.
oehlemar 0:7ee4c6416e08 14 * This filter can typically be used within a periodic task that takes measurements that need
oehlemar 0:7ee4c6416e08 15 * to be filtered, like speed or position values.
oehlemar 0:7ee4c6416e08 16 */
oehlemar 0:7ee4c6416e08 17 class LowpassFilter {
oehlemar 0:7ee4c6416e08 18
oehlemar 0:7ee4c6416e08 19 public:
oehlemar 0:7ee4c6416e08 20
oehlemar 0:7ee4c6416e08 21 LowpassFilter();
oehlemar 0:7ee4c6416e08 22 virtual ~LowpassFilter();
oehlemar 0:7ee4c6416e08 23 void reset();
oehlemar 0:7ee4c6416e08 24 void reset(float value);
oehlemar 0:7ee4c6416e08 25 void setPeriod(float period);
oehlemar 0:7ee4c6416e08 26 void setFrequency(float frequency);
oehlemar 0:7ee4c6416e08 27 float getFrequency();
oehlemar 0:7ee4c6416e08 28 float filter(float value);
oehlemar 0:7ee4c6416e08 29
oehlemar 0:7ee4c6416e08 30 private:
oehlemar 0:7ee4c6416e08 31
oehlemar 0:7ee4c6416e08 32 float period;
oehlemar 0:7ee4c6416e08 33 float frequency;
oehlemar 0:7ee4c6416e08 34 float a11, a12, a21, a22, b1, b2;
oehlemar 0:7ee4c6416e08 35 float x1, x2;
oehlemar 0:7ee4c6416e08 36 };
oehlemar 0:7ee4c6416e08 37
oehlemar 0:7ee4c6416e08 38 #endif /* LOWPASS_FILTER_H_ */
oehlemar 0:7ee4c6416e08 39