FAT32/SDHC library for Wave and other shields

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: FAT32/SDHC library for Wave and other shields

Post by fat16lib »

zachtos,

There is almost no way to tell if a card will work without trying it. Manufactures make changes often and don't change the part number. Your working card is Version 3.7 of a product they call SD02G.

I have an old 16 MB card that came with a Canon camera. I use it for testing and it never fails. It came formatted FAT12 and I forced it to be FAT16 by using very small clusters. It is still fast enough to play wave files.

I would love to have one or two of your 128 MB cards for testing. Send me a PM so I can arrange to buy them.

Finally here is what makes or breaks the use of a card. The small InCOMM chip in the picture below is the flash controller. This is the part that provides the SPI interface. There are many versions of this part from at least six semiconductor companies. It is really hard to get data sheets for these parts. I have found a few by searching Chinese sites for part numbers.

Here is the picture:
Attachments
SdInside.png
SdInside.png (630.64 KiB) Viewed 11385 times

zachtos
 
Posts: 78
Joined: Sun May 03, 2009 8:18 pm

Re: FAT32/SDHC library for Wave and other shields

Post by zachtos »

New card doesnt work either!!!! SO ANGRY@@$!@!! $$100 gone total now and nothing to show for it.

Code: Select all

init time: 39

Card type: SD1

readCID failedSD error

errorCode: 10

errorData: D
one from prior post, HP 1gb, formatted using the aformentioned utility and vista format to fat16 w/ 32kb clusters, no avail

I may be able to return this one, but I am stuck w/ the 128mb unless someone wants to buy them.

http://www.newegg.com/Product/Product.a ... 6820208043
$6 ea newegg

http://www.transcendusa.com/Support/DLC ... SxxSDC.pdf
datasheet

will this one work? of course, I forgot, no one can tell me...

I bought 10 of these areduino waveshields, I'm spending more on SD cards then the #@$@# shields, how about a refund for such a frustrating product...??? perhaps I should have stuck with ISD recorders afterall.

zachtos
 
Posts: 78
Joined: Sun May 03, 2009 8:18 pm

Re: FAT32/SDHC library for Wave and other shields

Post by zachtos »

WELL I"LL BE DAMNED!

the new v1.1 board can play all those 'broken' SD cards of mine! V1.0 can not! good day sir.

User avatar
THW_Mark
 
Posts: 36
Joined: Wed Aug 29, 2007 6:33 am

Re: FAT32/SDHC library for Wave and other shields

Post by THW_Mark »

@fat16lib

in your current google code, the pispeak example has a definition for "redled". This is not used in the code, as far as i can see. So I think you can remove that from the example.

Great work at the lib by the way! :)

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: FAT32/SDHC library for Wave and other shields

Post by fat16lib »

THW Mark,

I just did minimal mods to ladyada's pispeak. I didn't catch that extra #define.

User avatar
THW_Mark
 
Posts: 36
Joined: Wed Aug 29, 2007 6:33 am

Re: FAT32/SDHC library for Wave and other shields

Post by THW_Mark »

ah ok :) i started with your lib directly, so i didnt notice. i was just wondering what that define was doing there :)

User avatar
chief robot
 
Posts: 37
Joined: Wed Jun 25, 2008 8:04 pm

Re: FAT32/SDHC library for Wave and other shields

Post by chief robot »

Hi,
I was successfully using a ProSpec 1GB card, but suddenly it stopped working.
I can view it on my desktop with my card reader fine.
I bought a new card as someone here recommended some that worked. I bought a Sandisk 4 GB SDHC card , but that doesn't work either. I can't run the test program as a file seems to be missing - SdCard.h My card reader also does not read the new card. I have 4 cards total and they are all different, but all give me the same error.

Wave test!
Free RAM: 1173
Card init. failed!
SD I/O error: 1, 0

Am I doing something wrong?
Thanks.

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: FAT32/SDHC library for Wave and other shields

Post by fat16lib »

Are you using the latest version of the library, WaveHC, and test sketch, SdReadTest.pde? You must run WaveHC and SdReadTest.pde from the latest version of the download file.

If you are using wavehc20090519 or later read the changes.txt file. The class SdCard became SdReader so that WaveHC could be used with another library that was already using that name.

Error code 1 means that the card does not respond to the first command which sets the card to SPI mode. The error codes for the SD card are in the file SdReader.h.

This error means there is a fundamental hardware problem that has nothing to do with the SD card's format.

The fact that four types of SD cards fail suggest there is some problem with with the Arduino/Wave Shield. Look at all of the solder joints and make sure the shield is plugged into the Arduino correctly. I had one problem where the pins were plugged in "off by one".

It is hard to help more since there is so little information when the SD card fails on the first command.

Madeleine
 
Posts: 4
Joined: Thu Jun 04, 2009 2:33 am

