Go Down

Topic: Which SD library to use ?!? (Read 2251 times) previous topic - next topic

Andreas1984

Jan 21, 2014, 04:44 pm Last Edit: Jan 21, 2014, 04:48 pm by Andreas1984 Reason: 1
Hello,

I have an application, where I want to have a fast reading speed from the SD-Card, to keep the reloading time small.

The reload of new data takes 1 mS. (After eeach 512 Bytes)

Currently I am using the SD library that comes with the Arduino IDE - Some people have told, that this library is old and requested me to use the sdfatlib http://code.google.com/p/sdfatlib/

However, I want to ask here if you really can win performance by using this lib... By the way I am using a DUE and the ethernet shield, which hosts also an sd card...

Do you think, that using a faster SD-Card, like for example a "SanDisk MicroSDHC 8GB Extreme Pro" could also bring some performance (now I am using an old SD-Card)... Or is the bottlenack on the arduino side?

Thx.



fat16lib

I am the author of SdFat.

The Arduino SD.h library is a wrapper for a very old version of SdFat so it is missing a number of bug fixes. 

SdFat has better native SPI support so is often faster.

A "SanDisk MicroSDHC 8GB Extreme Pro" is not likely to be faster than cheaper cards.  High performance consumer cards are optimized for very large, many MB,  transfers using the 4-bit SDIO bus.  Many less expensive cards perform better than these high end cards on Arduino with smaller transfers using the 1-bit SPI bus.

Industrial cards optimized for embedded applications give the best performance.

Only testing with you application will determine which card preforms best.

Here are the SdFat bench test results for several cards on Due using 512 byte reads and writes.

Full size 8GB Extreme Pro
Quote

Buffer size 512 bytes
Starting write test.  Please wait up to a minute
Write 242.81 KB/sec
Maximum latency: 81073 usec, Minimum Latency: 1496 usec, Avg Latency: 2106 usec

Starting read test.  Please wait up to a minute
Read 752.96 KB/sec
Maximum latency: 3244 usec, Minimum Latency: 594 usec, Avg Latency: 677 usec


Amazon basics 8 GB microsSD
Quote

Buffer size 512 bytes
Starting write test.  Please wait up to a minute
Write 252.65 KB/sec
Maximum latency: 285502 usec, Minimum Latency: 1029 usec, Avg Latency: 2023 usec

Starting read test.  Please wait up to a minute
Read 1299.29 KB/sec
Maximum latency: 2562 usec, Minimum Latency: 323 usec, Avg Latency: 391 usec


A 1 GB ATP Industrial grade card http://www.digikey.com/product-detail/en/AF1GSDI-5ACXX/AF1GSDI-5ACXX-ND/3770372.
Quote

Buffer size 512 bytes
Starting write test.  Please wait up to a minute
Write 1104.17 KB/sec
Maximum latency: 63529 usec, Minimum Latency: 395 usec, Avg Latency: 461 usec

Starting read test.  Please wait up to a minute
Read 2206.39 KB/sec
Maximum latency: 452 usec, Minimum Latency: 228 usec, Avg Latency: 229 usec


Wintec 2GB Industrial SD http://www.wintecind.com/OEM/Flash/SD/H6.html.
Quote

Buffer size 512 bytes
Starting write test.  Please wait up to a minute
Write 1289.91 KB/sec
Maximum latency: 2439 usec, Minimum Latency: 348 usec, Avg Latency: 395 usec

Starting read test.  Please wait up to a minute
Read 2865.15 KB/sec
Maximum latency: 359 usec, Minimum Latency: 175 usec, Avg Latency: 176 usec

Andreas1984

Hello,

thx for this valuable information.

I have downloaded your lib and trying to get familiar with it.

The information regarding the Industrial SD-Cards is highly valuable!

I have some more questions:

a) Are normal SD-Cards faster then micro SD-Cards? - I guess yes - Your bench results seem to be made with normal SD-Cards.

b) If yes, can you recommand an Arduino SD-Card Shield, that hosts a normal SD-Card?

Thx




fat16lib

Quote

a) Are normal SD-Cards faster then micro SD-Cards? - I guess yes - Your bench results seem to be made with normal SD-Cards.

There is no reason microSD cards can't be fast on Arduino.  The old Amazon Basic card above is faster than the costly Extreme Pro.  It depends on how well a card performs for small transfers on the SPI bus.

MicroSD industrial cards exist but I have not done tests.  The key to good performance is to choose cards with single-level cell (SLC) NAND flash technology. 

Consumer cards use multi-level cell (MLC) NAND flash which stores multiple bits per cell.  Using eight levels to store three bits per cell is common.  This lowers the cost but the flash controller becomes complicated and performance suffers for small transfers (a few 512 byte blocks).

Quote
b) If yes, can you recommand an Arduino SD-Card Shield, that hosts a normal SD-Card?

I use a homemade shield.  The only connection to SPI on the Due is the SPI header.  Also Due is 3.3V so no level shifters are required.

pito

#4
Jan 22, 2014, 08:49 pm Last Edit: Jan 22, 2014, 08:52 pm by pito Reason: 1
My experience with microsd cards is - the smaller the volume the faster. I had a 128MB microsd Nokia, it did 980kB/sec r/w while 4Gb cheapo microsd (3 var brands) did 300-400kB in the same app.

fat16lib

#5
Jan 22, 2014, 09:12 pm Last Edit: Jan 22, 2014, 09:27 pm by fat16lib Reason: 1
Quote

My experience with microsd cards is - the smaller the volume the faster. I had a 128MB microsd Nokia, it did 980kB/sec r/w while 4Gb cheapo microsd (3 var brands) did 300-400kB in the same app.


This is often true.  Your card is probably old so has old technology, not the new MLC cards designed to support fast transfers for video on modern  phones.  Modern cards only support SPI to satisfy the spec.

Run SdInfo on your card to see when it was made.

It's the technology, not the size.  I have some old 2 GB cards that are very fast.  

Corsair made consumer cards for a while and they were SLC.  The 1GB Corsair 133X card is the fastest I have seen on Due.  My card was manufactured in 2006.

One interesting development.  Some of  the newest low cost cards preform well on Arduino.  These are class 2/4 SDHC cards like the blue SanDisk cards.   The problem is you can't be sure of the performance since the internals of these cards change often so I can't recommend cards.

Go Up