a

Dependencies:   mbed

Committer:
beacon
Date:
Mon May 22 10:45:28 2017 +0000
Revision:
0:dfea4e0e064b
k

Who changed what in which revision?

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