Re: FAT32/SDHC library for Wave and other shields

Post by Madeleine »

Question: How fast is the _expected_ overhead seektime to open up a file before starting to play it?

I've timed (with millis()) the time to do a

file.open(root, fname)

and it takes everything in between 4 and 99 milliseconds.

4 is rather ok, 99 is a bit too long for concatenating sounds.

How can I speed this up?

By pre-opening the next file? (Gets rather nasty, codewise but could be solved with some sort of playqueue)
Get a faster card? Or is that wasted money?
By doing anything else?

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: FAT32/SDHC library for Wave and other shields

Post by fat16lib »

You can't speed it up reliably. SD cards have terrible latency when you start to read in a new area. The read latency can be up to 100 ms. The delays happen at random times as the SD controller tries to optimize read ahead.

In the worst case opening a file could take much longer than 100ms. Use the root directory and have the minimum number of files possible.

Here is part of the SD spec on latency:
4.6.2.1 Read
For a Standard Capacity SD Memory Card, the times after which a timeout condition for read operations occurs are (card independent) either 100 times longer than the typical access times for these operations given below or 100 ms (the lower of the two). The host should use 100 ms timeout (minimum) for single and multiple read operations rather than using TAAC and NSAC.
Faster cards have higher sustained transfer rate but still have the same latency start-up glitches. The Arduino is too slow to take advantage of higher transfer rates.

You may get some advantage by opening a number of files. The only limit on the number that can be open is the amount of RAM you want to use. I think it takes about 30 bytes per file. If you play an open file a second time be sure to call rewind() before playing it again.

Also there will be latency when you call create(file). It needs to read the wave file meta-data and pre-buffer data.

Madeleine
 
Posts: 4
Joined: Thu Jun 04, 2009 2:33 am

Re: FAT32/SDHC library for Wave and other shields

Post by Madeleine »

Thanks for an utterly informed answer. I think I will elaborate on my playqueue and spend some time opening files in advance. I concatenate phrases & words (like tts, but just the generation of speech based on arduino input/calc) and do not really want to much pause between them.

Minimizing the files to e.g. syllables+words is not an option as I have to have too much data in the application instead.

User avatar
ericzundel
 
Posts: 41
Joined: Thu Aug 06, 2009 10:42 pm

Re: FAT32/SDHC library for Wave and other shields

Post by ericzundel »

Hi I read through the WaveHC docs and the thread here and didn't see an answer to this question, so here goes.

I was really hoping it would be possible to read from 2 files at the same time. What I've done is combined the sample program dap_hc.pde with my own code for reading files that contain data to output onto an LED matrix. While I can get either to work on their own, I get SD I/O errors (somtimes error 3, sometimes error 10) if I try to run both reads in parallel. each loop loops similar:

- loop through the root directory until you find a file ending in .wav (or .led)
- Open a FatReader on that file
- Pass the periodically pull in data from the FAT reader.

I notice that if i'm scanning the directory while the wave file is running, the audio stutters. If I check the error status with the sdError() function from the demo sketch, it returns the i/o error (and halts the program).

My theory is that the FatReader/SdReader might towrk, but the problem lies in the fact that the Wave library relies on an interrupt and the interrupt may be causing re-entrancy in the library. If that's the problem, I could work around that by changing the interrupt code to work a different way.

So I guess what I'm asking is, "should I be able to get this to work with the WaveHC library" as is, is it possible but would take a lot of work, or is it just practically impossible.

Thanks a million,
-Eric.

User avatar
ericzundel
 
Posts: 41
Joined: Thu Aug 06, 2009 10:42 pm

Re: FAT32/SDHC library for Wave and other shields

Post by ericzundel »

I did some work to minimize file i/o and added a few noInterrupts(); ... interrupts() guards and the project is working much better.

doshir
 
Posts: 1
Joined: Thu Oct 22, 2009 11:36 pm

Re: FAT32/SDHC library for Wave and other shields

Post by doshir »

I succeeded to access subdirectories and w/r files in the subdirectory with minor modification for SdFay.cpp in WaveRP library.

$ diff libraries/SdFat/SdFat.cpp sdfat_save/SdFat.cpp
279d278
< fileSize_ = 32 * 65534; // Fat16 and Fat32 sub dir entry max : 65534
288a288
> fileSize_ = dir.fileSize;

With this modification, depends on size of the SD/SDHC card, with FAT16 formatted 2GB card, a subdirectory can hold 1022 files.
It is not fully tested yet. Just wrote 1000 unique short files then verified in a subdirectory.
For increase the number of the files, it need to touch uint8_t SdFile::create(SdFile &dirFile, char *fileName) but 1022 files is enough for me now.

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: FAT32/SDHC library for Wave and other shields

Post by fat16lib »

doshir,

your mod will result in a corrupt file system.

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

Return to “Arduino Shields from Adafruit”