EEPROM better than SD card for audio ?

I have a project that uses up to 9 audio announcements of about 4 seconds duration.
At the moment I am using a SD card, and the waveHC library, but unless I use a SD card of 250Mb or less it is unreliable, and sometimes won't read the card.

Would it be better to use some EEPROMs ? the audio tracks are between 250 and 850k, but I am sure i can reduce the sampling without hassles.

I just need some advise here..........

It seems that there are many people who have the same problem with the larger memory SD cards, and I havn't found any answers posted yet.
The real problem is that it is intermittent, the card just doesn't respond after a while, replacing it works again for a while.
Replacing the card with a 250Mb version ( when I can find them ) works fine every time.

I have tried changing the buffer chip to several different types, and decoupling caps right on the socket of the card, but not found the answer........

John,
I think reading from a serial EEPROM would probably work for you.
Take a look here
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=80
See how many you'd need for the storage you're after.
They're in Bits, so divide by 8 or 12 or 16 or whatever width you're using for your DAC.

Thanks Bob
I think the first thing I must do is rerecord the anouncements with a view to making them smaller files - it didn't matter before with the SD cards.
Then I can see what size I must work on

OK I have broken the announcements into 14 slices of WAV files totalling 259k ( I could probably trim them a little more )

In an ideal world I could just swap the SD card for a pair of AT24C1024W EEPROMs that are available locally.

I don't really understand how the waveHC library interacts with the DAC and the SD card, presumably the FAT side would be a much simpler random address on the EEPROM for the various sound files ?

To record the WAV files on the EEPROM would presumably be a separate sketch to import each byte or batch of bytes of the WAV file from the PC, via the Arduino board, and store them on the EEPROM?

I would then plug the eeprom into a socket on the project board, which has a 328 chip to read from the eeprom and feed to the DAC or whatever ?

am I on the right track, or trying to reinvent the wheel?

Your description sounds exactly like I was thinking.
I wouldn't be using a library, would just be reading from the known start address and writing to the DAC.
But that's just me.

Maybe it is a problem with your code and the way it reads the files, as if it is loooking for something and searches the whole thing
I've been using 4gb sd cards for a while now datalogging and reading back the information and I've had no hassles regardless of the size of the file
id check your code first for a bug before changing the storage medium, especially as an sd card is very cheap and very simple to use,
if your code is funny, complicating it with serial eeprom probably wont help

The code I have been using is basically the example from the guy who writes the FAT libraries, and he reckons the wave HC is the one best suited to audio.
I have to have this project sorted out without the audio problem . The audio part is just a small part of the project, which superimposes graphics on a HD LCD screen, which is working fine ...

I will try your idea with no libraries Bob, and start with a small example with just a couple of files, I think I can master the eeprom part, its similar to the RTC chip eeprom on the last project , which is working well.
I am not too sure about the DAC, but I have downloaded the datasheet and see what I can do.

The wavehc code is extremely complicated for us beginners, but I am hoping most of it is for the SD card side....

OK I have bought a 24C1024 eeprom, made up a little Mgyver shield, and studied the datasheet.

I have tried the benchmark example of Arduino Playground - I2CEEPROM24C1024
but it gets to " writing data " and hangs.

I notice there is no "begin" in the setup, which I think should be the memory reset from the datasheet ?

I just want to try writing to and receiving from the eeprom for now.

I will try through the night and see how I get on.

My next task will be to find how to download the WAV files in bytes and store them on the eeprom.

I eventually went back to the serial printout, which I thought was hung, and it reports:

E24C1024 Library Benchmark Sketch

--------------------------------
Write By Byte Test:

Writing data:...........................DONE
Total Time (seconds): 722
Write operations per second: 181
--------------------------------

--------------------------------
Read By Byte Test:

Reading data:...........................DONE

Total Test Time (secs): 83
Read operations per second: 1579
Total errors: 0
--------------------------------

If I cant get more than 1579 bytes ( or is it talking bits? ) I cant see it providing data fast enough to the DAC for the audio ???

That does seem slow.
How're you writing to the DAC?
If you figure an arduino with 16,000,000 clocks/second,
needs 8 clocks to read a byte serially in a burst mode,
so you're down to 2,000,000 reads/second,
and 8 clocks to write it out in a burst mode,
so you're down to 250,000 reads/writes/second,
and it takes 100 clocks for the instructions to move the data from input register to output register and other stuff,
so you're down to 2,500 reads/writes/second.
Doesn't leave much room for quality sound does it.
Doesn't sound like SD card with serial SPI would do much better.
If you could do byte reads/writes you could get back to ~40,000 reads/writes per seconds.
Or go with external hardware - load start address into a counter, have EEPROM data bus be same as DAC bus, address clock to counter be the data clock into the DAC kind of thing.

For eproms, the read time is different than write time. It takes about 5ms for a byte or page to be written, and this makes for a maximum write rate of 200 bytes or pages (of 128 bytes) per second.

Yes, read times are much faster than write times, that was not an issue.
The issue is the time it takes for the serial transfers from EEPROM to the DAC. Overall it would seem too slow.

Of course the other thing is that this test addresses, then writes, to each byte in turn.

I will be random addressing approx 5 Kb at a time, so just need to send the start address once, then read a whole string of bytes.

I havnt even connected the DAC yet, this was just a speed test routine in the library

I am going to see if I can test writing a couple of bytes , then test the retrieve time. I will not actually be writing to the eeprom at all once it is "recorded" except for the dummy write before each random read ( as per data sheet for the 24C1024 )
This is all interesting new ground for me.

The DAC I am using at the moment is connected as in the top right of

Can't you read an SD card like Openlog at 115kbps? It's buffered so the code doesn't have to wait for each byte to arrive? I've been going the other way at this speed, so mine is much more difficult.

I have had one last try at using the SD card.

I modified the Adafruit wave library to take my bcd inputs, but its exactly the same, it reads the 256Mb cards, but not most of the 2Gb cards.

Heres the code below, I dont know if there is something stupid, otherwise I will carry on with the eeprom try, which I am rather out of my depth on I must confess...

#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;	// This holds the information for the file we're play

WaveHC wave;	// This is the only wave (audio) object, since we will only play one at a time

int talkingPin = 19;  // high while audio playing to video chip to keep number on.
int aPin =18; //define pin numbers for bcd inputs from HT12D
int bPin =17;
int cPin =15;
int dPin =16;
int vtPin = 14; // define pin numbers for valid transmission input from HT12D
int track ; // define audio track number
int bcda ; // define bcd digitalreads for BCD/dec conversion
int bcdb;
int bcdc;
int bcdd;
int valid ;  // to be set high if vt in

// this handy function will return the number of bytes currently free in RAM, great for debugging!
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);

}

void setup() {
  // set up serial port
  Serial.begin(9600);

  pinMode (aPin,INPUT);  //bcd inputs from HT12
  pinMode (bPin,INPUT);
  pinMode (cPin,INPUT);
  pinMode (dPin,INPUT);
  pinMode (vtPin,INPUT);  // valid trasnmission input
  pinMode (talkingPin,OUTPUT); // display enable to vga chip

  putstring_nl("WaveHC with 9 inputs");

  putstring("Free RAM: ");	 // This can help with debugging, running out of RAM is bad
  Serial.println(freeRam());	// if this is under 150 bytes it may spell trouble!

  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

  // pin13 LED
  pinMode(13, OUTPUT);

   if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you  *****  TRIED BOTH
 // if (!card.init()) {	   //play with 8 MHz spi (default faster!)
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);				    // then 'halt' - do nothing!
  }
  // enable optimize read - some cards may timeout. Disable if you're having problems *** TRIED WITH AND WITHOUT AND true
 // card.partialBlockRead(false);
  // Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;				     // we found one, lets bail
  }
  if (part == 5) {			     // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();	// Something went wrong, lets print out why
    while(1);				    // then 'halt' - do nothing!
  }

  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?

  // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);				     // then 'halt' - do nothing!
  }

  // Whew! We got past the tough parts.
  putstring_nl("Ready!");
}

void loop() {

  bcda = digitalRead ( aPin );  // read the state of the video micro "decode" data outputs  
  bcdb = digitalRead ( bPin );
  bcdc = digitalRead ( cPin );
  bcdd = digitalRead ( dPin );
  valid = digitalRead ( vtPin );  // check if signal received, set valid high

  if (bcda==1 && bcdb==0 && bcdc == 0 && bcdd == 0 ) { //longwinded bcd / dec decoding to give track number to be read
    track = 1;
  } 
  if (bcda==0 && bcdb==1 && bcdc == 0 && bcdd == 0 ) { 
    track = 2;
  }
  if (bcda==1 && bcdb==1 && bcdc == 0 && bcdd == 0 ) { 
    track = 3;
  }
  if (bcda==0 && bcdb==0 && bcdc == 1 && bcdd == 0 ) { 
    track = 4;
  }
  if (bcda==1 && bcdb==0 && bcdc == 1 && bcdd == 0 ) { 
    track = 5;
  }
  if (bcda==0 && bcdb==1 && bcdc == 1 && bcdd == 0 ) { 
    track = 6;
  }
  if (bcda==1 && bcdb==1 && bcdc == 1 && bcdd == 0 ) { 
    track = 7;
  }
  if (bcda==0 && bcdb==0 && bcdc == 0 && bcdd == 1 ) { 
    track = 8;
  }
  if (bcda==1 && bcdb==0 && bcdc == 0 && bcdd == 1 ) { 
    track = 9;
  }  

// if ( valid == HIGH ){
 
  if (track==1 ) {
    playcomplete("doornum1.wav");
  }
  else;
  if (track==2) {
    playcomplete("doornum2.wav");
  }
  else;
  if (track==3) {
    playcomplete("doornum3.wav");
  }
  else;
  if (track==4) {
    playcomplete("doornum4.wav");
  }
  else;
  if (track==5) {
    playcomplete("doornum5.wav");
  }
  else;
  if (track==6) {
    playcomplete("doornum6.wav");
  }
  else;
  if (track==7) {
    playcomplete("doornum7.wav");
  }
  else;
  if (track==8) {
    playcomplete("doornum8.wav");
  }
  else;
  if (track==9) {
    playcomplete("doornum9.wav");
  }
 //}
}
// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  if (wave.isplaying) {//   set display enable high to vga chip
    digitalWrite(talkingPin, LOW);
  }
  else
  {  
    digitalWrite(talkingPin, HIGH);
  }
  while (wave.isplaying) {

  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
 //if (wave.isplaying) {// already playing something, so stop it!  cant happen with talkinpin 
 //  wave.stop(); // stop it
//}
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); 
    Serial.print(name); 
    return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); 
    return;
  }
 if (valid == 1){  //  wont run without this here
    // ok time to play! start playback
    wave.play();

  }

}

John,
What is your hardware connection to the SD card?
Are you using an IC to buffer the signals from the Arduino to get them down to 3.3V levels?
How are you powering the SD card? They can be power hungry and need more than the 50mA an FTDI chip can put out, if that is your source for example.

I followed the design of this shield when I added parts for my Bobuino, and it works great with 2 GB cards.
http://www.ladyada.net/make/logshield/design.html
I used a 74AC125D for the data buffer and IXF25001MEV33 for a 3.3V regulator.

This is really frustrating, I used the same circuit as you Bob, I made 4 of these units and they all have the same problem, I have a separate 3.3v 150mA regulator, I scoped the output and its steady. I tried a couple of different voltage buffer chips, I have decoupled everything.

Tomorrow I think I will make a separate part on perf/vero board, and try it with all the recommended part numbers if I can get them.

Have you tried yours playing back audio clips? I can't see it making any difference, I dont think mine is even getting that far.

With it fitted to the board I have no serial to see whats happening.

I would like to go the DS cvard route, the eeprom is fiddly recording to.

I don't know enough about this to offer advice. But what i can say it that i bought a adafruit wave shield a few months ago and have been using a 2gig card with only a minor problem. when i first got the card i put some files on it all was ok. I changed the files using a diffident computer and lynux instead of my windows. I then spent a whole day trying to get to the bottom of a intermittent sound output. For the first half of the day i put it down to another part of the project that i had just been working on, not the audio which i thought was working fine. i did do a quick check on the audio and it read the first file fine, so i put it down to some other change in the code. Anyway after lots of swearing and head scratching and taking the code back to a version from a week earlier i eventually found the sd card was doing all sorts of strange things. Sometimes recognized files sometimes didn't , sometimes player weird clicks instead of the audio. Took the card home reformatted put the original files on again using windows and it all worked again. It still worked fine now it's installed in a interactive display for kids and plays nature noises, had no problems since. Still don't know why it did it. I was planning on using a 32gb card for a new project so i hope it they do go above 250mb :slight_smile:

John,
I haven't done more than the SdFat provided tests.
I get Write & Read results of ~160K & 280K with a Sandisk Ultra 15 MB/s SDHC 16GB card on the Benchmark test.

"With it fitted to the board I have no serial to see whats happening."
Huh? What does the SPI to the SD card have to do with Serial out to a monitor?