Filter library test

Or do you know other, maybe more accurate methods to test the filters?

I'd create a big array, 256 or 512 values to store results of the filtering. Like in your initial setup, you feed a sinewave, arduino filterring data and store them to an array. You printing results by request whenever you change input, or like to observe a process.

I checked a library, and author's copy has this:

  if(_order==2) {                                 //ripple -1dB
    _v[0] = _v[1];
    _v[1] = _v[2];
    long tmp = ((((data * 662828L) >>  4)         //= (    7.901529699e-2 * x)
      + ((_v[0] * -540791L) >> 1)                 //+( -0.5157387562*v[0])
      + (_v[1] * 628977L)                         //+(  1.1996775682*v[1])
      )+262144) >> 19;                            // round and downshift fixed point /524288

    _v[2]= (int)tmp;
    return (int)((
      (_v[0] + _v[2])
      +2 * _v[1]));                               // 2^
  }

As you can see, slow float math replaced by integer approximation.
You says:

Then I opened “SignalFilter.cpp” and substitute the Chebyshev Filter of 2nd Order with my new Filter code:
Code:
if(_order==2) {
_v[0] = _v[1];
_v[1] = _v[2];
_v[2] = (4.153748378268e-1 * data)

  • ( -0.4501779675 * _v[0])
  • ( -0.2113213838 * _v[1]);
    return
    (_v[0] + _v[2])
    +2 * _v[1];
    }

Is it code you are testing?