cancel
Showing results for 
Search instead for 
Did you mean: 

Digital Filtering Problem

baycanakcay
Associate II
Posted on March 23, 2016 at 14:26

Hi,

 I am using STM32f405, and CMSIS dsp library, to filter a signal acquired by ADS1278. The filter used is a 12th order bandpass butterworth IIR filter whose coefficients generated by matlab, and my signal is 2430Hz The problem is;

When I use a filter with a pass band 2300Hz-2500Hz everything work fine. But if a use a more narrow band like 2420Hz-2440Hz filter output is not stable. It is making noise, not periodic but randomly, like 2 seconds ok then a noise, 5 seconds ok then a noise. Matlab says filter is stable for 32bit quantized coefficients, but actually there is problem. 

Can anyone suggest a way to findout where is the problem?

#dsp-iir-filter-matlab-stm32f4
8 REPLIES 8
benoit239955_stm1_st
Associate II
Posted on March 23, 2016 at 14:55

Hello,

This seems very difficult to get a right result.

Are you in 32bits integer or single FP and your sample rate is not high versus the band.

Some times I program the filter in Double FP to get the expected result or on 64 bits integer (more difficult and longer to execute)

B.

AvaTar
Lead
Posted on March 23, 2016 at 15:21

> Matlab says filter is stable for 32bit quantized coefficients, but actually there is problem.

 

If I remember correctly, Matlab does by default anything in double precision.

Coefficients might be single-precision (float, 32 bit), but intermediate values not.

I'm pretty sure, if you verify your IIR implementation on a PC platform using float (single precision), you get identical ('noisy') results.

baycanakcay
Associate II
Posted on March 24, 2016 at 09:29

Hi,

I am using single precisison floating point, and also tried imlementing filter in 64 bit floating point but execution time approximately 10 times greater. 

Is there any mathematical relation between bandwidth and the sampling rate?

Because i also tried incresing sampling rate. Infact I cannot really increase the sample rate because of the software limitation in communication between ADS1278 and my STM32f4 dsp. But I extrapolate the signal by injecting zero after every sample. But ı got the same result.  

baycanakcay
Associate II
Posted on March 24, 2016 at 09:33

I also tried implementing this in PC, but there was no problem.

My coefficients were 32bit fp and the arithmetic was single, and I got correct result. 

AvaTar
Lead
Posted on March 24, 2016 at 10:41

> Is there any mathematical relation between bandwidth and the sampling rate?

 

Search for ''Nyquist theorem''. I supposed you know ...

> I am using single precisison floating point, and also tried imlementing filter in 64 bit floating point but execution time approximately 10 times greater. 

 

Ten times seems a bit much, but yes, double precision is not directly supported by the FPU, and requires emulation.

I think you would need to estimate the accumulative error of your filter implementation. Single precision means only 24 bit mantissa - the more calculations, and the more complex, the further the deviation from your theoretical result.

And for a reference implementation, that definitely includes reference data. When using the same 'filter' code and the same reference test data, you should get the exact same results on your target hardware, and on a PC implementation, provided you use a IEE754 floating point implementation (which is the default).

baycanakcay
Associate II
Posted on March 24, 2016 at 11:13

Hi,

I know sampling theorem, and it states that to reconstruct signal you have to sample it at least twice of signal's frequency.

I was asking for is there any practical implementation states that ''if you want to have good result your sampling frequency must be for example 50x of the band width of your filter''

Thanks 

AvaTar
Lead
Posted on March 24, 2016 at 12:27

I'm not an expert in digital signal processing, but there is a relation between sampling frequency and  bandwidth (filter slope). Think of the correspondence between sampling frequency (time domain) and bin size (frequency domain).

Excluding other possible bugs in your implementation, your high-order filter might be numerically unstable for such a small bandwidth. However, a direct mathematical relation escapes my knowledge ...

baycanakcay
Associate II
Posted on March 24, 2016 at 12:46

Thanks for your help Avatar,

I will take that in to consideration.