Store and read data to SD CARD

Peavey5150Peavey5150 Posts: 11
How do I save data to a text file from the propeller activity board itself, and then have the propeller activity board read the data back from the SD card after rebooting the system ?

This Project is for machine learning. Robot learns from each trial and would remember data after shut down.

C lang

activity bot 360
propeller activity board wx


  • 5 Comments sorted by Date Added Votes
  • Peavey5150Peavey5150 Posts: 11
    edited January 6 Vote Up0Vote Down
    I think I got it from the examples
    #include "simpletools.h"                      // Include simpletools header    
    int DO = 22, CLK = 23, DI = 24, CS = 25;      // SD card pins on Propeller BOE
    int main(void)                                // main function
      sd_mount(DO, CLK, DI, CS);                  // Mount SD card
      //FILE* fp = fopen("test.txt", "w");          // Open a file for writing
     int  val ;
    // fwrite(&val,sizeof(val),1,fp);
     //val =-100000;
    // fwrite(&val,sizeof(val),1,fp);
     // fclose(fp);
     // looks like I just needed to  modify  this line
     FILE* tp = fopen("test.txt", "r");  
     print("val = %d\n" ,val);
     print("val = %d\n",val);
                                  // With a newline at the end

    modEdit: code blocks added
  • RS_JimRS_Jim Posts: 1,126
    edited January 6 Vote Up0Vote Down
    Make your code easier to read. In close it between code tags by selecting the "C" from the header and enclosing code between the tags.
  • Peavey5150,

    What do you want your ActivityBot to "Learn"?

    You will need to create some kind of data format that stores this information and then create code that is able to replay or analyze it.

    Also understand that unless you provide your servos a constant voltage they will move slower as the voltage drops so any distance or time record would be inaccurate.
  • Peavey5150Peavey5150 Posts: 11
    edited January 7 Vote Up0Vote Down
    Thanks for the tips.

    I was just missing File*
    to read code after shutdown. I got it now.
Sign In or Register to comment.