9dofRazor for near space flight project
Fork of 9dofRazorImuAhrs by
Revision 2:add8059b69fa, committed 2016-04-07
- Comitter:
- szeitler18
- Date:
- Thu Apr 07 18:01:22 2016 +0000
- Parent:
- 1:f2736d5ba512
- Commit message:
- Sick Program in need of tlc
Changed in this revision
diff -r f2736d5ba512 -r add8059b69fa dof9RazorImuAhrs.cpp --- a/dof9RazorImuAhrs.cpp Thu Apr 07 16:52:48 2016 +0000 +++ b/dof9RazorImuAhrs.cpp Thu Apr 07 18:01:22 2016 +0000 @@ -17,19 +17,20 @@ // Includes //****************************************************************************/ #include "dof9RazorImuAhrs.h" +extern DigitalOut led1; dof9RazorImuAhrs::dof9RazorImuAhrs(PinName tx, PinName rx) { razor = new Serial(tx, rx); razor->baud(BAUD_RATE); - + led1 = 0; } void dof9RazorImuAhrs::update(void) { - + led1 = 1; //Make sure we get to the start of a line. while (razor->getc() != '\n'); - + led1 = 0; #if PRINT_EULER == 1 razor->scanf("!ANG:%f,%f,%f", &roll, &pitch, &yaw); #endif
diff -r f2736d5ba512 -r add8059b69fa dof9RazorImuAhrs.h --- a/dof9RazorImuAhrs.h Thu Apr 07 16:52:48 2016 +0000 +++ b/dof9RazorImuAhrs.h Thu Apr 07 18:01:22 2016 +0000 @@ -24,8 +24,8 @@ //****************************************************************************/ // Defines //****************************************************************************/ -#define PRINT_EULER 1 //Corrected heading data. -#define PRINT_ANALOGS 0 //Razor spits out raw gyro/accelerometer/magneto +#define PRINT_EULER 0 //Corrected heading data. +#define PRINT_ANALOGS 1 //Razor spits out raw gyro/accelerometer/magneto //data. //Set as a define when compiling AHRS code. #define BAUD_RATE 57600 //Default in AHRS code.
diff -r f2736d5ba512 -r add8059b69fa main.cpp --- a/main.cpp Thu Apr 07 16:52:48 2016 +0000 +++ b/main.cpp Thu Apr 07 18:01:22 2016 +0000 @@ -6,15 +6,25 @@ #include "mbed.h" Serial pc(USBTX, USBRX); -dof9RazorImuAhrs theRazor(p27, p28); +dof9RazorImuAhrs theRazor(p9, p10); +DigitalOut led1(LED1); +DigitalOut led2(LED2); + const float g = 9.8; +float x; + int main() { - + pc.printf("I'm alive!\r\n"); while(1) { - wait(0.1); - theRazor.update(); - pc.printf("ax = %.2fg, ay = %.2fg, az = %.2fg\r\n", theRazor.getAccX()*g,theRazor.getAccY()*g, theRazor.getAccZ()*g); - pc.printf("gyrox = %.2fg, gyroy = %.2fg, gyroz = %.2fg\r\n", theRazor.getGyroX() *g, theRazor.getGyroY() *g, theRazor.getGyroZ() *g); + pc.printf("Hi!\r\n"); + led2 = 1; + wait(1); + led2 = 0; + theRazor.update(); + x = theRazor.getAccX(); + pc.printf("ax = %.2f\r\n",x); + pc.printf("ax = %.2fg, ay = %.2fg, az = %.2fg\r\n", theRazor.getAccX(),theRazor.getAccY(), theRazor.getAccZ()); + //pc.printf("gyrox = %.2fg, gyroy = %.2fg, gyroz = %.2fg\r\n", theRazor.getGyroX() , theRazor.getGyroY() , theRazor.getGyroZ()); }