An example program that decodes the data returned from the MPU9150 DMP

Dependencies:   CMSIS_DSP_401 MPU9150_DMP QuaternionMath mbed

Fork of MPU9150_Example by Chris Pepper

Files at this revision

API Documentation at this revision

Comitter:
Hagrass
Date:
Tue Aug 11 14:41:02 2015 +0000
Parent:
0:9f2982964a48
Commit message:
IMU;

Changed in this revision

MPU9150_DMP.lib Show annotated file Show diff for this revision Revisions of this file
QuaternionMath.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
diff -r 9f2982964a48 -r b213291e5a51 MPU9150_DMP.lib
--- a/MPU9150_DMP.lib	Mon Sep 01 14:26:51 2014 +0000
+++ b/MPU9150_DMP.lib	Tue Aug 11 14:41:02 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/p3p/code/MPU9150_DMP/#e523a92390b6
+https://developer.mbed.org/users/Hagrass/code/MPU9150_DMP/#0332862b5608
diff -r 9f2982964a48 -r b213291e5a51 QuaternionMath.lib
--- a/QuaternionMath.lib	Mon Sep 01 14:26:51 2014 +0000
+++ b/QuaternionMath.lib	Tue Aug 11 14:41:02 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/p3p/code/QuaternionMath/#3cc1a808d8c6
+https://developer.mbed.org/users/Hagrass/code/QuaternionMath/#a23aea42443c
diff -r 9f2982964a48 -r b213291e5a51 main.cpp
--- a/main.cpp	Mon Sep 01 14:26:51 2014 +0000
+++ b/main.cpp	Tue Aug 11 14:41:02 2015 +0000
@@ -2,7 +2,7 @@
 #include "Quaternion.h"
 
 Serial debug(USBTX, USBRX);
-MPU9150 imu(p10, p9, p15);
+MPU9150 imu(p27, p28, p15);
 
 DigitalOut led(LED1);
 
@@ -28,13 +28,17 @@
     Quaternion q1;
     
     while(true){
+        
+    wait(1);
+    
 
         if(imu.getFifoCount() >= 48){
             imu.getFifoBuffer(buffer,  48);
             led = !led;
         }
-        
-        if(timer.read_ms() > 50){
+        q1.decode(buffer);
+    //    wait(1.1);
+        if(timer.read_ms() >50){
             timer.reset();
            
            //This is the format of the data in the fifo, 
@@ -67,10 +71,11 @@
                 (float)((((int32_t)buffer[8] << 24) + ((int32_t)buffer[9] << 16) + ((int32_t)buffer[10] << 8) + buffer[11]))* (1.0 / (1<<30)),
                 (float)((((int32_t)buffer[12] << 24) + ((int32_t)buffer[13] << 16) + ((int32_t)buffer[14] << 8) + buffer[15]))* (1.0 / (1<<30)));
             */
-                
-            q1.decode(buffer);
-            debug.printf("%f, %f, %f, %f\r\n", q1.w, q1.v.x, q1.v.y, q1.v.z);
-
+                //wait(0.01); 
+            
+            debug.printf("w:%f, v.x:%f, v.y:%f, v.z:%f\r\n", q1.w, q1.v.x, q1.v.y, q1.v.z);
+imu.setFifoReset(true);    
+    imu.setDMPEnabled(true);
 
             //TeaPot Demo Packet for MotionFit SDK
             /*
@@ -84,6 +89,8 @@
                 debug.putc((char)0);
             }
             */
+        
         }   
-    }
+   
+  }
 }
\ No newline at end of file