Compiling error t filter

Hi
I'm trying to to use t filter
http://t-filter.engineerjs.com/
, it generate two files, SampleFilter.c and SampleFilter.h , and i have compiling error ;
fatal error: SampleFilter.h: No such file or directory

I pasted SampleFilter.c to Arduino IDE

#include "SampleFilter.h"

static double filter_taps[SAMPLEFILTER_TAP_NUM] = {
  -4.4408920985006264e-17,
  4.4408920985006264e-17,
  1,
  4.4408920985006264e-17,
  -4.4408920985006264e-17
};

void SampleFilter_init(SampleFilter* f) {
  int i;
  for(i = 0; i < SAMPLEFILTER_TAP_NUM; ++i)
    f->history[i] = 0;
  f->last_index = 0;
}

void SampleFilter_put(SampleFilter* f, double input) {
  f->history[f->last_index++] = input;
  if(f->last_index == SAMPLEFILTER_TAP_NUM)
    f->last_index = 0;
}

double SampleFilter_get(SampleFilter* f) {
  double acc = 0;
  int index = f->last_index, i;
  for(i = 0; i < SAMPLEFILTER_TAP_NUM; ++i) {
    index = index != 0 ? index-1 : SAMPLEFILTER_TAP_NUM-1;
    acc += f->history[index] * filter_taps[i];
  };
  return acc;
}

and added SampleFilter.h file


t filter adding 2

in the directory t_filter_2 you should have three files
t_filter_2.ino
SampleFilter.h
SampleFilter.c

try closing the IDE and click on t_filter_2.ino to reopen
the IDE should then show the three files and be able to find the header file

I did this way - 3 files marked in red, and I have an error

Hello tom321

SimpleFilter.h != Sample.Filter.h
Check spelling.

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

I corrected spelling = error still the same
SampleFilter.h: No such file or directory

I created three files and it compiles and links OK

I did with the same name as yours


I got this message once
t filter error

I hope you are not trying to run this code on an AVR-based Arduino, like the Uno, Mega, etc. They don't support the double data type and given the magnitudes of the coefficients below, the filter won't work at all.

In any case, the coefficients seem utterly useless. What sort of filter are you trying to produce?

40 Hz low pass filter for stm32f103

Judging from the coefficients, that is not a low pass filter. In fact it doesn't do much of anything.

first I want to make any filter then 40Hz

There are plenty of Arduino filter tutorials on line. Here is one example: https://www.norwegiancreations.com/2016/03/arduino-tutorial-simple-high-pass-band-pass-and-band-stop-filtering/

Here is a 40 Hz low pass filter, designed using the calculator you picked:

I have a directory with three files
SampleFilter2

IDE displays

.ino file

#include "SampleFilter.h"

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

void loop() {
}

SampleFilter.cpp

#include "SampleFilter.h"

void filter(void){
  Serial.println("in filter");
}

SampleFilter.h

#include <Arduino.h>

void filter(void);

when run the serial monitor displays

in filter

I created SampleFilter.h in H format but don't know how to create SampleFilter.cpp in C++ format

I just created the files using notepad and renamed them .h and .cpp
if you have a .c file rename to .cpp

I suspect this is Windows giving you trouble. I suspect your "SampleFilter.h" file is actually named "SampleFilter.h.ino". Can you turn on the "show file extensions" option? For some illogical reason, Microsoft still thinks it's a good idea to hide file extensions by default.

did not think of that! I tick 'View>File Name extensions' as soon as I get a new system

I did it, I changed this line
#include "SampleFilter.h"
//#include <SampleFilter.h> = old
in cpp

Thanks, later I will work with setup and loop

This is my 20 Hz low pass filter


and actual response to 1 Hz to 80 Hz signal

There is no band pass filter effect , should be 55 dB attenuation

#include "SampleFilter.h"
int sensorPin = 0;    //A0, pin number to use the ADC
int sensorValue = 0;


/////////////
float EMA_a = 0.3;    //initialization of EMA alpha
int EMA_S = 0;        //initialization of EMA S
////////////


void setup() {
  Serial.begin(115200);
  EMA_S = analogRead(sensorPin);
}

void loop() {
  sensorValue = analogRead(sensorPin);              //read the sensor value using ADC
  EMA_S = (EMA_a * sensorValue) + ((1 - EMA_a) * EMA_S); //run the EMA

  Serial.print( sensorValue);
  Serial.print("  Low Pass Filter ");
  Serial.print(" ");
  Serial.println(   EMA_S + 10);

  delay(20);
}

This looks like a very low resolution signal (like +/- 10 steps), so your filtered signal will be low resolution too. What happens if you also make EMA_S a float?