3

The problem:

How to extend the memory for a sound buffer (intensively used) if:

  1. SD card library supports only one file open at a time (and I have one open already)
  2. EEPROM chips are able to stand about 100,000 write cycles only (see the datasheets!)
  3. I can't find anything else to buy! (a standard and durable RAM chip that loses its content when switched off would be the best).

About the 2nd point. Let's assume that the chip is 64KB and I want to use half of it for a circular sound buffer (it's small, I know). Let's also assume that a standard MP3 song is 160kbps and it's 3.5 min long. Given that, the EEPROM chip (with 100k write cycles limit) in this condirions will reach its limit after 3.2GB of played sound, which is about 762 songs, 44 hours. That can be reached in a single week! Replacing a chip every week is not an option. I'm not a fan of planned obsolescence...

Do you know any chip that will be right for the job? (and can be bought on eBay and it's affordable?)

Background:

I have built a WWW-controlled MP3 and online radio player (using ESP8266 and VS1003) and it's working really great, we're using it whole days, but ESP is not fast enough to handle WWW requests and play MP3 at the same time (especially from SD card), so the sound is paused for about 0.5 - 1 sec every time a www page is served (a really small page! Just basic HTML with a title and a list of file links!). SD card content cannot be cached for generating the pages on the fly (not enough heap memory) and two files cannot be opened at the same time by the SD library (one is open for the currently playing file - if not playing an online stream - and I'm currently closing it during reading and sending of requested html page). So I've got two memory problems: 1. serving the www pages and 2. buffering the online stream (usually not needed, most streams can play on my 4KB buffer without a glitch whole day but some of them are jamming very often - depends on the server). I'm thinking about both caching the pages (so I don't have to read them from SD and my music won't be interrupted) and creating a circular buffer (for live streams) in external memory chip. It does not need to keep the data after cutting the power. I've got about 24KB of heap left in my sketch (max) and it can fall even to about 6KB when a single folder's content is loaded to memory. It's not far away from heap overflow... I need to load at least the current folder (with long filenames).

1
  • This is a software problem, and properly solved there. Compared to an ordinary Arduino, an ESP8266 has quite a bit of buffer memory. The problem is that by not really implementing multiple tasks, you put yourself in the position of needing absurd amounts of buffer. Your best solution on this platform will be to rework the SD card access library to handle multiple files, or perhaps permit multiple instances to request sectors from the same card. Then your buffer need only be a few sector's size, which should not be a problem. May 5, 2016 at 0:42

2 Answers 2

5

A simple SPI SRAM chip. Available up to 128KB, such as the 23LC1024: http://www.microchip.com/wwwproducts/en/23LC1024

5
  • This chip is great! Thanks! Although it's very expensive as you compare it. You can get ESP-12 for $2.5 and this little chip costs above $8! For that price you can buy 3 pcs of ESP-12 (or 4pcs ESP-01 or 5pcs ATmega328P-PU!) and make memory out of them (by a sketch), even with WiFi interface... :] That's even more true for these Adafruit non-volatile modules (from JRobert's answer), which have 32KB only!
    – P.W.
    May 4, 2016 at 23:57
  • This is silly way to solve a software problem. May 5, 2016 at 0:41
  • @ChrisStratton Yeah, but it's the typical PC software developer request/solution. Software is running slow => throw more hardware at it.
    – Majenko
    May 5, 2016 at 0:43
  • 1
    This is not a software problem. If you download a radio stream from Internet and you don't have a big buffer, then you will eventually always get lags in sound. You can't speed up the whole Internet. I agree that SD library probably could be made better (to handle multiple files) but even then it wouldn't help because I'm getting like 2 sec delays when opening SOME of the files on my SD card! You can't cheat time and memory size by software. It's just physically not possible. Check out by yourself how WinAMP (for example) delays the online radio streams. It's about half a minute!
    – P.W.
    May 6, 2016 at 22:14
  • You should switch to SdFat instead of SD.
    – Majenko
    May 6, 2016 at 22:15
3

An FRAM chip?

  • Non-volatile (though you don't need that)
  • SPI or I^2C available on a breakout board from Adafruit
  • Or roll you own from a bare chip, if you're handy with Surface Mount Devices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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