Friday, January 7, 2011

Filter coefficients revisited...

I mentioned in a previous post that "if you don't like the filters that Juha has chosen for the rig" or "if you want to add more of your own" that you can simply design them in software and change or add coefficients.

I also stated that there was a program I liked better than the one I posted but I forgot what it is.  Well I remembered and also noticed that it's the program that Juha himself used.  If you look at the Microphone IIR source code header (miciir.h) he reveals his source of coefficient generator.

// Microphone test LPF filter
// fs = 8000 Hz
// f1 = 2100 Hz
// pass band riple 0,3dB
// designed with Toshio Iwata DFALZ1 program
/*
a0 = 15723
a1 = 31447
a2 = 15723
b1 = 7747
b2 = 22379
a0 = 6398
a1 = 12796
a2 = 6398
b1 = -12827
b2 = 5651
*/


The dfalz1 program is available on http://www.digitalfilter.com/ (link to Digital Filter Analyzer page) (direct link to download) and applies to the FIR filters as well. So you can change characteristics of the filters in this rig quite simply if you would like. I think Juha's choice of filters was quite good and most people shouldn't mess with it.. but if you want to mess with it to learn about these filters.. you can always easily change it back.

Here is a screenshot of a certain "hacker" duplication the narrow filter (FIR) on the cube.. the 200-700 Hz filter. Note all of the design parameters of the filters are in the comments of the filter headers. Really cool of Juha to have the open source be that open.



OK.. the screenshot needed to be small to fit here... but the coefficients I generated with the program are an exact match (when designed with the parameters that were specified in the comments) with those that are in the existing project header file.  You might be able to tell that from the picture above!

Make sure you set the coefficents to 16-bits on a 16-bit fixed-point processor like the DSPic33!

I'm going to eventually have to post why it's much more difficult to have a project be open source (hardware and software).. but lets just say that it's wonderful that Juha and George approached the project this way.

No comments:

Post a Comment