Trying to log data from UM6 sensor with GPS receiver LS20031. I have two problems: - I can't log to file at a fast rate (<0.5s) without data values freezing to a fixed value. Print to pc screen it works fine. Ideally I would do this with an interrupt (e.g. ticker) so that the time of each reading is a fixed interval - I removed this as I thought this was causing the problem. - I want to record GPS lat and long. I have setup the GPS ground speed so I know the sensor are communicating. So I possibly havent set the config file to correctly interpet these two signals.

Dependencies:   MODSERIAL mbed

Fork of UM6_IMU_AHRS_2012 by lhiggs CSUM

Files at this revision

API Documentation at this revision

Comitter:
njewin
Date:
Wed May 01 23:32:16 2013 +0000
Parent:
1:20201cda90d0
Child:
3:0cfe2e18440d
Commit message:
before full change from 'attach interrupt' to using 'wait'

Changed in this revision

UM6_config/UM6_config.h 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
--- a/UM6_config/UM6_config.h	Wed May 01 19:06:43 2013 +0000
+++ b/UM6_config/UM6_config.h	Wed May 01 23:32:16 2013 +0000
@@ -12,7 +12,7 @@
 
 
 
-MODSERIAL um6_uart(p26, p25);    // UM6 SERIAL OVER UART PINS 26 & 25
+MODSERIAL um6_uart(p9, p10);    // UM6 SERIAL OVER UART PINS 26 & 25
 
 
 
--- a/main.cpp	Wed May 01 19:06:43 2013 +0000
+++ b/main.cpp	Wed May 01 23:32:16 2013 +0000
@@ -20,8 +20,11 @@
 
 DigitalIn enable(p5);    // enable signal for logging data to file
 
-Timer t; // sets up timer 't'
-Ticker tick; // sets up ticker
+Timer t; // sets up timer for measuring data loggin time
+Timer t1; // sets up timer for reading data at set intervals
+//Ticker tick; // sets up ticker
+
+//int doRead = 0; // ticker interupt variable 
 
 void rxCallback(MODSERIAL_IRQ_INFO *q) {
     if (um6_uart.rxBufferGetCount() >=  MAX_PACKET_DATA) {
@@ -30,15 +33,13 @@
     }
 }
 
-int doRead = 0;
-
-void print_um6() {
-    doRead = 1;    // interupt to read signals from UM6
-        
-}      
+//void print_um6() {
+//    doRead = 1;    // interupt to read signals from UM6
+//        }      
 
 int main() {
 
+
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 //          SET SERIAL UART BAUD RATES
 /////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -51,14 +52,18 @@
     // attach interupt function to uart
     um6_uart.attach(&rxCallback, MODSERIAL::RxIrq);
 
-    tick.attach(&print_um6, 0.50);
+//    tick.attach(&print_um6, 0.20);  // ticker interupt
 
     FILE *fp = fopen("/local/out3.csv", "w");  // Open "out.txt" on the local file system for writing
-    fprintf(fp, "time1 (s),Yaw (deg),Roll (deg),Pitch (deg),GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ,MagX,MagY,MagZ \r");   // sends header to file
+    fprintf(fp, "time1 (s),Yaw (deg),Roll (deg),Pitch (deg),GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ\r");   // sends header to file
+
+int n = 0;  // while loop counter
 
-    while (enable) {
-         logLED = 1; // turns LED3 on when logging starts                
-         if (doRead) { 
+    while (n < 10) {
+         logLED = 1; // turns LED3 on when logging starts
+         t1.start(); 
+         wait(0.5);               
+         if (t1 > 0.5) { 
            float time1=t.read();
            float Yaw=data.Yaw;
            float Roll=data.Roll;
@@ -69,21 +74,24 @@
            float AccelX=data.Accel_Proc_X;
            float AccelY=data.Accel_Proc_Y;
            float AccelZ=data.Accel_Proc_Z;
-           float MagX=data.Mag_Proc_X;
-           float MagY=data.Mag_Proc_Y;
-           float MagZ=data.Mag_Proc_Z;
+         //  float MagX=data.Mag_Proc_X;
+         //  float MagY=data.Mag_Proc_Y;
+         //  float MagZ=data.Mag_Proc_Z;
            float GPSlong=data.GPS_long;
            
            pc.printf("time1 %3.3f s,Yaw %3.3f deg,Roll %3.3f deg,Pitch %3.3f deg\n",time1,Yaw,Roll,Pitch);  
-           //pc.printf("time1 %3.3f s,Yaw %3.3f deg,Roll %3.3f deg,Pitch %3.3f deg, Longitude %f deg\n",time1,Yaw,Roll,Pitch,GPSlong);  
+           //pc.printf("time1 %3.3f s,Yaw %3.3f deg,Rol l %3.3f deg,Pitch %3.3f deg, Longitude %f deg\n",time1,Yaw,Roll,Pitch,GPSlong);  
            fprintf(fp, "%3.3f,%3.3f,%3.3f,%3.3f\n",time1,Yaw,Roll,Pitch);
-           //%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f\n",time1,Yaw,Roll,Pitch,GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ,MagX,MagY,MagZ);
+          // fprintf(fp, "%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f\n",time1,Yaw,Roll,Pitch,GyroX,GyroY,GyroZ);
+          // fprintf(fp, "%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f,%3.3f\n",time1,Yaw,Roll,Pitch,GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ);
            
            pc_activity = !pc_activity;  // Lights LED1 when uart RxBuff has > 40 bytes
-           doRead = 0; 
+         //  doRead = 0;   // reset ticker interupt variable
+          t1.reset();
+          n++;
          }
-      
-    }  // end while(1) loop
+    }  // end while(1) loopn
+   wait(0.6);  // debug - hold LED on for 0.6s, even when while loop not true
    logLED = 0;  // turns LED3 off when logging ends
    fclose(fp);