Generating PASM IIR digital filters using Python (scipy.signal library).
Mark_T
Posts: 1,981
in Propeller 1
This is something I've posted a rudimentary version of before, but as an aside, and I've been improving and enhancing the code recently.
The python scipy.signal library has lots of stuff for designing digital filters easily. I've put together some code to generate PASM implementations of IIR (infinite impulse response) digital filters using this. The code also uses matplotlib the Python plotting library to show the response of the filter too. You can specify a bit depth for the coefficients to speed up and reduce the size of the generated code.
There are some problems still for some filters, the code to gather zeroes and poles into stages is decided ropey for edge cases, but many things work.
I've used one of the examples (band_pass_2) on my Prop audio board (it has I2S ADC and DAC so can handle 24 bit audio sampled at 48kHz) to show the actual performance matches the calculated performance well (~90 dB S/N).
(The slight slope on the passband is due to my spectrum analyzer's tracking generator AC coupled output dropping in amplitude below about 15kHz)
The main graphs displayed show response in magnitude and phase and impulse and step responses:
There is also a complex filter mode, demonstrated by one of the examples.
Have fun!
__Mark
The python scipy.signal library has lots of stuff for designing digital filters easily. I've put together some code to generate PASM implementations of IIR (infinite impulse response) digital filters using this. The code also uses matplotlib the Python plotting library to show the response of the filter too. You can specify a bit depth for the coefficients to speed up and reduce the size of the generated code.
There are some problems still for some filters, the code to gather zeroes and poles into stages is decided ropey for edge cases, but many things work.
I've used one of the examples (band_pass_2) on my Prop audio board (it has I2S ADC and DAC so can handle 24 bit audio sampled at 48kHz) to show the actual performance matches the calculated performance well (~90 dB S/N).
(The slight slope on the passband is due to my spectrum analyzer's tracking generator AC coupled output dropping in amplitude below about 15kHz)
The main graphs displayed show response in magnitude and phase and impulse and step responses:
There is also a complex filter mode, demonstrated by one of the examples.
Have fun!
__Mark
Comments
(I take a low pass filter and rotate all the zeroes and poles around the origin in the example to make
a single-sideband band-pass quadrature filter).
The graph plots for a complex filter show the negative frequency domain as well and the impulse/step
responses in quadrature
The crystal is 6.144MHz which allows standard I2S 48kSPS and 96kSPS - puts the system clock up to over 98MHz.
Separate 3.3V regulators power the digital and analog supplies.
A single cog (plus one timer on the main cog) can drive the ADC and DAC at 48kSPS with enough cycles to spare to estimate incoming dB and apply a power-of-two scale factor to the outgoing samples.
I'm using the board to verify and experiment with digital filtering and processing of audio using the prop.
Anyway, your board looks nice. Pity about the ADC chips EOL.