Go Down

Topic: Datalogger and 2 Accelerometers (Read 1 time) previous topic - next topic


So this is my second post in this forum. At first I was asking about being able to use I2C and SPI protocols simultaneously and was told that it was possible. Now the problem is that i got the 2 accelerometers to work together (both I2C) and i am able to initialise the SD card, but when i try to open a file and write, the program just freezes. This is the part of the code having to do with the SD card:

//Initialize Card in void setup()
  if (!SD.begin(CS_pin))
      Serial.println("Card Failure");
  Serial.println("Card Ready");

//Open file in void loop() after filtering the 6 values for the acc. and then outputting them to serial
    int output1=movingAvarageFilter.process(acc_Front.value.x);
    int output2=movingAvarageFilter1.process(acc_Front.value.y);
    int output3=movingAvarageFilter2.process(acc_Front.value.z);     
    int output4=movingAvarageFilter3.process(acc_Rear.value.x);
    int output5=movingAvarageFilter4.process(acc_Rear.value.y);
    int output6=movingAvarageFilter5.process(acc_Rear.value.z);
    Serial.print(output1); Serial.print(",");
    Serial.print(output2); Serial.print(",");
    Serial.print(output3); Serial.print(",");
    Serial.print(output4); Serial.print(",");
    Serial.print(output5); Serial.print(",");

   File logFile = SD.open("LOG.csv", FILE_WRITE);
  if (logFile)

    Serial.println("Couldn't open log file");


Maybe you are running out of SRAM? Which Arduino model are you using? The SD.open() function requires a bit of SRAM (500 bytes).

You might want to try using the F() function to keep the strings in program memory. That may help.
Code: [Select]
//Initialize Card in void setup()
  if (!SD.begin(CS_pin))
      Serial.println(F("Card Failure"));
  Serial.println(F("Card Ready"));


I'm using a Duemilanove clone board. Tomorrow my Leonardo should be arriving in the post so maybe if i try it on it, it'll work. But for now i'll try using the F() function. Thanks man


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131