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

Committer:
maetugr
Date:
Sat Dec 01 07:13:04 2012 +0000
Revision:
28:ba6ca9f4def4
Parent:
26:96a072233d7a
Child:
29:8b7362a2ee14
bevor eigener PID

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 26:96a072233d7a 1 #include "Mixer.h"
maetugr 26:96a072233d7a 2
maetugr 26:96a072233d7a 3 Mixer::Mixer()
maetugr 26:96a072233d7a 4 {
maetugr 26:96a072233d7a 5 for(int i=0; i<4; i++)
maetugr 26:96a072233d7a 6 Motor_speed[i]=0;
maetugr 26:96a072233d7a 7 }
maetugr 26:96a072233d7a 8
maetugr 26:96a072233d7a 9 void Mixer::compute(unsigned long dt, const float * angle, int Throttle, const float * controller_value)
maetugr 26:96a072233d7a 10 {
maetugr 26:96a072233d7a 11 // Calculate new motorspeeds
maetugr 28:ba6ca9f4def4 12
maetugr 28:ba6ca9f4def4 13 for(int i=0; i<4; i++)
maetugr 28:ba6ca9f4def4 14 Motor_speed[i] = Throttle;
maetugr 28:ba6ca9f4def4 15
maetugr 28:ba6ca9f4def4 16 Motor_speed[1] += +controller_value[0]; // Roll
maetugr 28:ba6ca9f4def4 17 Motor_speed[3] -= -controller_value[0];
maetugr 26:96a072233d7a 18
maetugr 28:ba6ca9f4def4 19 Motor_speed[0] += controller_value[1]; // Pitch
maetugr 28:ba6ca9f4def4 20 Motor_speed[2] -= controller_value[1];
maetugr 28:ba6ca9f4def4 21
maetugr 28:ba6ca9f4def4 22 Motor_speed[1] += controller_value[2]; // Yaw
maetugr 28:ba6ca9f4def4 23 Motor_speed[3] += controller_value[2];
maetugr 28:ba6ca9f4def4 24 Motor_speed[0] -= controller_value[2];
maetugr 28:ba6ca9f4def4 25 Motor_speed[2] -= controller_value[2];
maetugr 26:96a072233d7a 26
maetugr 26:96a072233d7a 27 for(int i = 0; i < 4; i++) // make shure no motor stands still
maetugr 26:96a072233d7a 28 Motor_speed[i] = Motor_speed[i] > 50 ? Motor_speed[i] : 50;
maetugr 26:96a072233d7a 29 }