Algorithmus

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LowpassFilter.h Source File

LowpassFilter.h

00001 /*
00002  * LowpassFilter.h
00003  * Copyright (c) 2018, ZHAW
00004  * All rights reserved.
00005  */
00006 
00007 #ifndef LOWPASS_FILTER_H_
00008 #define LOWPASS_FILTER_H_
00009 
00010 #include <cstdlib>
00011 
00012 /**
00013  * This class implements a time-discrete 2nd order lowpass filter for a series of data values.
00014  * This filter can typically be used within a periodic task that takes measurements that need
00015  * to be filtered, like speed or position values.
00016  */
00017 class LowpassFilter {
00018     
00019     public:
00020     
00021                 LowpassFilter();
00022         virtual ~LowpassFilter();
00023         void    reset();
00024         void    reset(float value);
00025         void    setPeriod(float period);
00026         void    setFrequency(float frequency);
00027         float   getFrequency();
00028         float   filter(float value);
00029         
00030     private:
00031         
00032         float   period;
00033         float   frequency;
00034         float   a11, a12, a21, a22, b1, b2;
00035         float   x1, x2;
00036 };
00037 
00038 #endif /* LOWPASS_FILTER_H_ */