I am enjoying the mbed system so far. Thanks for all the previous ground work.
My project is to build an in-car data aquisition system. My end goal is to interface with my stand-alone fuel injection system for a dash display (already working on AtMega16 board. I moved to the mbed system due to the extra ports avialable. I am adding SD card logging, accelerometer and GPS tracking.
I have the display and accelerometer working well with the mbed. I just added the microSD card setup. I can write to the card but I only get one line to write. Any suggestions on file system to continually write? I moved the file close command outside my while loop but I get a flag "statement unreachable"
Thanks. Here is my main code.
#include "mbed.h"
#include "TextLCD.h"
#include "LIS302.h"
#include "SDFileSystem.h"
//LCD 2x16 parallel code pin assignment
TextLCD lcd(p21, p22, p23, p24, p25, p26, p30); // rs, rw, e, d0, d1, d2, d3
int column;
int row;
int i;
//Acclerometer - SparkFun LIS302 pin assignment
LIS302 acc (p5,p6,p7,p8);
Serial pc (USBTX,USBRX);
//SD Card pin assignment
SDFileSystem sd(p11, p12, p13, p10, "sd");//DI, D0, SCK, CS
int main() {
acc.calibrate(1.043, -0.935, 0.989, -1.061, 0.9274, -1.1584); //calibrate Accelerometer
FILE *fp = fopen("/sd/testfile.txt", "w");
while (1) {
lcd.locate(0,0); //X direction
lcd.printf("X=");
lcd.printf("%.3f" ,acc.x());
lcd.locate(8,0); //Y direction
lcd.printf("Y=");
lcd.printf("%.3f" ,acc.y());
lcd.locate(0,1); //Z direction
lcd.printf("Z=");
lcd.printf("%.3f" ,acc.z());
//SD Card File access/write
printf("Hello World!\n");
wait(0.1);//accelerometer refresh rate
lcd.cls();
//write accel values to SD card
fprintf(fp, "%.3f %.3f %.3f\n",acc.x(),acc.y(),acc.z());
wait(0.1);
}
fclose(fp);
}
I am enjoying the mbed system so far. Thanks for all the previous ground work.
My project is to build an in-car data aquisition system. My end goal is to interface with my stand-alone fuel injection system for a dash display (already working on AtMega16 board. I moved to the mbed system due to the extra ports avialable. I am adding SD card logging, accelerometer and GPS tracking.
I have the display and accelerometer working well with the mbed. I just added the microSD card setup. I can write to the card but I only get one line to write. Any suggestions on file system to continually write? I moved the file close command outside my while loop but I get a flag "statement unreachable"
Thanks. Here is my main code.