1
\$\begingroup\$

I'm attempting to record 8-bit/8kbps audio to an SD card using the samd21g18a microcontroller. I'm having an issue where the ADC sample value drops whenever the SD card is being written to. This results in a "ticking" noise during playback.

The "ticking" happens at a ~60ms interval which is consistent with SD card writing after buffering 512 bytes (512 * (1 / 8000) = 0.064 seconds). I've shortened all the wires to their minimum lengths which has reduced the amplitude of the "ticking" significantly, but it still faintly exists. Does anyone have any suggestions for shielding the mic/ADC from noise from the SPI lines?

Here is a screenshot of the audio file in Audacity that shows the "ticking" sound. This was before I shortened the wires so it's not quite this severe anymore:

enter image description here

For the mic, I'm using this Adafruit breakout built around the MAX4466, which seems to be picking up and amplifying the noise from the SPI lines.

Thank you!

@JRE Here is a diagram of the setup. Again, the lines are kept as short as possible with both breakout board grounds connecting directly to the Feather M0 ground pin.

Audio recording setup with Feather M0

@John Birckhead I initially thought that power to the mic might be dropping while the SD card is writing due to the higher current demands. Here is a screenshot of VCC (CH1) and the mic output (CH2) while it's logging to the SD card. The input voltage seems very stable even upon zooming in.

Scope screenshot of VCC and mic out

Here's a screenshot of the SD shield clock pin (CH1) and the mic output (CH2). The resolution isn't great, but you can see that the mic output drops then recovers when the SD write happens.

Scope screenshot of SD CLK and mic out

\$\endgroup\$
  • 2
    \$\begingroup\$ Can you show a diagram of your whole setup? It sounds more to me like you've got power supply problems. \$\endgroup\$ – JRE Jun 3 '19 at 18:44
  • \$\begingroup\$ Probably a poor ground or cross-talk. Proper decoupling and grounding will probably solve this issue. \$\endgroup\$ – Voltage Spike Jun 3 '19 at 19:02
  • \$\begingroup\$ While electrical intereference is certainly possible, are you sure this is not an irregularity in the ADC sampling resulting from a time delay in writing? Typically you need both to be careful of noise coupling, and to be sure that your sampling is fully decoupled by buffers and remains perfectly consistent regardless of the data sink momentarily pausing. As for the interference, it may not actually be the SPI, but rather a bolus of current needed for the following write operation. \$\endgroup\$ – Chris Stratton Jun 3 '19 at 19:07
  • \$\begingroup\$ are you using shielded pair everywhere (or STP cable)? Is there a low ESR e-cap on Vdd in the right place? \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jun 3 '19 at 19:34
  • 1
    \$\begingroup\$ I checked for irregularities in the ADC sampling by using the same code to first record a short sample to RAM then write to SD card. Recording audio this way results in no "ticking", however, the limited RAM means only being able to store a few seconds. \$\endgroup\$ – AngryPeaches Jun 3 '19 at 19:55
1
\$\begingroup\$

too many words for a comment:

You are most likely seeing a slight drop in the power supply to the microphone board at the time the write occurs. This board is designed for experimenters and they amplify the audio signal referenced to VCC/2 of the MAX 4466 breakout board. Even a tiny dip in the power supply subject to the gain of this board will be something you can hear, and the current to drive the MicroSD card will be enough to do it.

First, be sure that the lines from your power source go to the processor first, and that power and ground for your audio card comes from the processor board and goes nowhere else. This way, there none of the current required to run your microSD card is running in the lines between the audio and the processor. Then I might try powering the audio board from an LDO linear reference or regulator instead of directly from the same power as the processor.

Great illustration. Here is what I am trying to say: The current to the SD board will increase whenever a write occurs. When this happens it will cause a voltage drop across ground wire from the wire's inductance and resistance, so that the SD card ground is a slightly higher voltage than the processor ground. Because you are getting your microphone amplifier ground from a point along this current-carrier wire, its ground is slightly moving whenever a write occurs, and since the amplifier reference is VCC/2, this change also gets amplified. This can be hard to measure with a scope because it matters where the scope is grounded in your circuit.

An ideal situation would be to have the power for the microphne come directly from the processor ADC reference and ground pins on separate wires. Since this line would have essentially no current, there would be no difference in voltage from current surges. Using the pin on the board means that the current path is still shared for the SD card and power on the traces, even if you use separate wires.

In general, it is not a good idea to use VCC/2 as a reference for audio signals because of this problem, especially in a case like this where the VCC/2 is introduced before amplification. I can't open the schematic to your audio board, but I would consider using a voltage reference to bias the microphone rather than a resistor divider from the power supply. Once you get the audio signal amplified, small changes will not make a big difference.

Good luck!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for your suggestion! It doesn't seem like input voltage to the mic board is the issue. I added some screenshots to the OP that I think will show this is. Early on I tried to provide separate power to the mic and sd breakout boards. While it seemed to slightly reduce the amplitude of the "ticking", the issue still remained. \$\endgroup\$ – AngryPeaches Jun 5 '19 at 13:12
  • \$\begingroup\$ Great illustration. I edited my answer because I am too long winded again \$\endgroup\$ – John Birckhead Jun 5 '19 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.