Hello,

I want to dynamically calculate the coefficients and set the frequency of a general filter, in this case Bandpass Filter with a VERY small bandwidth value (0.01). The problem I'm having is that I would like the output at the chosen frequency to be 0 dB. As you can see on the screenshots, the output gain changes with the frequency in periodic way (seemingly).

My idea was that if I could determine a function that takes the frequency and outputs a scale-factor which to multiply the gain parameter that is used to calulate gainLinear = 10 ^ (**gain**/20). This in order to always have the ouput to be 0 no matter the frequency like in fig 2 & fig 4.

Figure 4 shows an example of a wanted result, where input f0 = 800, a gain value of 4.5 is generated and the output is ~ 0.

I'm using the bandpass equation defined in: https://wiki.analog.com/resources/tools-software/sigmastudio/toolbox/filters/general2ndorder

Any help or ideas is highly appreciated.

// Johan

fig 1.

**f0 = 800, gain = 0**

fig 2.

**f0 = 804, gain = 0**

fig 3.

**f0 = 816, gain = 0**

fig 4.

**f0 = 800, gain = 4.5**

Johan,

Is a Bandpass filter with a bandwidth value of 0.1 unacceptable for this application? That should behave similarly to a peaking filter with a Q factor of 16, which is at the max of the range for the coefficient calculations for the DSP. So the Bandpass filter should not normally lose so much gain when changing f0, but it may be that the Q factor necessary for this kind of filter is beyond the DSP limits.

Also, which device is being used in this application?