Hi everybody,
I am trying to write data on a SD CARD SanDisk 16 GB U1 from Teency 3.5.
I would like to log data from different sensors and I was wondering which is the maximum frequency for writing data on the card.
This is my function for the data writing:
This function is manager by a Timer:
and in the void setup() I have the following initialization:
Actually I can write data on the card but after a certain period of time the writing seems to be blocked and the written data are the same for each row of the output file.
Thank you for any suggestion!
I am trying to write data on a SD CARD SanDisk 16 GB U1 from Teency 3.5.
I would like to log data from different sensors and I was wondering which is the maximum frequency for writing data on the card.
This is my function for the data writing:
Code:
void functionSDcardTimer()
{
if ((cycles % 4000) ==0) //roughly every sec
{
myFile.close();
myFile = SD.open("test01.txt", O_RDWR | O_CREAT | O_APPEND);
myFile.println(String(TIMER) + "," + String(CYCLES) + "," + String(ENC_1_pos) + "," + String(ENC_2_pos) + "," + String(ENC_1_omega) + ","+ String(ENC_2_omega) + "," + String(LC_1) + "," + String(LC_2) + "," + String(POT_pos) + "," + String(POT_punto));
}
else
{
myFile.println(String(TIMER) + "," + String(CYCLES) + "," + String(ENC_1_pos) + "," + String(ENC_2_pos) + "," + String(ENC_1_omega) + ","+ String(ENC_2_omega) + "," + String(LC_1) + "," + String(LC_2) + "," + String(POT_pos) + "," + String(POT_punto));
}
cycles++;
}
This function is manager by a Timer:
Code:
#include "SdFat.h"
SdFatSdioEX SD;
File myFile;
unsigned long int cycles=0;
IntervalTimer SDcardTimer;
#define SD_CARD_TIMER_INTERVAL 4000
and in the void setup() I have the following initialization:
Code:
if (SD.begin())
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}
myFile = SD.open("test01.txt", O_RDWR | O_CREAT | O_APPEND);
SDcardTimer.begin(functionSDcardTimer,SD_CARD_TIMER_INTERVAL);
Actually I can write data on the card but after a certain period of time the writing seems to be blocked and the written data are the same for each row of the output file.
Thank you for any suggestion!