NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.

Dependencies:   mbed MODI2C

Files at this revision

API Documentation at this revision

Comitter:
maetugr
Date:
Tue Oct 16 10:21:32 2012 +0000
Parent:
8:d25ecdcdbeb5
Child:
10:953afcbcebfc
Commit message:
init von baro und compass in konstruktor geschrieben; vor einbetten der sensorwertarrays in die klassen

Changed in this revision

BMP085/BMP085.cpp Show annotated file Show diff for this revision Revisions of this file
HMC5883/HMC5883.cpp Show annotated file Show diff for this revision Revisions of this file
Servo/Servo.cpp Show annotated file Show diff for this revision Revisions of this file
Servo/Servo.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/BMP085/BMP085.cpp	Mon Oct 15 19:03:17 2012 +0000
+++ b/BMP085/BMP085.cpp	Tue Oct 16 10:21:32 2012 +0000
@@ -13,6 +13,9 @@
 BMP085::BMP085(PinName sda, PinName scl) : i2c_(sda, scl)
     {
     Init();
+    // MYINIT -------
+    oss = 0; //Oversampling des Barometers setzen
+    // MYINIT -------
     }
     
 
--- a/HMC5883/HMC5883.cpp	Mon Oct 15 19:03:17 2012 +0000
+++ b/HMC5883/HMC5883.cpp	Tue Oct 16 10:21:32 2012 +0000
@@ -8,6 +8,14 @@
 HMC5883::HMC5883(PinName sda, PinName scl, Timer & GlobalTime_) :  i2c_(sda, scl),  GlobalTime(GlobalTime_)
     {
     Init();
+    // MYINIT ----------
+    //Kompass kalibrieren  --> Problem fremde Magnetfelder!
+    //AutoCalibration = 1;
+    short MagRawMin[3]= {-400, -400, -400};     //Gespeicherte Werte verwenden
+    short MagRawMax[3]= {400, 400, 400};
+    Calibrate(MagRawMin, MagRawMax);
+    //Calibrate(20);
+    // MYINIT ----------
     }
 
 void HMC5883::Init()
--- a/Servo/Servo.cpp	Mon Oct 15 19:03:17 2012 +0000
+++ b/Servo/Servo.cpp	Tue Oct 16 10:21:32 2012 +0000
@@ -2,13 +2,14 @@
 #include "mbed.h"
 
 Servo::Servo(PinName Pin) : ServoPin(Pin) {
+    initialize(); // TODO: Works?
 }
 
 void Servo::initialize() {
     // initialize ESC
-    Enable(2000,20000);   // full throttle
-    wait(0.01);    // for 0.01 secs
-    SetPosition(1000);    // low throttle
+    Enable(2000,20000); // full throttle
+    wait(0.01);         // for 0.01 secs
+    SetPosition(1000);  // low throttle
 }
 
 void Servo::SetPosition(int Pos) {
@@ -21,6 +22,9 @@
 }
 
 void Servo::EndPulse() {
+    // my change
+    PulseStop.detach();
+    // my change
     ServoPin = 0;
 }
 
--- a/Servo/Servo.h	Mon Oct 15 19:03:17 2012 +0000
+++ b/Servo/Servo.h	Tue Oct 16 10:21:32 2012 +0000
@@ -1,7 +1,7 @@
 // based on http://mbed.org/users/jdenkers/code/Servo/
 
-#ifndef __SERVO_H
-#define __SERVO_H
+#ifndef SERVO_H
+#define SERVO_H
 
 #include "mbed.h"
 
--- a/main.cpp	Mon Oct 15 19:03:17 2012 +0000
+++ b/main.cpp	Tue Oct 16 10:21:32 2012 +0000
@@ -57,7 +57,7 @@
     angle[0] += (Acc_angle[0] - angle[0])/50 + Gyro_data[0] *dt/15000000.0;
     angle[1] += (Acc_angle[1] - angle[1])/50 + Gyro_data[1] *dt/15000000.0;
     tempangle += (Comp_angle - tempangle)/50 - Gyro_data[2] *dt/15000000.0;
-    angle[2] -= Gyro_data[2] *dt/15000000.0;
+    angle[2] -= Gyro_data[2] *dt/15000000.0; // gyro only here
     
     // Read RC data
     //RC[0].read() // TODO: RC daten lesen und einberechnen!
@@ -72,20 +72,11 @@
     pc.printf("Flybed v0.2");
     LEDs.roll(2);
     
-    //Kompass kalibrieren  --> Problem fremde Magnetfelder!
-    //Comp.AutoCalibration = 1;
-    short MagRawMin[3]= {-400, -400, -400};     //Gespeicherte Werte verwenden
-    short MagRawMax[3]= {400, 400, 400};
-    Comp.Calibrate(MagRawMin, MagRawMax);
-    //Comp.Calibrate(20);
-    
-    Alt.oss = 0; //Oversampling des Barometers setzen
-    
+    // Start!
     GlobalTimer.start();
     Datagetter.attach(&get_Data, 0.02);     // start to get data all 10ms
     while(1) {
-        // PC output
-        pc.locate(10,5);
+        pc.locate(10,5); // PC output
         pc.printf("dt:%dms  %6.1fm   ", dt/1000, Alt.CalcAltitude(Alt.Pressure));
         pc.locate(10,8);
         pc.printf("Roll:%6.1f Pitch:%6.1f Yaw:%6.1f    ", angle[0], angle[1], angle[2]);