Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biquad Filters #213

Closed
PAk-CatchFire opened this issue Feb 20, 2022 · 11 comments
Closed

Biquad Filters #213

PAk-CatchFire opened this issue Feb 20, 2022 · 11 comments

Comments

@PAk-CatchFire
Copy link

I wonder if it is possible with this marvellous tool to generate Biquad IIR filters.

Some DSPs and MCUs, do have biquad libraries as a very efficient implementation form, so expanding this tool could be really useful for this purpose.

Thank you.
Best Regards

@chipmuenk
Copy link
Owner

That's indeed on my todo list for quite a while now. Currently, I'm working on some file I/O issues and I'm planning to add an export option for coefficients in second-order sections format (i.e. biquads). What would be most useful to you - exporting

  • SOS coefficients as floats
  • SOS coefficients as integers (this probably requires an additional gain factor per section to overcome scaling issues)
  • header files with the coefficients in C format (example needed)
  • C files with the actual filter topology (example needed, maybe even as a template as I'd like to generate ready to use filters from templates)

Contributing examples and / or templates would be most helpful!

@PAk-CatchFire
Copy link
Author

PAk-CatchFire commented Feb 26, 2022

Thank you @chipmuenk

Actually I plan to use it for ARM CMSIS in floating point (f32) format (I don't use integer for signal processing anymore), where probably the most common way is direct form II.
https://www.keil.com/pack/doc/CMSIS/DSP/html/group__BiquadCascadeDF2T.html

To help you, maybe this blog post is quite interesting:
http://gaidi.ca/weblog/implementing-a-biquad-cascade-iir-filter-on-a-cortex-m4

also linking to this other post (where an octave implementation is also presented):
https://hackernoon.com/fast-iir-filtering-on-arm-cortex-m-with-cmsis-dsp-and-gnu-octave-qk1n3y66

Here the Github:
https://github.com/matteoscordino/iir-designer-cmsis-dsp?ref=hackernoon.com

From my point of view, pyfda will have a lot of acceptance within the ARM community with this Biquad feature!!

PS: This link is also nice for an example:
http://gaidi.ca/weblog/implementing-a-biquad-cascade-iir-filter-on-a-cortex-m4

@chipmuenk
Copy link
Owner

Thanks for all the links! If I understand you correctly, you would like to get the biquad coefficients in the format
{b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} as floats as described in https://www.keil.com/pack/doc/CMSIS/DSP/html/group__BiquadCascadeDF2T.html ? That should be possible without a big effort.

@PAk-CatchFire
Copy link
Author

PAk-CatchFire commented Mar 2, 2022

Yes, that could be a fantastic direct first step.

The idea later could be to use the CMSIS library wrapper for testing the embedded library coefficients with your graphic tool - so powerful and handy!!

Again, congratulations on your work on this awesome tool. I will use it with some of our internship students for filter designing (I try to avoid MATLAB as much as possible to provide them opensource engineering tools).

@PAk-CatchFire
Copy link
Author

Hello Christian.
I wonder if you had the time to include the biquad filters for ARMs processors.

Best regards

@PAk-CatchFire
Copy link
Author

Hello @chipmmuenk, do you plan on a new release any time soon?

Best Regards

@chipmuenk
Copy link
Owner

Sorry for leaving you waiting for so long - I'm justing implementing some Github Actions at the moment to automate building and releasing to PyPI and then there will be a full new release during the next week. The main branch already contains the CMSIS export, somewhat hidden in the CSV options and is fully functional. In my opinion a new tab / subwidget is required in the future to allow a.o. selecting the order of second order sections and setting fixpoint options.

@PAk-CatchFire
Copy link
Author

Thank you.
I am converting Pyfda in my preferred tool for filter designing (so fast and powerful!!)
However, I don't see how to get the CMSIS format export in the CSV.

What I see is the same coefficients as the npy format when I import it in python:
image

Maybe I am missing something?

On the other hand, do you have a time frame for implementing in the GUI the Biquad Cascade IIR Filters Using a Direct Form II Transposed format?
Like in Matlab:
https://es.mathworks.com/help/dsp/ref/dsp.biquadfilter-system-object.html

I am seeing that many embedded applications are porting into this format because they are a quite efficient implementation.

Regards

@chipmuenk
Copy link
Owner

I've started working on fixpoint filters again. The export option for CMSIS SOS format is implemented for quite a while now but it is hidden somewhat: Open CSV option (the little cog) in the b,a tab and select CMSIS SOS format.

Does this export format work for you?

Regards

@chipmuenk
Copy link
Owner

Since v0.9.0b1, coefficients can be saved directly in CMSIS SOS format via "save coefficients".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants