Electronic – SPI interfering with ADC sample

audiointerferencespi

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

Best Answer

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!