Shop OBEX P1 Docs P2 Docs Learn Events
SD card writing — Parallax Forums

SD card writing

Computer Geek 101Computer Geek 101 Posts: 179
edited 2010-08-31 07:29 in Propeller 1
I am building a data logger. The device will get data every ½ second. Is it more efficient to store like 15 seconds of data in ram then write all at one time or write data every ½ second? Thanks for the help.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-31 07:14
    SD card already uses buffering because data is read or written in blocks of 512 bytes. The I/O routines use a 512 byte RAM buffer to hold the data, then write the buffer to the SD card when the buffer becomes full. SD card writes can take different amounts of time depending on the amount of buffering built into the SD card and how efficient the space management algorithms are that are part of the SD card's firmware.

    You probably want to run the SD card writing routines in their own cog because of this unpredictable write time. That way, your datalogging code can continue to read sensors, collect and format data, timestamp it, and otherwise prepare it to be written to the SD card even if the SD card "hiccups" occasionally taking as much as 1/2 second to 1 second to finish writing a 512 byte sector.
  • Computer Geek 101Computer Geek 101 Posts: 179
    edited 2010-08-31 07:20
    Thanks Mike. It does run in its own cog. I just didnt know if I could save battery life by doing a large buffer.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-31 07:29
    Power consumption is very dependent on the specifics of the particular SD card and on what's going on internal to the card. You have to remember that, before a block can be written, the card's firmware has to make room for it in an erased sector of memory that can be 4K or 16K or larger. If the block is being updated rather than being written for the first time, the other blocks in the sector may have to be relocated as well, all of which takes additional time and energy.
Sign In or Register to comment.