Pages: [1]   Go Down
Author Topic: How long time does is take to write to an SD?  (Read 2459 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

How long time does it take to append 150 chars to a file on an SD card?

How much power does it use while writing? I guess it depends on the SD card. Any min/max values for a 2 GB microSD?

I am making a gps logger, and in the case of power failure, I would like to add a capacitor to finish writing.

~Frank
Logged

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1656
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The time to do a write depends on the card and the state of the card.  The SD spec allow a card to take as long as 200 ms.

Run the SdFat bench example.  it will print the max latency.  Here is output for a typical card with a max latency of 156 ms:
Quote
Type any character to start
Free RAM: 1035
Type is FAT16
File size 5MB
Starting write test.  Please wait up to a minute
Write 192.83 KB/sec
Maximum latency: 155956 usec, Avg Latency: 513 usec

Starting read test.  Please wait up to a minute
Read 295.49 KB/sec
Maximum latency: 2808 usec, Avg Latency: 333 usec

Done
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got:

Free RAM: 1043
Type is FAT16
File size 5MB
Starting write test.  Please wait up to a minute
Write 86.71 KB/sec
Maximum latency: 163952 usec, Avg Latency: 1143 usec

Starting read test.  Please wait up to a minute
Read 142.85 KB/sec
Maximum latency: 5392 usec, Avg Latency: 690 usec

So what does the lantency mean? Is it to access the SD card (initialize, open the file,...)?
So the total time will be the latency (163 ms) + write time for 150 bytes (150B/86.7kB/s = 1.7 ms) or maybe write time for a block (5,8 ms), or maybe even write time for 2 blocks if the data spans 2 blocks?

Any idea how much power a common microSD card uses? Will it use a lot power durring the latency time?

Just tried it again:

Write 83.57 KB/sec
Maximum latency: 332064 usec, Avg Latency: 1186 usec
Read 143.75 KB/sec
Maximum latency: 5392 usec, Avg Latency: 686 usec

332 ms is A LOT!

One more time:

Write 84.39 KB/sec
Maximum latency: 321320 usec, Avg Latency: 1175 usec
Read 143.76 KB/sec
Maximum latency: 5424 usec, Avg Latency: 686 usec


~Frank
Logged

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1656
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The bench example writes 100 bytes at a time.  The bench example writes a five MB file so 50,000 write calls are executed.

The maximum latency is the maximum time to execute this statement:
Code:
  file.write(buf, sizeof(buf))
Where buf is a 100 byte array.

A latency of over 300 ms is unusually long.  150-200 ms is more common. 

The maximum latency generally occurs when a SD card erases a large number of blocks of flash memory.  It can also be related to wear leveling or remapping a bad spot.
Logged

Pages: [1]   Go Up
Jump to: