Hello,
I am trying to implement a 60kHz bandpass filter in a STM32F407 microcontroller with the help of the CMSIS DSP Library, and unfortunately I am having a bit of trouble... I am wondering if someone here might know what I might be doing wrong. I've attached two pdfs one where it shows the 60kHz sine input that is sampled 4500 times at the sampling r ate of 5.25MSPS, the second pdf shows the output of the filter and as you might see it is completely off so I am obviously doing something wrong...
I've attached the code that I've written for the filter and the filter co-efficents that is used. The filter co-efficents are generated with the MATLAB fdatool and I've also attached a MATLAB script for simulating the filter.
The picture above is the plot of the filter co-efficents, I used the fdatool to generate 16-bit unsigned integer co-efficents because the MCU is using a 12-bit ADC which I then just read as 16-bit unsigned integers, which I then forward to the arm_fir_q15 function.
I've looked at some examples online and I can't figure out what I am doing so wrong. Is there something I'm missing or what?
Well for starters I can tell you're doing this all in unsigned ints rather than Q15. They are different data types. Q15 is a signed integer, with an imaginary decimal place after the most significant bit. In other words, it has 1 integer bit, and 15 fractional bits. The range of acceptable values for Q15 is [-1,1), which is represented by [0x8000, 0x7FFF]. Spend a little bit of time researching that, and adapting your code to Q15 and you'll probably figure it out.
Cheers,
Dan