Marco Oehler / Mbed 2 deprecated Lab2

Dependencies:   mbed

Committer:
oehlemar
Date:
Mon Mar 09 16:23:04 2020 +0000
Revision:
0:1a972ed770da
LAB2

Who changed what in which revision?

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