VS1053 recording issue- strange noise

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
whooo
 
Posts: 3
Joined: Wed Sep 17, 2014 4:23 pm

VS1053 recording issue- strange noise

Post by whooo »

I've been having some issues with the VS1053 breakout board. I have no problems playing audio files off of the SD card, but when I try to record using the record_ogg sketch included in the library, there's a low, repetitive "wub" noise. It only occurs when recording to the SD card- if I stop recording, I can still hear any noises I make played back through the speaker, but the wub noise is gone. Starting another recording brings it back.

http://i.imgur.com/FnZCxZt.jpg

SDCS pin on top, rail on bottom

http://i.imgur.com/wAgVB7L.jpg

DREQ pin on top, rail on bottom

http://i.imgur.com/t3Xj6N8.gif

Here's a clearer picture from one of the recordings.

Looking at this, it seems like the issue is caused by a lack of isolation from the SD chip select pin and the rest of the circuit. The noise is visible in both the arduino I've been using and the VS1053 board (I've checked the power rails and pins on both). I've tried two mega2560s and an uno, neither of which made a difference. Does anyone have an idea of how to fix this? I've included the code I'm using below.

Code: Select all

/*************************************************** 
// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// define the pins used
#define RESET 9      // VS1053 reset pin (output)
#define CS 10        // VS1053 chip select pin (output)
#define DCS 8        // VS1053 Data/command select pin (output)
#define CARDCS 4    // Card chip select pin a0
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin a1

#define REC_BUTTON 7

Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(RESET, CS, DCS, DREQ, CARDCS);

File recording;  // the file we will save our recording to
#define RECBUFFSIZE 128  // 64 or 128 bytes.
uint8_t recording_buffer[RECBUFFSIZE];

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Ogg Recording Test");

  // initialise the music player
  if (!musicPlayer.begin()) {
    Serial.println("VS1053 not found");
    while (1);  // don't do anything more
  }

  musicPlayer.sineTest(0x44, 1000);    // Make a tone to indicate VS1053 is working
 
  if (!SD.begin(CARDCS)) {
    Serial.println("SD failed, or not present");
    while (1);  // don't do anything more
  }
  Serial.println("SD OK!");
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(10,10);
  
  // when the button is pressed, record!
  pinMode(REC_BUTTON, INPUT);
  digitalWrite(REC_BUTTON, HIGH);
  
  // load plugin from SD card! We'll use mono 44.1KHz, high quality
  if (! musicPlayer.prepareRecordOgg("v44k1q05.img")) {
     Serial.println("Couldn't load plugin!");
     while (1);    
  }
}

uint8_t isRecording = false;

void loop() {  
  if (!isRecording && !digitalRead(REC_BUTTON)) {
    Serial.println("Begin recording");
    isRecording = true;
    
    // Check if the file exists already
    char filename[15];
    strcpy(filename, "RECORD00.OGG");
    for (uint8_t i = 0; i < 100; i++) {
      filename[6] = '0' + i/10;
      filename[7] = '0' + i%10;
      // create if does not exist, do not open existing, write, sync after write
      if (! SD.exists(filename)) {
        break;
      }
    }
    Serial.print("Recording to "); Serial.println(filename);
    recording = SD.open(filename, FILE_WRITE);
    if (! recording) {
       Serial.println("Couldn't open file to record!");
       while (1);
    }
    musicPlayer.startRecordOgg(false); // use microphone (for linein, pass in 'false')
  }
  if (isRecording)
    saveRecordedData(isRecording);
  if (isRecording && !digitalRead(REC_BUTTON)) {
    Serial.println("End recording");
    musicPlayer.stopRecordOgg();
    isRecording = false;
    // flush all the data!
    saveRecordedData(isRecording);
    // close it up
    recording.close();
    delay(1000);
  }
}

uint16_t saveRecordedData(boolean isrecord) {
  uint16_t written = 0;
  
    // read how many words are waiting for us
  uint16_t wordswaiting = musicPlayer.recordedWordsWaiting();
  
  // try to process 256 words (512 bytes) at a time, for best speed
  while (wordswaiting > 256) {
    //Serial.print("Waiting: "); Serial.println(wordswaiting);
    // for example 128 bytes x 4 loops = 512 bytes
    for (int x=0; x < 512/RECBUFFSIZE; x++) {
      // fill the buffer!
      for (uint16_t addr=0; addr < RECBUFFSIZE; addr+=2) {
        uint16_t t = musicPlayer.recordedReadWord();
        //Serial.println(t, HEX);
        recording_buffer[addr] = t >> 8; 
        recording_buffer[addr+1] = t;
      }
      if (! recording.write(recording_buffer, RECBUFFSIZE)) {
            Serial.print("Couldn't write "); Serial.println(RECBUFFSIZE); 
            while (1);
      }
    }
    // flush 512 bytes at a time
    recording.flush();
    written += 256;
    wordswaiting -= 256;
  }
  
  wordswaiting = musicPlayer.recordedWordsWaiting();
  if (!isrecord) {
    Serial.print(wordswaiting); Serial.println(" remaining");
    // wrapping up the recording!
    uint16_t addr = 0;
    for (int x=0; x < wordswaiting-1; x++) {
      // fill the buffer!
      uint16_t t = musicPlayer.recordedReadWord();
      recording_buffer[addr] = t >> 8; 
      recording_buffer[addr+1] = t;
      if (addr > RECBUFFSIZE) {
          if (! recording.write(recording_buffer, RECBUFFSIZE)) {
                Serial.println("Couldn't write!");
                while (1);
          }
          recording.flush();
          addr = 0;
      }
    }
    if (addr != 0) {
      if (!recording.write(recording_buffer, addr)) {
        Serial.println("Couldn't write!"); while (1);
      }
      written += addr;
    }
    musicPlayer.sciRead(VS1053_SCI_AICTRL3);
    if (! (musicPlayer.sciRead(VS1053_SCI_AICTRL3) & _BV(2))) {
       recording.write(musicPlayer.recordedReadWord() & 0xFF);
       written++;
    }
    recording.flush();
  }

  return written;
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: VS1053 recording issue- strange noise

Post by adafruit_support_rick »

Please post clear, detailed pictures of both sides of the module, showing your soldering and connections

User avatar
whooo
 
Posts: 3
Joined: Wed Sep 17, 2014 4:23 pm

Re: VS1053 recording issue- strange noise

Post by whooo »

http://i.imgur.com/nBKtgwb.jpg

http://imgur.com/CtXiRUb

GPIO pins are all tied to GND via a 100K resistor, and RX is tied to 3.3V.

After playing around with this some more, I've found that saving to an SD card on another board works fine- I'm still using SPI, but I have the 5V supply of my arduino going to the VS1053's VCC input, and the 3.3V arduino supply going to the power of the external SD card. It appears that the issue is being caused by spikes in the power being drawn by the SD card (on the VS1053 board) when it is being written to, which is causing a voltage drop in the rest of the circuit, leading to noise which the mic and A/D converter on the VS1053 are picking up.

Looking at the datasheet for the voltage regulator on the board, its max output current is rated at 150mA. The SD card alone will use 100mA (standard SD- see table 2-2), up to 200mA (SD HC). This doesn't give much wiggle room for the rest of the circuit.

I'm going to use the workaround of saving to a separate board for now, but I figure you guys would find this useful.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: VS1053 recording issue- strange noise

Post by adafruit2 »

ooh ok - that is an interesting issue. i wonder if tying the arduinos 3.3V pin to the output of the onboard regulator would help. that would bump the current capbility up to 250mA.
can you try that and let us know? if that helps it will let us with a design rev

another option is to use a seperate mic amp
https://www.adafruit.com/products/1063
this one has hella PSRR which may reduce wubbage

User avatar
whooo
 
Posts: 3
Joined: Wed Sep 17, 2014 4:23 pm

Re: VS1053 recording issue- strange noise

Post by whooo »

Just tried tying the arduino's 3.3v supply to the regulator output- the noise is still there.

I was actually using that mic originally and had the same issues with it. I also tried desoldering the mic from the amplifier board and biasing it using this circuit to see if there was any difference between feeding the line in and differential inputs of the vs1053, but the noise was still there.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: VS1053 recording issue- strange noise

Post by adafruit2 »

OK thx for the feedback, not sure if its something we can fix on-board but will keep it in mind when we look at the PCB!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”