+ Reply to Thread
Results 1 to 18 of 18

Thread: SD Card Reading/Writing

  1. #1

    Default SD Card Reading/Writing

    Hello,

    I am a senior in electrical engineering working on my senior design project, and not the most adept coder, especially not in Spin. For the project, we are sending up a weather balloon to gather atmospheric data. The sensors we are using are an altimeter, temperature sensors, compass, and accelerometer. The microcontroller we are using is the Parallax Propeller, and coding is done in Spin. The goal is to gather this data at certain time intervals and save this data to an SD card. The micro-SD card adapter we are using is the Parallax #32312. I am aware of the FAT16 (fsrw.spin) object by Tomas Rokicki and have downloaded it. However, I am unsure as to how to implement it. Attached is a simplified version of the code I have. The main file gathers and prints altitude data to Parallax Serial Terminal every 2 seconds. The two other files are just required objects. I was wondering if someone could show me the basic concept of how to create a file and write this data to the micro-SD card (Parallax #32312) instead of Parallax Serial Terminal using the fsrw object with this simplified example. Any help would be greatly appreciated.

    29124_altimeter.spinParallax Serial Terminal.spinsimplified_main.spin

  2. #2

    Default Re: SD Card Reading/Writing

    There is an awesome SD object (version 3) I think from a guy named Kye I think here on the forum. Go check that out. Really nice object!

    Good luck!

  3. #3
    Cluso99's Avatar
    Location
    Sydney/Brisbane Australia or 'sailing on the high seas'
    Posts
    9,256

    Default Re: SD Card Reading/Writing

    MoZak18: Firstly, welcome to this fabulous forum.

    Take a look at Kyes SD object. There is an App Note by Parallax describing this. There is a demo program using the sd card. Also look at KyeDos by Drac. I think this will get you there quicker.
    My Prop boards: CpuBlade, TriBlade, RamBlade, www.clusos.com
    Prop Tools (Index)
    Emulators (Index) ZiCog (Z80)
    Prop OS (also see Sphinx, PropDos, PropCmd)

  4. #4

    Default Re: SD Card Reading/Writing

    Its the full file system driver object in the object exchange. http://obex.parallax.com/objects/619/
    Nyamekye,

  5. #5
    Cluso99's Avatar
    Location
    Sydney/Brisbane Australia or 'sailing on the high seas'
    Posts
    9,256

    Default Re: SD Card Reading/Writing

    BTW you will see version 2 & 3 mentioned. It is confusing but the object in obex is the latest.
    My Prop boards: CpuBlade, TriBlade, RamBlade, www.clusos.com
    Prop Tools (Index)
    Emulators (Index) ZiCog (Z80)
    Prop OS (also see Sphinx, PropDos, PropCmd)

  6. #6

    Default Re: SD Card Reading/Writing

    Thank you for all the replies, as well as the link, I am taking a look at Kye's object right now. I have found another object however; SD_Card_Micro_01.spin by Greg Denson. It's for beginners and actually utilizes the fsrw object. I played around with it for only a few minutes the other day with no output whatsoever on PST. Any comments on this object relative to Kye's?

  7. #7

    Default Re: SD Card Reading/Writing

    I only use FSRW for my projects; it's been heavily vetted and the only SD card driver I trust. That said, it may not have as much hand-holding as you desire. You may need to dig in a little more to use it, but I think you'll be happy you did.

    In the beginning you need to decide how you're going to store information on the SD card. You could store data in a raw format, which is the most compact, but you might consider storing it in text format that can be displayed later; perhaps something that is comma-delimited. Using a comma-delimited file will let you open and view the file in a simple text editor, or open the file in a spreadsheet where you can use the values stored.
    Jon McPhalen
    Burbank, CA

  8. #8
    Cluso99's Avatar
    Location
    Sydney/Brisbane Australia or 'sailing on the high seas'
    Posts
    9,256

    Default Re: SD Card Reading/Writing

    Almost all of my programs currently use fsrw. Originally I thought that Kye's was slower but I think it is now at least as fast (anyone care to comment?).

    I am switching to Kye's drivers. They are documented nicely and use longer more meaningful names (too long for me as I like typeing short names because I am old school). Catalina uses a derived version of Kye's drivers, and Drac uses them for KyeDos. It also supports FAT32 (dont think fsrw supports FAT32) and also subdirectories. Also it comes with quite a lot of functionality like MKDIR etc.

    Just my 2c
    My Prop boards: CpuBlade, TriBlade, RamBlade, www.clusos.com
    Prop Tools (Index)
    Emulators (Index) ZiCog (Z80)
    Prop OS (also see Sphinx, PropDos, PropCmd)

  9. #9

    Default Re: SD Card Reading/Writing

    Ok. Well below I have attached the "beginner" object that utilizes the fsrw object. I only got the error message, and could not get the SD card to mount. Could someone else try this and tell me if they have any luck and/or any suggestions? Thanks as always.

    fsrw.spinParallax Serial Terminal.spinsafe_spi.spinSD_Card_Micro_01.spin

  10. #10

    Default Re: SD Card Reading/Writing

    > I am switching to Kye's drivers.

    That's too bad.

    > Originally I thought that Kye's was slower but I think it is now at least as fast

    Kye's drivers aren't even in the same ballpark in speed. But they are fast
    enough for some uses.

    > It also supports FAT32 (dont think fsrw supports FAT32)

    fsrw has supported FAT32 for quite some time.

    > and also subdirectories.

    fsrw does not support subdirectories.

  11. #11

    Default Re: SD Card Reading/Writing

    FSRW will always be faster. You can't even replace my block driver with FSRW's block driver and get the same speed.

    If you need speed go with FSRW.

    Kye's drivers aren't even in the same ballpark in speed. But they are fast
    enough for some uses.
    My drivers's readByte function goes at 3KBs... FSRW goes at 32KBs.

    ---

    My goal for my code was not to be fast though. My goal was to support all the file system functionality FSRW does not have.
    Nyamekye,

  12. #12
    Cluso99's Avatar
    Location
    Sydney/Brisbane Australia or 'sailing on the high seas'
    Posts
    9,256

    Default Re: SD Card Reading/Writing

    Thanks rokicki.

    I must do some proper speed tests as I sure don't want to slow access in ZiCog, or any of the new OS I am planning.

    In fact, I am using mb_rawb_spi26_rr006.spin for the low level pasm driver by lonesock. The upper level is fsrw26_rr006 .spin. (the _rr006 is to force release of the spi pins to tristate). I can simply recompile using fsrwFemto_rr007.spin. Apologies to anyone who had input to these drivers that have not been mentioned.

    Would it be difficult to support subdirectories?

    Perhaps I need to use a mix, using your pasm for the physical access??? I need some free time to perform some checks.
    My Prop boards: CpuBlade, TriBlade, RamBlade, www.clusos.com
    Prop Tools (Index)
    Emulators (Index) ZiCog (Z80)
    Prop OS (also see Sphinx, PropDos, PropCmd)

  13. #13

    Default Re: SD Card Reading/Writing

    @Cluso99

    My driver does extra FAT book keeping when writing files.

    You should get a nice speed bump if you Frankenstein both drivers together for reading... see the last post here: http://forums.parallax.com/showthrea...Updated!/page3 #140

    For writing you probably won't have much of a speed boost. But, I did not really test the Frankenstein'ed version of my driver much.

    And... I threw away the code... So... it will have to be re-written.
    Nyamekye,

  14. #14

    Default Re: SD Card Reading/Writing

    I put together my very first spin program to count slow pulses from an optical tach and write the counts on an SD card that I attached to an USB prototype board. I used bits and pieces of spin code from this forum. The program loads from the eeprom, runs fine and writes the data to the SD card as long as the board is connected to my computer through the USB port. When I try to run it on battery power with no USB connection, there is no file written on the SD card and a small red led next to the USB port is flashing. It appears that the propeller may be trying to communicate through the USB port and not booting the program from the EEprom.

    I would appreciate any suggestions?

    Thanks

  15. #15

    Default Re: SD Card Reading/Writing

    You are most likely suffering from the FTDI reset problem.

    You need check the state of the pin 31 when the prop chip turns on.

    If high then also turn the serial driver on.

    If low then do not turn the serial driver on.

    The issue is do to the FTDI chip being powered by the propeller chip's pin 30 when the propeller chip turns on. And then when the FTDI chip turns on it resets the propeller chip. Which causes an infinite reset loop.

    Thanks,
    Nyamekye,

  16. #16
    Cluso99's Avatar
    Location
    Sydney/Brisbane Australia or 'sailing on the high seas'
    Posts
    9,256

    Default Re: SD Card Reading/Writing

    Kye: Thanks for the readbyte speed comparisons.
    Have you compared readsectors? This is where I would require the speed, and of course writesector.
    My Prop boards: CpuBlade, TriBlade, RamBlade, www.clusos.com
    Prop Tools (Index)
    Emulators (Index) ZiCog (Z80)
    Prop OS (also see Sphinx, PropDos, PropCmd)

  17. #17

    Default Re: SD Card Reading/Writing

    I think FSRW is about 3X faster than my readData function. I think the writeData function for FSRW is 3X to 4X faster.

    My driver has about the same performance of the original FSRW library when using my readData and writeData functions.
    Nyamekye,

  18. #18

    Default Re: SD Card Reading/Writing

    Thanks for the tip, Kye!

    I used PST when debugging my program and I commented out all reference to it for the final version -except I missed the first two:

    PST :" Parallax Serial Terminal"
    PST.Start(115200)

    When I commented these out, it works fine.

+ Reply to Thread

Similar Threads

  1. SD card writing
    By Computer Geek 101 in forum Propeller 1 Multicore Microcontroller
    Replies: 3
    Last Post: 08-31-2010, 02:29 PM
  2. Need help writing to SD card
    By bulkhead in forum Propeller 1 Multicore Microcontroller
    Replies: 4
    Last Post: 09-21-2008, 09:00 AM
  3. Reading/Writing to ROM?
    By firestorm.v1 in forum BASIC Stamp
    Replies: 1
    Last Post: 05-15-2007, 06:02 AM
  4. writing to sd card
    By claym53 in forum Javelin Stamp
    Replies: 48
    Last Post: 03-07-2007, 10:29 PM
  5. Reading and writing to a CF Card.
    By stuart_w in forum General Discussion
    Replies: 5
    Last Post: 10-25-2006, 10:02 AM

Bookmarks

Posting Permissions

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