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.
Hi,
I am trying to use DSPF_sp_biquad API for a 6th order IIR Bandpass filter implementation(Parallel SOS- 2 X 3). But API is crashing , and unfortunately I did'nt see it running for atleast once!!! even I tried with buffer length of multiple of 6 as suggeted by someone, no improvement.
Eventually, I thought of using DSPF_dp_biquad (Double precision) API after converting float buffer to double, it is not crashing, but introducing accuracy error.
Please let me know what's wrong with the API to introduce accuracy deviation. Hope, following details will help you to better analyse the problem.
My filter specs are as below : Fp1 = 44Hz
Fp2 = 48Hz
Fs1 = 52Hz
Fs2 = 56 hz
Ap = 1dB
As = 30dB
Ap = 1dB
and the coefficients for three biquads are as below:
float64 b0[3] = {0.420639067511500, -0.841083737890231352843143, 0.420639067511500}; <- Biquad 1
float64 a0[2] = {-1.998039409813, 0.9987030104471};
float64 b1[3] = {0.420639067511500, -0.840948942241822614267313, 0.420639067511500}; <- Biquad 2
float64 a1[2] = {-1.998280901758, 0.998825255448};
float64 b2[3] = {0.001500620942198, 0.0000000000000, -0.001500620942198}; <- Biquad 3
float64 a2[2] = {-1.996398261519, 0.9969987581156};
Input signal passed is 230V/ 50Hz, with 12800 Hz Sampling frequency. One half cycle (128 Samples) is passed through the filter and then DFT is applied on one full cycle to compute fundamental magnitude and phase angle. Interestingly the C version of the same API is giving proper results which I can't use for my implementation due to timing issues.
Please refer attached the snapshot for three different implementation input sand outputs.
230V/50 hz sinewave is passed through 3 different channels:
1. Serial SOS implementation- > My own C code. -> 229.993
2. Parallel SOS implementation-> C version of DSPF_dp_biquad API. -> 229.993
3. Parallel SOS implementation -> DSPF_dp_biquad API. -> 229.2025 <- Accuracy error
Please let me know if this is a known issue with the DSPF_dp_biquad and any possible solution for the accuracy error and it would be really helpful if you can provide an alternative solution or API available for DSPF_sp_biquad or its bug free version.
Regards,
Balachandra Naik
For DSPF_sp_biquad you must invoke the API with nx a multiple of 6. Please see this related thread.
Hi Brad,
nx I am passing is 128, it can't be changed and obviously its not multiple of 6. Is there any other way I can use the DSPF_sp_biquad API? In fact, I have tested DSPF_dp_biquad, its supporting any length. Why this restriction on single precision API? Even datasheet doesn't say that.
Regards,
Balachandra Naik
It's a documentation error that it doesn't mention the restriction. If you look at the source code for the function (i.e. inside the bundled .src file) it is mentioned in the comments of the function. If you can't meet the requirement then you can't use the function. Better go with compiled C code.