This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using CMSIS DSP Function: arm_fir_f32 - Correct Use?

Hi All;

I have some questions about correct use of the CMSIS DSP library call arm_fir_32. First, I'll provide some background about what I am doing and what the setup is.

I have a STM32F4 Discovery board, using IAR EWARM for programming. Just for testing purposes, I'm generating a low frequency test signal at 40Hz and feeding it into one of the ADC inputs. The signal is biased to swing from 0 to about 2.5Vpp. The signal has a low to moderate amount of broadband noise - but at this point I am not purposely mixing or introducing any other signals with it. There is a timer interrupt set to sample frequency of 2KHz, with a sampling buffer of 2048 samples.

I have already tested and am using the FFT function arm_cfft_f32, and can accurately determine (track) the frequency of the incoming signal when I change it at the source.  This seems to be working well.

Now, I would like to use the arm_fir_32 filter. To do this, I started out reading the documentation from CMSIS on the function. To implement a FIR low pass, to generate the tap coefficients, I am using this website's only tool to do so.

I generated a 4th order filter, and set the sampling rate the same as my software, with a cutoff of 60Hz. I forced generation to 24 taps to be even. So the BLOCK_SIZE is 32, and the number of blocks is 1024/32 = 32.

Following the example from CMSIS  on this function, I believe I've set up correctly. So the chain looks like this:

ADC --> FIR --> FFT

However, I'm not getting the result I would expect. The values returned from the FFT's output buffer are exponentially large (not this way if I comment out /circumvent the FIR calls). This leads me to believe I am missing a step. Do I need to normalize the values? I thought that because I input the rate into the FIR function setup, this wouldn't be required  - but maybe this is incorrect.

Can someone please provide some insight or assistance as to what I am missing or doing incorrectly to apply the FIR processing?

Thank you,

Gary

Parents
  • Hi Gary,

    The CMSIS FIR function does not have any unusual scaling that you need to follow.  Since you are generating a lowpass filter you can easily determine if the filter is scaled properly by determining its DC response.  Simply sum up the coefficients in the filter and the result should be close to 1.0.  One thing to keep in mind is that you have a relatively short FIR filter.  At 24 points with a sample rate of 2 kHz, your frequency resolution is 83 Hz (2000/24) and you thus won't be able to make changes in the frequency domain at a finer resolution than this.

    Could you share your code and we'll take a quick look?

    -Paul

Reply
  • Hi Gary,

    The CMSIS FIR function does not have any unusual scaling that you need to follow.  Since you are generating a lowpass filter you can easily determine if the filter is scaled properly by determining its DC response.  Simply sum up the coefficients in the filter and the result should be close to 1.0.  One thing to keep in mind is that you have a relatively short FIR filter.  At 24 points with a sample rate of 2 kHz, your frequency resolution is 83 Hz (2000/24) and you thus won't be able to make changes in the frequency domain at a finer resolution than this.

    Could you share your code and we'll take a quick look?

    -Paul

Children