DUE + Amp. Poor audio quality, noise

Hi there,
I can see there was quite a lot of discussion about the audio quality on DUE.
In my project I am using:

  • Arduino DUE,
  • 4x4 Keypad,
  • SD Data shield,
  • a phone receiver detect (on/off)
  • an Amp (2 x 15W (6-18V) with TDA7297)
  • a Speaker (analog phone receiver)

The sound quality of my speaker is pretty bad. Cannot say it's completely unusable, but it gives a weird pulsating noise and the quality itself is not great.
I've tried: changing the power source, changing the speaker, giving better grounding, applying a capacitor across the input to a power supply of an amp. Nothing improved the quality by much.
Any suggestions would be highly appreciated :slight_smile:

My schematics are very simple:

My audio code part:

// Playing assigned filename
void playSound(const char* cName) {
  File myFile = SD.open(cName);
  const int S = 1024; // Number of samples to read in block
  short buffer[S];
  // until the file is not finished
  Serial.println("playing ");
  Serial.println(cName);

  Audio.begin(44100, 200);
  delay(200); //delay = no glitch at the beggining of an audio
  while (myFile.available()) {
    myFile.read(buffer, sizeof(buffer));
    // Prepare samples
    int volume = 512;
    //max volume 1024
    Audio.prepare(buffer, S, volume);
    Audio.write(buffer, S);
    if (state == STATE_IDLE) {
      if (isKeyPressed()) {
        if (isNumberKey(key)) {
          break;
        }
      }
    }
    if (hookOffState == 0) {
      break;
    }
  }
  Audio.end();
  myFile.close();
  delay(50); //delay = no glitch at the beggining of an audio

Use a separate, beefy power supply for the amp and the speaker. Don't forget to connect the grounds.

The Arduino can power only a few LEDs.

It would be a good suggestion - but I've tried. I have this adjustable power supply. Sadly the result is maybe a 5% increase in quality.

Can it supply at least 5 amperes at 6V? You have a 30 Watt amplifier!

Do not even think of using the Arduino to power anything but a couple of LEDs, or a sensor.

OK, I'll try a bigger one then.

I don't what you mean by an "analog phone speaker", but what sort of sound quality would you expect from it? That amplifier is capable of driving decent home stereo speaker boxes.

An old phone handset, like that: https://sc04.alicdn.com/kf/HTB1evpeIHSYBuNjSspfq6AZCpXaQ.jpg
I probably would be OK with a smaller Amp, but there was none in stock.

I would expect pretty low quality audio from that handset, no matter what amplifier.
Also, your amplifier is expecting a low impedance loudspeaker.

UPDATE.
Went to an electronics parts store. Tried multiple chargers (up to 6 amps). Almost no difference.

Went to the professional. They have inspected my project with an oscilloscope and more tools.
The conclusion - these 3rd party data log shields suffer some major voltage fluctuations when reading the SD card.
I've tried to combat these fluctuations in prebuffering:

  // 44100kHz stereo => 88200 sample rate
  // 100-400 mSec of prebuffering. 
  Audio.begin(44100, 400);

Changing the length of prebuffering affects the speed of a "noise". It somewhat helps.

I am trying to find an SD shied or some kind of module, which would not have this issue. I have already tried one different brand of this shield, sadly not that much of a difference.

Did you remove the carbon microphone cartridge and short the terminals together? Most phone handsets connect the mike and earphone together so the user can hear their own voice.
Paul

Are you powering your amp board from Vin pin?

Did you remove the carbon microphone cartridge and short the terminals together? Most phone handsets connect the mike and earphone together so the user can hear their own voice.
Paul

No, mine didn't have this short. It was a 4 pin connector: 2 for the earphone and 2 for the mic.
I have also tried this whole setup with another, Arduino-friendly speaker, which gave the same results.

Are you powering your amp board from Vin pin?

Yes and no - I've tried both. I was convinced that powering it from VIN makes these interferences, but when trying all different power sources I've powered Arduino and the Amp separately - it was little to no difference. Sometimes the sound quality improved, but these interferences (that goes every 200-400 msec) also could be heard much clearer...

I’m sorry, let me qualify this for anyone reading just in case, you do not power anything from Vin pin, EVER, it is the power input for the board, that leads to regulator.

Can it be that I've damaged my board when powering via VIN?

The Due 3.3V supply is noisy, it has an on-board buck converter. For analog signal work I'd suggest using a separate module (the Due's inbuilt ADC and DAC are poor, note, not just because of the noisy supply). For audio work you really want separate analog supply from the microprocessor's digital supply, which is always noisy by its nature.

SDcards pull large currents (this is why they are hot after use) and will definitely put noise on their 3.3V supply - powering them from 5V using a module with a built-in 3.3V regulator can help isolate the noise they inject to the rest of the system. Good decoupling helps, at least 100µF (or more) electrolytic on top of any high speed decoupling is worth trying.

My Amp takes a minimum of 6V... So different power source it is.
Sadly, it does not solve a problem. I will try this setup with another, a new set of boards, but I doubt I've burned the old ones - so I expect no change in interference.

EDIT. Decoupling helps with a general audio quality, which is not the big issue (also my project should imitate an old phone, so it's even better). The biggest issue is that weird interference generated by SD card prebuffering. I'll try to record it today.

EDIT2. This is a recording of my interference.
https://www.mboxdrive.com/noise.mp3
The sound should be a background hum when removing the phone receiver. Now we have these almost locomotive-sounding interferences every 400msec (or whatever I am putting as my prebuffer).

UPDATE.
I have tested the setup with different DUE boards, SD shields/modules, and different amplifiers and got the same/similar results - interference.
But when testing with other, simpler boards (UNO and MEGA) it works without interference! A bit bizarre. Also, those boards don't have a proper DAC so the quality is not pristine, but it definitely has no repeating interference.

It is puzzling and I have no idea how to go from here. I have also found another topic with the same problem: Periodic noise when playing a wav file (SD card, Due, DAC, amp and speaker)
I cannot pinpoint the similarities and a root cause for this problem and it drives me crazy...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.