A project similar to http://mbed.org/users/lhiggs/code/UM6_IMU_AHRS_2012/, where I'm trying to log data from a UM6 (CH Robotics orientation sensor) and a GPS transceiver to an sd card. I've adapted LHiggs code to include ModGPS. For sum reason a soon as I pick up a gps signal the UM6 data freezes i.e. the time and gps signals continue to print out but the UM6 signals fixes on a single value.

Dependencies:   MODGPS MODSERIAL SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
njewin
Date:
Thu May 23 20:24:19 2013 +0000
Parent:
2:4a6e89c2d82a
Child:
4:8dcf0bdc25c8
Commit message:
prints timer and counter to sd card and screen; (just added MODSERIAL library but not included in main)

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Thu May 23 20:24:19 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/AjK/code/MODSERIAL/#ae0408ebdd68
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Thu May 23 20:24:19 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- a/main.cpp	Thu May 23 15:02:07 2013 +0000
+++ b/main.cpp	Thu May 23 20:24:19 2013 +0000
@@ -1,15 +1,21 @@
 #include "mbed.h"
+#include "SDFileSystem.h"
 
 //------------ system and interface setup ----------------------------//
 LocalFileSystem local("local");  // sets up local file on mbed
 Serial pc(USBTX, USBRX);  // sets up serial connection to pc terminal
 
 //------------ Hardware setup ----------------------------------------//
-DigitalOut myled(LED1);   // debug LED
+DigitalOut led1(LED1);    // debug LED
 DigitalIn enable(p10);    // enable signal for logging data to file
+AnalogIn log1(p18);       // dummy log signal1
+AnalogIn log2(p19);       // dummy log signal2
+SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+
 
 //------------ interrupt and variable setup --------------------------//
 Ticker tick;
+Timer t;
 int counter=0;
 int flag=0;
 
@@ -22,21 +28,31 @@
 //============= Main Program =========================================//
 int main() {
     pc.baud(115200);  // baud rate to pc interface
-    FILE *fp = fopen("/local/ticker4.txt", "w");
-
+    
+    //---------- setup sd card -----------------------------// 
+    mkdir("/sd/mydir", 0777);    
+    FILE *fp = fopen("/sd/mydir/sdtest.csv", "w");
+    if(fp == NULL) {
+        error("Could not open file for write\n");
+    }
+//    FILE *fp = fopen("/local/ticker4.csv", "w");
+    fprintf(fp,"time,counter,log1,log2 \r");
+     
+    t.start();
     tick.attach(&LogData, 0.01); // attaches LogData function to 'tick' ticker interrupt every 0.5s
 
     while(1) {
-        while(enable) {
             if(flag==1) {  // prints counter value every interrupt raises flag
-                myled=1;
-                fprintf(fp,"%d \n",counter);
-                pc.printf("%d \n",counter);
+                led1=1;              
+                fprintf(fp,"%.3f,%d,%f,%f \r",t.read(),counter,log1,log2);
+                pc.printf("%.3f, %d, %f, %f \n",t.read(),counter,log1,log2);
                 flag=0;
             }    // end if(flag=1) loop
-        }       // end while(enable) loop
+         
+            if(enable==0) {       
+            break;             // breaks while loop in enable switched off
+            }
+    } // end while(1) loop
     fclose(fp);
-    myled=0; // turns off LED when enable switch off
-    counter=0; // resets counter
-    } // end while(1) loop
+    led1=0; // turns off LED when enable switch off
 } // end main() loop