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@0:ac15e38daeb5, 2011-04-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Apr 20 08:00:25 2011 +0000
- Revision:
- 0:ac15e38daeb5
- Child:
- 1:70348515ed2f
Initial release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:ac15e38daeb5 | 1 | /** SimpleFilter implements a simple low pass integer "leaky integrator" described here: |
shimniok | 0:ac15e38daeb5 | 2 | * |
shimniok | 0:ac15e38daeb5 | 3 | * http://ece124web.groups.et.byu.net/references/readings/Simple%20Software%20Lowpass%20Filter.pdf |
shimniok | 0:ac15e38daeb5 | 4 | * |
shimniok | 0:ac15e38daeb5 | 5 | * Well suited for filtering ADC integer values very quickly |
shimniok | 0:ac15e38daeb5 | 6 | * |
shimniok | 0:ac15e38daeb5 | 7 | * Michael Shimniok http://bot-thoughts.com/ |
shimniok | 0:ac15e38daeb5 | 8 | */ |
shimniok | 0:ac15e38daeb5 | 9 | class SimpleFilter { |
shimniok | 0:ac15e38daeb5 | 10 | public: |
shimniok | 0:ac15e38daeb5 | 11 | /** Creates a new filter object |
shimniok | 0:ac15e38daeb5 | 12 | * |
shimniok | 0:ac15e38daeb5 | 13 | * @param shift: the number of shifts to perform at each filtering input step; lower means higher bandwidth |
shimniok | 0:ac15e38daeb5 | 14 | */ |
shimniok | 0:ac15e38daeb5 | 15 | SimpleFilter(short shift); |
shimniok | 0:ac15e38daeb5 | 16 | |
shimniok | 0:ac15e38daeb5 | 17 | /** Supplies input to the filter and returns filtered output value |
shimniok | 0:ac15e38daeb5 | 18 | * |
shimniok | 0:ac15e38daeb5 | 19 | * @param value is the input value to the filter, e.g., some measurement |
shimniok | 0:ac15e38daeb5 | 20 | * @returns the filtered output value |
shimniok | 0:ac15e38daeb5 | 21 | */ |
shimniok | 0:ac15e38daeb5 | 22 | short filter(short value); |
shimniok | 0:ac15e38daeb5 | 23 | |
shimniok | 0:ac15e38daeb5 | 24 | private: |
shimniok | 0:ac15e38daeb5 | 25 | long _filter_value; |
shimniok | 0:ac15e38daeb5 | 26 | short _shift; |
shimniok | 0:ac15e38daeb5 | 27 | }; |