• General
  • MEMS analog microphone extremely noisy on Bela mini

robinm ok so - i really couldn't hear anything from the first circuit (no baseline?), but the second circuit (the one including the MEMS) actually DOES work like a charm

That's a good first step.

robinm The microphone itself is still crunchy as crazy, but the baseline noise has been practically completely removed this way.

Is this the case both when powering from USB or from LiPo?

To assess and address the distortion you are hearing, can you show the microphone signal on the Bela scope? In Pd you 'd do:

[adc~ 3] << mic input: analog in 0
|\\
| | \
| |   \
| [dac~ 1 2] << output to headphones. Does it distort when powered via USB?
|
[dac~ 27] << send to scope

Then view it at http://bela.local/scope . Show screenshots both with the microphone connected and without it (without C2).

It is harder/impossible to use the Scope when powered via LiPo. If the issue only presents itself only with the LiPo, consider using a program that can record the analog input as a wav file to disk and send that wav file over. In Pd it would be:

Set this program to run on boot, power via LiPo, let it run for ten seconds, then power it off gracefully, power via USB, open up the IDE, download the wav file and look at it / post it here.

Since it seems too much like magic to believe it, can you explain me what's happening?

I don't know exactly how you were wiring the microphone before. This circuit provides a bias of about 2V at the analog input which works as the central point, which is what the two resistors do. C1 removes some of the high frequency noise. When you add the microphone, C2 ensure the signal is AC-coupled and no DC-voltage at the output of the microphone affects the 2V bias. If the mic breakout already has an output capacitor, this could be removed. The AC-coupled signal from the microphone will be added to the 2V DC bias and so it will oscillate around the 2V offset, thus remaining within the 0V : 4.096V range of the ADC.
Now, I just looked at the circuit for your MEMS breakout: https://cdn.sparkfun.com/assets/c/3/7/5/e/SparkFun_Analog_MEMS_Microphone_Breakout_ICS40180_Schematic.pdf . If this is accurate, then the output of the breakout should already be centered at around 1.65V and so the diagram I suggested shouldn't be needed, at least for basic operation (although it may improve the dynamic range when Bela is powered from USB). So if you have something that works with my circuit that didn't work before, it may be one of these options:

  • you wired the previous circuit wrong (although it should be straightforward)
  • you wired my circuit wrong, something is hitting the rail (GND or 5V) when no microphone is connected, thus saturating the ADC input (dead silence!) and causing the subsequent distortion when the microphone is indeed connected. Looking at the scope and/or recorded wav file may shine some light on this
  • something else that requires further investigation

    Note that when both LiPo and USB are connected, the board would normally run off the USB power rail. I think you may be able to toggle the USB power on and off (thus forcing it to run from the LiPo) by running these commands in the console at the bottom of the IDE.

    This disables USB power and enables the LiPo:

    i2cset -y -f 0 36 1 47

    this enables USB power and disables the LiPo

    i2cset -y -f 0 36 1 63

    I haven't tested this, but it seems likely to work. If you do have any noise that only shows up with the LiPo, try toggling with these two commands and see if you can reproduce the "LiPo-only" noise even with the USB plugged in. To confirm this does anything at all, measure the voltage at the "REF" pin off the analog input header: It should be 4.096V when powered from USB and something closer to 3.7V when powered from LiPo only.

    giuliomoro Is this the case both when powering from USB or from LiPo?

    this was powered via USB.

    The scope is a good idea but I'll have to get back to you with it later / tomorrow.
    For the rest, quickly

    giuliomoro I don't know exactly how you were wiring the microphone before.

    I wasn't, or better I was just wiring VCC to 3v3, GNG to GNG, AUD to A0 or other analog pin.

    giuliomoro and so the diagram I suggested shouldn't be needed

    .. which is what I thought. the integrated circuit seemed to include some of this already (in my superficial understanding of it) so we went ahead and plugged it that way. To be honest, amongst us three people that have tried this setup on different units I am the only one that is experiencing this kind of noise via USB and LiPo (although the latter wasn't tested with your circuit yet); the other two people have only had noise while using the Lipo. We're in the process to test these various scenarios but I'll get back to you when I have checked scopes and maybe recorded files of it.

    giuliomoro you wired the previous circuit wrong (although it should be straightforward)

    never say never ahahah. I'll double check, it's always very likely

    giuliomoro you wired my circuit wrong, something is hitting the rail (GND or 5V) when no microphone is connected, thus saturating the ADC input (dead silence!) and causing the subsequent distortion when the microphone is indeed connected

    I'm not sure I understand this..

      robinm

      giuliomoro you wired my circuit wrong, something is hitting the rail (GND or 5V) when no microphone is connected, thus saturating the ADC input (dead silence!) and causing the subsequent distortion when the microphone is indeed connected

      I'm not sure I understand this..

      If you wired my circuit wrong, it may give the illusion that there is no background noise because the input is saturated when there's no microphone connected and when it's saturated there is no noise because it's just a constant value, either 0 or 1. But when the microphone signal is added on top of that, the resulting sound would be very distorted. This is compatible with your observation of "really couldn't hear anything from the first circuit (no baseline?)" and "crunchy as crazy"

        giuliomoro
        I see, well that picture i made in fritzing displays the actual wiring i used, but if you have another reference for your circuit (if you think it would help to see more clearly the diagram) I'd be happy to troubleshoot this!

        Better start from the scope and/or file recording explained here as a starting point to troubleshoot further.

        ok, since i don't have my hands on a Bela mini right now, do you think it would be equivalent to test this on Bela for the time being?

        Give it a try and see if you get the same results, if you do, it's worth doing.

        ok well, seems same (audio) results on a Bela. I think I wired the circuit correctly (but.. see below). the distorsion i experience might just be the output of the mic? I see no squarewave in the bela scope. here with the MEMS plugged in through your circuit, connected USB to the computer, in a condition of quietness:

        here singing a single tone almost straight into it:

        channel 1 (0) is the input directly from AnalogIn(0) in supercollider, channel 2 (1) is the same input scaled (-1,1) and sent to the Bela audio output.

        The circuit (this time on a breadboard for clarity) looks like this:

        If i test it removing only C2 and the MEMS I get nothing in the Bela scope, but it looks an awful lot like the scenario that you were picturing

        In this case the circuit looks like this:

        All of this was tested via USB to a pc. Can you spot any weird stuff in the circuit that I should fix? Or do you have other ideas on what to troubleshoot? at this point I'm not sure if what I'm hearing is in fact unusual for this mic... Should I send audio samples here on the forum?

          robinm ok well, seems same (audio) results on a Bela. I think I wired the circuit correctly (but.. see below). the distorsion i experience might just be the output of the mic? I see no squarewave in the bela scope. here with the MEMS plugged in through your circuit, connected USB to the computer, in a condition of quietness:

          here singing a single tone almost straight into it:

          channel 1 (0) is the input directly from AnalogIn(0) in supercollider, channel 2 (1) is the same input scaled (-1,1) and sent to the Bela audio output.

          These look OK: no obvious clipping or distortion can be seen. Try applying a DC-removal filter to the signal before sending it out of the output (e.g.: a high-pass filter with cutoff at 10Hz or some other Supercollider magic), just to ensure there's no unexpected clipping happening there (unlikely). In Pd that would be :

          [adc~ 3] << mic input: analog in 0
          |\
          |  \
          |   [hip~ 10]
          |    | \
          |    |   \
          |    [dac~ 1 2] << output to headphones. Does it distort when powered via USB?
          |
          [dac~ 27] << send to scope
          10 days later

          Unfortunately that doesn't seem to make a difference. In Supercollider I routed the analog-to-audio signal both through HPF.ar (a hi-pass filter) and LeakDC.ar (an alleged DC noise remover) but no change whatsoever. I have to specify that some of us are only having this problem when plugged to a LiPo (+ booster) but in my case the noise although bearable is omnipresent (and powering-agnostic..). I hope to post lucky updates, although for now we're just scratching our heads

          you haven't posted an audio recording of the issue yet,

          robinm here with the MEMS plugged in through your circuit, connected USB to the computer, in a condition of quietness:

          robinm here singing a single tone almost straight into it:

          robinm If i test it removing only C2 and the MEMS I get nothing in the Bela scope, but it looks an awful lot like the scenario that you were picturing

          I mention that these three all look OK in terms of distortion: no visible clipping. I though you had some issue with distortion, but now you mention having problems of noise. Can you record the inputs to file with noise and/or distortion and post a recording as suggested above? See

          giuliomoro a program that can record the analog input as a wav file to disk and send that wav file over. In Pd it would be