Go Down

Topic: Best anti-aliasing filter to use for sampling audio on arduino? (Read 4638 times) previous topic - next topic

mrule

Hello all,

I am playing around with the ArduinoFHT library. I am sampling at 9.6kHz for a Nyquist frequency of 4.8KHz. The basic RC low-pass filter as outlined here http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/ doesn't seem to be doing the trick: I'm still getting high frequencies aliasing down into the spectrum, and I think the RC high pass might be attenuating the upper end of the pass-band more than is necessary.

My problem is: I haven't the faintest clue where to begin for a hardware anti-aliasing filter design. My instinct is to go with something with a sharp cutoff at the expense of adding some pass-band ripple. I know Matlab uses Chebyshev at 80% of the nyquist for anti-aliasing, but it looks like maybe an Elliptic filter would give even sharper cutoff?

Once I've selected a filter, how do I go about building it? I haven't even been able to get a simple op-amp preamp to work, so I'm interested in a tutorial that is as detailed as possible, for absolute beginners in hardware filter implementation, but thorough enough to actually show me how to build a filter that meets my needs. Do I want an active or passive filter? How do I compute component values to achieve the desired pass-band? If the pass-band cutoff frequencies do not uniquely specify the component values, what sort of engineering trade-offs are captured by the additional degrees of freedom? If anyone has solved this problem before and has a circuit that I can just drop in and have work, that would be amazing.



pito

MAX740x - 8th order filters, 8pin, tuning (1Hz-10kHz cutoff) with 1 capacitor wired from Clock input to gnd. Works fine.
http://www.maximintegrated.com/datasheet/index.mvp/id/1899

DVDdoug

You are going to need an active filter.   In the old days, we'd use The Active Filter Cookbook.    But, I assume this stuff is online now.

Or, you can get a Switched Capacitor Filter IC.   That's probably the simplest solution.

Every filter is a compromise and the "type" of filter is up to you.     As you may know, the cutoff frequency is defined as the 3dB down point.    So, a 4.8kHz filter is NOT going to work.    You probably want any alias signals at least 40dB down.    That's the basic problem with a simple passive RC filter...   You'd have to set the cutoff frequency way below 4.8kHz in order to get significant attenuation at 4.8kHz.

mrule

Interesting,

An off the shelf solution like MAX7400 has appeal, as does purchasing that book to learn about active filter design. The only downside here is that I'd have to wait for parts to arrive to test them out, so I couldn't build something myself from passive components and op-amps this weekemd.

So you're saying that most people on this forum probably buy and off-the-shelf switched capacitor filter if they want a good anti-aliasing solution?

I suspect that, theoretically, much sharper attenuation can be achieved with high order passive filters incorporating inductors. I had hoped that perhaps there was a standard passive circuit people were using that performed better than the RC filter.




pito

Long time back I messed a lot with active filters - it is not as easy as it seems, as you need quite precise components to build something useful. The easiest way is the MAX or something else of that kind. Mind when messing with arduino's ADC the effort with high-quality analog AA filters is not appropriate, afaik.

"The MAX7400/MAX7404 provide 82dB of stopband rejection and a sharp rolloff with a transition ratio of 1.5. The MAX7403/MAX7407 provide a sharper rolloff with a transition ratio of 1.2, while still delivering 60dB of stop band rejection."

polymorph

A misunderstanding of Nyquist trips up even experienced EEs. DVDdoug is right. Your cutoff must be low enough to attenuate frequencies at and above 4.8kHz to nearly nothing, not merely have its -3dB point at 4.8kHz.

There are free books such as Op Amps for Everyone.

And online calculators. TI has FilterPro Desktop and an online tool called Webench, and Linear Technology has FilterCAD (and LTSpice for general simulation).

http://www.linear.com/designtools/software/#Filter

http://www.ti.com  and click on "Tools and Software", select the Filter tab on Webench, and start it.

Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

mrule

I don't understand this TI filter app, it seems to select filter parameters, but doesn't actually tell you anything about how to built the filter in hardware?

tmd3


TI filter app ... seems to select filter parameters, but doesn't actually tell you anything about how to built the filter in hardware?
I think you're talking about WEBENCH.  When you see the list of filter types at the bottom of the page, push a green "Select" button on the right side of the table.  That'll take you to a schematic.  If you haven't logged in to TI, it'll make you do that first.

bosleymusic

Tip #1 : Don't use regular arduino's for Audio unless lo-fi is your thing. Get a teeny which has a Cortex M4 core and single precision DSP built in to hardware. It also has decent built in converters unlike many of the other Arduino boards.

If you don't want to buy a dedicated IC, you can use two second order Sallen-Key lowpass filters in series to give you a fourth order, which can still provide a steep enough cut-off, and enough band width depending on the desired results.


Go Up