A class to receive data from the SparkFun 9DOF Razor IMU. It can be easily adapted to work with IMUs with different data formats.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
avbotz
Date:
Mon Jul 08 04:04:21 2013 +0000
Parent:
3:f04d3d10d518
Commit message:
Initial commit.

Changed in this revision

imu.cpp 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbed.lib Show diff for this revision Revisions of this file
--- a/imu.cpp	Sat Nov 05 01:02:59 2011 +0000
+++ b/imu.cpp	Mon Jul 08 04:04:21 2013 +0000
@@ -6,7 +6,7 @@
  * 20.138444, -15.096182, 232.355290, -29.691927, -14.679685, 45.097056, -75.690469, 0.737977, -159.505392
  */
 
-IMU::IMU(int baud, PinName tx, PinName rx, Serial* pc){
+IMU::IMU(int baud, PinName tx, PinName rx, Serial* pc) {
     p_pc = pc;
     p_pc->printf("Initializing IMU...\n");
     p_device = new Serial(tx, rx);
@@ -15,7 +15,7 @@
     readable = false;
     i_IMU = 0;
     accX = accY = accZ = gyrX = gyrY = gyrZ = magX = magY = magZ = 0;
-    p_device->putc('6'); //Tell the IMU to start sending binary data, if it isn't already
+    p_device->putc('4'); //Tell the IMU to start sending binary data, if it isn't already
     newData = false;
 }
 
@@ -80,7 +80,7 @@
 // in unsigned form so all of the bits are switched and we switch it back and center
 // it around 512 which we are using as out zero value
 inline void IMU::makeCorrect(short* i) {
-    if ((*i)>>15) *i = 0-(~(*i));
+    if ((*i)>>15) *i = 0-(~(*i)+1);
     else *i = 0+*i;
 }
 
--- a/main.cpp	Sat Nov 05 01:02:59 2011 +0000
+++ b/main.cpp	Mon Jul 08 04:04:21 2013 +0000
@@ -3,7 +3,7 @@
  * Updated to use interrupts - this will help when we intergrate this code into AVNavControl
  * 9dof razor from sparkfun, http://www.sparkfun.com/products/10736
  */
-/*
+
 #define GYRO_SCALE 14.375  // ticks per degree, http://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf 
 
 #include "mbed.h"
@@ -179,4 +179,3 @@
     if ((*i)>>15) *i = 512 - (~(*i));
     else *i = 512 + *i;
 }
-*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jul 08 04:04:21 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
\ No newline at end of file
--- a/mbed.lib	Sat Nov 05 01:02:59 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/projects/libraries/svn/mbed/trunk@28
\ No newline at end of file