Skip to content

Arduino Finite Impulse Response and Infinite Impulse Response filter implementations.

License

Notifications You must be signed in to change notification settings

bhupiister/Arduino-Filters

 
 

Repository files navigation

Build Status Test Coverage Build Status GitHub

Arduino Filters

Features

  • Infinite Impulse Response Filters
  • Finite Impulse Response Filters
  • BiQuad Filters
  • Butterworth Filters
  • Notch Filters
  • Median Filters
  • Simple and Exponential Moving Average Filters
  • Hysteresis

These filters were originally part of the old Filters library.
It has been updated completely, with continuous integration, unit tests, etc.

Documentation

The automatically generated Doxygen documentation for this library can be found here:
Documentation
Test coverage information can be found here:
Code Coverage
Arduino examples can be found here:
Examples

You might want to start with the Filters Module.

Example: Butterworth filter

#include <Filters.h>

#include <AH/Timing/MillisMicrosTimer.hpp>
#include <Filters/Butterworth.hpp>

void setup() {
  Serial.begin(115200);
}

// Sampling frequency
const double f_s = 100; // Hz
// Cut-off frequency (-3 dB)
const double f_c = 40; // Hz
// Normalized cut-off frequency
const double f_n = 2 * f_c / f_s;

// Sample timer
Timer<micros> timer = std::round(1e6 / f_s);

// Sixth-order Butterworth filter
auto filter = butter<6>(f_n);

void loop() {
  if (timer)
    Serial.println(filter(analogRead(A0)));
}

Tools

The python folder contains some Python scripts to visualize the frequency response of the filters used in the examples.

Butterworth Filter

Butterworth.ino

FIR Notch Filter

FIRNotch.ino

Related Projects

This library uses the Arduino Helpers utility library

Supported boards

For each commit, the continuous integration tests compile the examples for the following boards:

  • Arduino UNO
  • Arduino Leonardo
  • Teensy 3.2
  • Arduino Due
  • Arduino Nano 33 IoT
  • ESP8266
  • ESP32

This covers a very large part of the Arduino platform, and similar boards will also work (e.g. Arduino Nano, Arduino Mega, etc.).

If you have a board that's not supported, please open an issue and let me know!

Known limitations

The Arduino Due toolchain provided by Arduino is very old, and has some configuration problems. As a result, some math functions are not available.
There is nothing I can do about it in this library, it's a bug in the Arduino Due Core.

About

Arduino Finite Impulse Response and Infinite Impulse Response filter implementations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 97.2%
  • Python 0.8%
  • C 0.8%
  • CSS 0.5%
  • CMake 0.3%
  • Shell 0.3%
  • HTML 0.1%