This is a simple implementation of a FIR filter i made for real time proccessing on an STM32F103C8, as it lacks a floating point unit it had to be implemented using only integer arithmetics in order to maximize performance.
The library defines a FIR_t
object which can be created dynamicaly by an
initialization funcion
//Coefficents
float coeffs[N] = {...};
int main(){
FIR_t * filter;
filt = initFilter(&coeffs,N,xMax); // Coefficents, Order of the Filter (TAPS), Upper bounding for Signal
while(1){
int x = readSignal();
x = filter(filt,x); // Returns filtered signal with a delay of N samples
}
deInitFilter(filt);
return 1;
}
The following signal was filtered using this library, take in mind that there is still a quatization noise due to the lack of resolution of the adc at the range of the input signal.
Pre-Filtering | After-Filtering |
---|---|
![]() |
![]() |
I recommend to use the awesome work by Christian Münker with his pyfda, aswell as to read a bit about how filters really work, (Laplace/Z-Transform/Transfer-Functions...)