I am trying to implement a butterworth bandpass filter
My filter requirement is Fs= 500Hz, Fc1=0.4Hz, Fc2=4Hz, Oreder=2.
Below is the code which is implemented on 16bit-mcu and is called for every new sample
The coefficients are calculated from http://www-users.cs.york.ac.uk/~fisher/mkfilter
static int32_t xv[4+1], yv[4+1];
int32_t my_filter(int32_t sample)
{
xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4];
xv[4] = sample / 1.989695029e+03;
yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4];
yv[4] = (xv[0] + xv[4]) - 2 * xv[2]
+ ( -0.9380260977 * yv[0]) + ( 3.8116138294 * yv[1])
+ ( -5.8091337665 * yv[2]) + ( 3.9355459731 * yv[3]);
return yv[4];
}
This is the output of code What i want is output similar to scipy_filter.