## fixed point coeficcients to floating point

Started by 1 year ago2 replieslatest reply 1 year ago121 views

Hi,

I am trying to modify a Texas Instruments provided example to fit my needs.

Example filters like this one is provided in the code:

// Insert optional second filter here (@16 kHz). Some examples:
//1147,-1516,   522, -1699,   708,    // +5dB peak filter (F0=500 Hz, BW=3 octaves)

; Each second order section is assumed to have normalized both numerator and denominator,
; i.e b0 and a0 are 1. The gain g is applied to the input. If unormalized, g can be b0/a0
; and each coefficient in the numerator must then be divided by b0 and each coefficient
; in the denominator divided by a0.
; After the last section a dummy section with gain 0 indicates the end of the IIR filter.
; All coefficients must be in the SI.FFFF_FFFF_FF format, i.e 21 sign bits, one integer bit
; and ten fractional bits. Thus the range of the coefficients are [-2, 2) and the resolution
; is 2^-10

Now I am trying to verify this by plotting the frequency response of the peaking filter in Python

g = 1147*(2**-10)
sos = np.array([1*(2**-10)*g, -1516*(2**-10)*g,   522*(2**-10)*g, 1, -1699*(2**-10),   708*(2**-10)])
w, h = signal.sosfreqz(sos)

plt.plot()
db = 20 * np.log10(np.abs(h))
plt.plot(w/np.pi, db)
plt.grid(True)
plt.show()

The plot does not look like a peaking filter at all. I assume my convertion from fixed to floating point is incorrect. Hints would be appreciated.

Regards, Erlend

[ - ]