Build a cheap/small sound spectrum analyser in MicorPython project

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
Post Reply
kynixsemic
Posts: 1
Joined: Mon Jan 15, 2018 8:19 am

Build a cheap/small sound spectrum analyser in MicorPython project

Post by kynixsemic » Mon Jan 15, 2018 8:30 am

Explanation
In this Micropython project I wanted to build a cheap/small sound spectrum analyser to identify specific tones during testing. Initially I tried to connect the Adafruit sound sensor with an ADC and RPI but then faced a lot of timing problems and therefore went to the ARM-M4 micro-controller which is a pretty good straight forward solution. On git-hub I found an FFT code written in ARM assembler by Peter Hinch, which allowed me to obtain on-board frequency spectrum calculation of an array, based on the Cooley-Tukey algorithm.

https://i.stack.imgur.com/Bxllg.png
micropython+adafruit

The picture below illustrates the spectrum(top) in a silent room, the middle plot shows the calculated gradients of the domain and the last the reactivity of the specific tones. The system is continuously captures 2**10 samples in 0.1s >10Hz-5kHz, calculates the FFT and forwards output array to PC in 15ms.

Sound spectrum 10Hz-5kHz

The problem is found in the harmonic tones that appear at exactly 1,2,3,4,5,.. kHz (graph was taken in silent room). Second problem shows up when there is a little more noise; spikes(bottom graph) appear around the harmonic tones+/-240Hz, aliased?. The bottom plot shows the reactivity of the tones.
https://i.stack.imgur.com/KKYHR.png
Tried:
No power; all frequency zero except a few low freq show minor amplitude.
Settings of the FFT for 0.5s/0.1s/0.05s/0.01s and 512/1024/2048 samples; but show the same peaks at same freq.
Three different ADC channels on the Pyboard.
Both 3V3 and GND connections.
External regulated 2-5V with shared ground (laptop no charge). (makes it worse; more noise)
What is most likely the cause of this behaviour? Board circuit / Electret-Amplifier / FFT-code / USB-power?

Alternatives?
Does someone have experience with, or has a better alternative for a cheap on-board spectrum analysis:

Me Sound sensor (LM386) amplifier datasheet: http://www.ti.com/lit/ds/symlink/lm386.pdf
Grove sound sensor (LM386) amplifier.
Adafruit sound sensor (MAX4466) amplifier datasheet: http://www.kynix.com/uploadfiles/pdf967 ... 847424.pdf

User avatar
pythoncoder
Posts: 3130
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Build a cheap/small sound spectrum analyser in MicorPython project

Post by pythoncoder » Tue Jan 16, 2018 10:32 am

Have you got an anti-aliasing filter? If not it's very likely that the 1KHz comb spectrum is an artefact resulting from high frequency digital noise being aliased down into the audio band.

It's worth noting that microphone preamps are sensitive things prone to noise pickup - you really need to give attention to screening. Put the preamp and the anti-aliasing filter in a metal enclosure with the enclosure connected to gnd and use shielded cables for the mic and between the preamp and the Pyboard.

I and others have observed that the amount of digital noise around the Pyboard is reduced if not using the USB connection.
Peter Hinch

Post Reply