This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AIC3254: Coefficients [b0, b1, b2, a0, a1, a2] calculation for Bandpass digital biquad filters

Hello  and  Justin Bohr , , and all Engineers,

My project uses Arduino Uno and AIC3254. Both devices communicate through SPI. Current stage, I want to write coefficient of Bandpass filter from Arduino Uno to AIC3254. So I need the coefficient calculation processed by Arduino Uno. By this mean, I want to know the cofficient calculation. I cannot compromise with time if I use 1 HPF and 1 LPF, unless the combination of those HPF and LPF will give me only one set of coefficients.

1. Base on the value of center frequency, Fc, Bandwidth, sampling rate, Fs, below, could you please guide me on how to get the value of  [B0, B1, B2, A1, A2] coefficients for bandpass digital biquad filters?

2. I have had refer to SLAA447 and TAS_BQ_Filter_Equations but not found. 

3. I have had refer to:

H(z) = (N0 + 2*N1/z + N2/(z2)) / (32768 - 2*D1/z - D2/(z2))

So,

N0 = B0 = b0

N1 = B1 = b1 / 2

N2 = B2 = b2

D1 = A1 = - a1 / 2

D2 = A2 = - a2

But I dont get it because the formula of [b0, b1, b2, a1, a2] are missing.

4. I have had to try below equations for bandpass filter by using the same parameters as above (1) , but not success. The value of alpha@b0 gave an overflow value.

parameters: Fc=f0=1000Hz, Bandwidth=BW=100Hz, Scale=1, Fs=44100Hz

w0 = 2*pi*f0/Fs
alpha = sin(w0)*sinh( ln(2)/2 * BW * w0/sin(w0) )
BPF:        H(s) = (s/Q) / (s^2 + s/Q + 1)      (constant 0 dB peak gain)

            b0 =   alpha
            b1 =   0
            b2 =  -alpha
            a0 =   1 + alpha
            a1 =  -2*cos(w0)
            a2 =   1 - alpha

5. Is there any reference of the coefficient formula that I missed out? what is the real equation/formula of each coefficients [b0, b1, b2, a0, a1, a2] for bandpass digital biquad filter?

Thanks and Regards,

Kal

  • Answer:

    1. change Bandwidth,BW (Hz) to Bandwidth,BWO (Octave) : sengpielaudio.com/calculator-bandwidth.htm

    Quality factor, Q = f/ BW

    Omega in radian, w0 = 2*pi*f0/Fs 



    Bandwidth in octave, BWO = (log10((1+(1/(2*Q*Q)))+ pow((((pow(2+(1/(Q*Q)),2))/4)-1),0.5)))/log10(2); //arduino uno

    2. alpha = sin(omega)*sinh(log(2)/2*BWO*omega/sin(omega))

    B0 = alpha/(1+alpha)
    B1 = 0
    B2 = -alpha/(1+alpha)
    A1 = cos(omega)/(1+alpha)
    A2 = -(1-alpha)/(1+alpha)

    3. The value was slightly different, but in my project of feedback destroyer, it still can be compromise. Please correct me for any mistakes.

    Thanks and Best Regards,

    kal.

  • Hi Kaeroul,

    Thank you for providing your solution.

    Justin