Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Storing & Reading Large Arrays on Micro SD Card?

  1. #1
    Member
    Join Date
    Jun 2015
    Location
    Palm Springs, CA
    Posts
    27

    Storing & Reading Large Arrays on Micro SD Card?

    Is there a way to do this besides saving a text file and reading back every digit, comma, brace, and bracket? I'm thinking of something like how PROGMEM arrays are stored and then read back during a sketch. I would like to convert a text file into something more efficient and store that on a micro SD card for a Teensy to read.

    If nobody does it that way, and everyone is just storing their large arrays as text files on SD cards, I would be interested in seeing an example instead of re-inventing the wheel by coding it myself.

    Please excuse me if this has been discussed in another thread. I searched and was not able to find it. Also searched the Arduino forum, and the closest thing I found is someone suggested using a similar method as this code but modifying it for SD cards instead of EEPROM:
    http://playground.arduino.cc/Code/EEPROMWriteAnything
    I'm a bit rusty on pointers and need to brush up on that subject to understand what it's doing, then figure out what the equivalent is on an SD card. Is this the best route to follow? I would imagine I'd have to code something in C language to run on a computer (something I have little knowledge of) to convert the text file. Any advice would be greatly appreciated.

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,021
    How large are your arrays? PROGMEM is not needed on teensy as long as you declare the array const it will be stored in flash without all the headaches of PROGMEM calls

  3. #3
    Member
    Join Date
    Jun 2015
    Location
    Palm Springs, CA
    Posts
    27
    Megabytes or gigabytes in size. Too large to fit in flash memory.

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,224
    Quote Originally Posted by NewLinuxFan View Post
    Is there a way to do this besides saving a text file and reading back every digit, comma, brace, and bracket?
    you can write anything to SD cards and read it back.
    writing junks of large amount of binary data is standard procedure.
    so what is the problem?

  5. #5
    Member
    Join Date
    Jun 2015
    Location
    Palm Springs, CA
    Posts
    27
    Thank you. I did a quick search, and it looks like there are some discussions on that:
    https://forum.arduino.cc/index.php?topic=547210.0
    https://hackingmajenkoblog.wordpress...on-an-arduino/

    I'm guessing there's also a discussion or guide somewhere on converting C language arrays into binary format using a computer.

  6. #6
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,224
    Quote Originally Posted by NewLinuxFan View Post

    I'm guessing there's also a discussion or guide somewhere on converting C language arrays into binary format using a computer.
    No conversion required, nowadays all data are internally stored as binary in a computer. Search for difference of 'printf' and 'write' for writing formatted or binary data respectively to disk.

  7. #7
    Member
    Join Date
    Jun 2015
    Location
    Palm Springs, CA
    Posts
    27
    Thanks again. I'll read up on that. This is new stuff for me. Sounds like the learning curve is not as bad as I thought it might be.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •