Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Why is the SD library slow? on: January 21, 2011, 11:23:45 am
ohhh I was just figureing out what I did wrong

here is a part of my test code

char myString[glow]s[/glow][]="Test.txt";
void loop()
{
  file = SD.open([glow]myString[/glow], O_CREAT | O_WRITE | O_APPEND); //forgot on "s" myString[glow]s[/glow]

  for (int i = 0; i < 5000; i++) //writes numbers incrementing from 0-4999 to the SD card
    {
    file.println(i);
    }
  file.flush();
  file.close();
}

now it works fine
2  Forum 2005-2010 (read only) / Troubleshooting / Re: Why is the SD library slow? on: January 21, 2011, 06:43:22 am
Is it possible to create a file on the SD card with a variable name. (a name which is desided be the program)

so instead of
file = SD.open("Test.txt", O_CREAT | O_WRITE);

I would like something like...

int variable;
file = SD.open(variable, O_CREAT | O_WRITE);
.. and the variable changes from time to time so there will be created many files on the SD card, I was thinkin of using this for logging data from a meter, and have new file for each day / each week / each hour...
3  Forum 2005-2010 (read only) / Troubleshooting / Re: Why is the SD library slow? on: January 21, 2011, 05:53:49 am
One question about this SD library... is it possible to name the files created on the SD card by a variable...
something like...


File file;
int date;

void loop()
{
if (!(date==getdate())) //something that is excluded everyday
{
date=getdate();  //date collected from a Real time clock module
}
...some code...

file = SD.open(date, O_CREAT | O_WRITE | O_APPEND); //data written to the a file on the SD card named with the current date

rest of the code....
}
4  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Problem with SD.h ... Serial.print... doesn't work on: January 21, 2011, 04:17:56 am
Yes I am using arduino 168, I was just starting using arduino 2 weeks ago.. I thought the arduino software/compiler would give me some warning messages if I was out of ram, how can I see if I am out of ram/if the compiler generates a corrupt file? (just wondering so I can figure it out myself this problem will bug me later)

But thank you so much for finding my problem,  smiley-grin smiley-grin smiley-grin I have been 4 days or semething trying to figure it out  :o
5  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Problem with SD.h ... Serial.print... doesn't work on: January 20, 2011, 04:15:43 am
now here is my software (using Arduino 0022)

this program works (writes increment number up to 5000 to the SD card) but if I uncomment all the Serial.print() instructions the program just writes the fyrst Serial.print("Initializing SD card...") to the Serial monitor and freezes, or keeeps just writing "Initializing SD card" forever.

Quote
/*
  SD card read/write
 
 This example shows how to read and write data to and from an SD card file       
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 
 created   Nov 2010
 by David A. Mellis
 updated 2 Dec 2010
 by Tom Igoe
 
 This example code is in the public domain.
        
 */

#include <SD.h>

File file;

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  Serial.begin(9600);

  // Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(10, OUTPUT);

  if (!SD.begin(4)) {
    //   Serial.println("initialization failed!");
    //   return;
  }


  // Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
}

int j;
void loop()
{
  j++;
  file = SD.open("Test.txt", O_CREAT | O_WRITE | O_APPEND);

  while(millis() < 1000);  // delay so mills() is four digits

  for (int i = 0; i < 5000; i++) {
    file.println(i);
    //Serial.println(i);
  }
  // not needed in this example since close() will call flush.
  file.println(j);
  file.flush();  

  file.close();

}





6  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Problem with SD.h ... Serial.print... doesn't work on: January 19, 2011, 12:05:52 pm
these are the products that I am using
http://www.sparkfun.com/products/204
http://www.sparkfun.com/products/666
128MB SD card
7  Forum 2005-2010 (read only) / Bugs & Suggestions / Problem with SD.h ... Serial.print... doesn't work on: January 19, 2011, 12:05:24 pm
I have been trying to use the examples that come with the SD.h library. the examples did not work but after some hours I found out that if I commented out all the "Serial.print("text") instructions then the program started to work and I could make a new file on the SD card and write some stuff to it (then I put the card in my  computer to see if there was anything on the card, so I have confirmed that it works)

but then I was going to add this function to an other project that I already had written. (add the function to be able to write to SD card) but as soon as I included SD.h (#include SD.h#) then the program went going "nuts" with all the Serial.print() instructions. (sorry for my lack of english).
So it looks like the instruction "Serial.print()"/Serial.println(), is also implemented in the SD.h class or something because if I include the SD.h then my program stops working normally (prints just some bullshit on the Serial Monitor or just keeps restarting on and on)

any solution folks? :smiley
Pages: [1]