I have created a datalogging system and it was performing very slow. I found that the bottleneck is the Bridge FileIO writing to SD card. It takes 0.12 second to write 10 bytes.
I made a simple sketch to calculate the timing and the results are shocking. The upper writing speed for yun is approximately 100 bytes/s which is useless. I've tried reopening the file every time and only in the beginning, but is does not affect the timing at all.
I've seen in source files that the file data is transfered via 250 kbps stream directly to linino. Is linino processing the request that long?
Did anyone else come across this problem? Something should be done here, because 100 Bps is frankly nothing.
Thanks for help,
over.
#include <FileIO.h>
void setup(){
//set pins as outputs
pinMode(13, OUTPUT);
cli();//stop interrupts
//set timer1 interrupt at 1Hz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
// set compare match register for 1hz increments
OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS12 and CS10 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
//TIMSK1 |= (1 << OCIE1A);
sei();
Bridge.begin();
Serial.begin(9600);
// Initialize SD card writing
FileSystem.begin();
}//end setup
void loop(){
digitalWrite(13,HIGH);
TCNT1 = 0;
String data = "Hello World! This card writing sucks big time and a little bit more!!!Hello World! This card writing sucks big time and a little bit more!!!";
writeLog(data);
digitalWrite(13,LOW);
Serial.println(TCNT1);
delay(500);
}
int writeLog (String data)
{
File dataFile = FileSystem.open("/mnt/sd/test.txt", FILE_APPEND);
if (dataFile)
{
dataFile.print(data);
dataFile.close();
return 0;
}
else
{
Serial.println("error opening datalog.txt");
return 1;
}
}