Write data on SD card from Teency 3.5

Status
Not open for further replies.

Lorenzo

Well-known member
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:

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!
:)
 
I am unable to access and listing or use SD card files using the Library program "List files" and setting CS(1) to pin 31 when the card is installed in the 3.5's card slot. My Teensy3.5 program that accesses card files in the audio shield slot also fails with the audio shield fitted to the 3.5. Here is the relevant part of the latter program. Am I being premature trying to use cards with the 3.5 .
 
I am unable to access and listing or use SD card files using the Library program "List files" and setting CS(1) to pin 31 when the card is installed in the 3.5's card slot. My Teensy3.5 program that accesses card files in the audio shield slot also fails with the audio shield fitted to the 3.5. Here is the relevant part of the latter program. Am I being premature trying to use cards with the 3.5 .

Sorry, could you explain it a little better and post your code? Thank you.
 
I am unable to access and listing or use SD card files using the Library program "List files" and setting CS(1) to pin 31 when the card is installed in the 3.5's card slot. My Teensy3.5 program that accesses card files in the audio shield slot also fails with the audio shield fitted to the 3.5. Here is the relevant part of the latter program. Am I being premature trying to use cards with the 3.5 .

For the T3.5 onboard SD and the SD lib example listfiles, as the sketch comments note, you need
const int chipSelect = BUILTIN_SDCARD;
 
Status
Not open for further replies.
Back
Top