Go Down

Topic: filter library (Read 11 times) previous topic - next topic


I did some filter design scripts  :smiley-sweat: which could come in handy for (y)our measurements.
It covers for now some IIR filters with Butterworth, Chebyshev, Bessel characteristics (1st order and up to an exaggerate 5th order). Furthermore you will find Resonance and Proportional Integral filters. All pass types are present (low, high, band, stop, all). It will generate classes for floating point or integer calculation.

if you are interested check it out here: http://www.schwietering.com/jayduino/filtuino/

Comments and bug reports are welcome. If you find them useful, drop me a line, so I just know that I did something useful for others  ;)


Nice work, bit for those not familiar with this theory (like myself) could you provide links to some background info, or provide a playground article?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Nice work, bit for those not familiar with this theory (like myself) could you provide links to some background info, or provide a playground article?

Natuurlijk. Best would be to provide some info where I do actually need them, or where typical applications are in microcontroller projects.

There is a lot of info about filters on wiki, but that is pretty toughhttp://en.wikipedia.org/wiki/Digital_filter. A nice tutorial but in the field of Audio you find here: https://ccrma.stanford.edu/~jos/filters/filters.html.

The more practical approach:
For cleaning sensor data I used Bandpass and Lowpass filters, so the higher frequency fluctuations are reduced.
For such a purpose you can use: 1st order, Bessel or Chebyshev, Lowpass or Bandpass filters.
A Bandpass filter would also get rid of the DC that you might have in a sensorvalue without need of calibrating (i.e. in calm state, you have +2V, with a signal more or less, the bandpass will give you positive and negative values around).

For musical applications (bit tough on the Arduino because of the max Samplerate), you would use Butterworth filters as they will distort less the useful frequencies.

For myself I use them to convert Vibrations measured with an optical sensor where I am interested in the mean frequency of the vibration (which is 1 stable frequency) but I want to avoid upper harmonics of the vibration. i.e. the vibrations are 100Hz, my samplingrate is 2Khz, the first harmonic would be 200Hz which I am not interested in. In the filter design I will use the samplingrates I stated (2000Hz), use the same frequencies for low and high (100Hz) and using a Bandpass filter. This pretty much cleans the signal and just by doing an average over the sampleperiod (10msecs) I get a perfect reading without adding weird math.

Another typical application would be to get rid of 50/60Hz in sensor readings caused by power supply which you could not avoid by using electrical filters (i.e. optical sensors in an ambient with artificial light). In this case you use a Bandstop using the 50Hz (Europe) or 60Hz (US) as frequencies and the sampling rate of your readings (which must be > 100Hz actually).

Furthermore, the Proportional Integral Filters are widely used in process control where something does not respond quickly to your input (steering a ship for example), so if you have a gyro you would use such a filter to avoid 'over-reacting', see also here http://en.wikipedia.org/wiki/PID_controller.



That is very nice work. Congratulations.

I don't suppose you could be coaxed into adding a graph showing the frequency response?  ;)

The Aussie Shield: breakout all 28 pins to quick-connect terminals


coaxed into adding a graph showing the frequency response?

I had some thoughts about it. What I am actually interested in is not a graph of the theoretical response (you can find  in the net) but a simulation of the calculation, so I can see if the integer calculation optimizations are ok for the kind of signals I got. But looks like pretty much work!  :smiley-sweat:

Go Up