Filters for sensor

Hello dear Arduino community,

I would like to test a Butterworth filter which I found from the gitHub-Website (Link) with my sensor, but unfortunately when I compile the code the following error occurs:

AH/Timing/MillisMicrosTimer.hpp: No such file or directory

I have already downloaded the zip.file and installed it manually as library, but the same error occurs.

Here is the example Butterworth code:

/**
 * Example of Butterworth filter.
 * 
 * @boards  AVR, AVR USB, Nano 33 IoT, Nano 33 BLE, Due, Teensy 3.x, ESP8266, ESP32
 * 
 * @see <https://tttapa.github.io/Pages/Mathematics/Systems-and-Control-Theory/Analog-Filters/Butterworth-Filters.html>
 * 
 * Written by PieterP, 2019-11-12  
 * https://github.com/tttapa/Arduino-Filters
 */

#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 = 25; // 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)));
}

Thank you very much for your time and help in advance

Best regards

Kosta

Why not use the micros() timer built in to Arduino?

Hello jremington,

how would the micros() timer built in help me with the Butterworth filter? And if it can help me, where can I find in Arduino IDE?

Best regards

Kosta

unsigned long start = micros();
... code to be timed ...
Serial.println(micros() - start);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.