Implements a simple leaky integrator integer value filter, handy for fast, simple, ADC output filtering. Implemented as described here: [[http://ece124web.groups.et.byu.net/references/readings/Simple%20Software%20Lowpass%20Filter.pdf|Simple Software Lowpass Filter.pdf]]
Dependents: AVC_20110423 WallBot_Simple AVC_2012
SimpleFilter.h
00001 /** SimpleFilter implements a simple low pass integer "leaky integrator" described here: 00002 * 00003 * http://ece124web.groups.et.byu.net/references/readings/Simple%20Software%20Lowpass%20Filter.pdf 00004 * 00005 * Well suited for filtering ADC integer values very quickly 00006 * 00007 * Michael Shimniok http://bot-thoughts.com/ 00008 */ 00009 class SimpleFilter { 00010 public: 00011 /** Creates a new filter object 00012 * 00013 * @param shift: the number of shifts to perform at each filtering input step; lower means higher bandwidth 00014 */ 00015 SimpleFilter(short shift); 00016 00017 /** Supplies input to the filter and returns filtered output value 00018 * 00019 * @param value is the input value to the filter, e.g., some measurement 00020 * @returns the filtered output value 00021 */ 00022 short filter(short value); 00023 00024 /** Read the current value in the filter 00025 * 00026 * @returns the current value in the filter 00027 */ 00028 short value(void); 00029 00030 /** Shorthand operator for value() 00031 * 00032 * @returns the current value in the filter 00033 */ 00034 operator short() { return value(); } 00035 00036 private: 00037 long _filter_value; 00038 short _shift; 00039 };
Generated on Wed Jul 13 2022 18:05:52 by
