Successful acro and level mode now! Relying on MPU9250 as base sensor. I'm working continuously on tuning and features :) NEWEST VERSION ON: https://github.com/MaEtUgR/FlyBed (CODE 100% compatible/copyable)

Dependencies:   mbed

Committer:
maetugr
Date:
Mon Sep 14 12:49:08 2015 +0000
Revision:
7:90f876d47862
Parent:
1:60882db03b0f
Child:
8:609a2ad4c30e
Changed a lot of Timing related things; controll frequency is now regulated to 495Hz becuase this is the output frequency anyway

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 0:37f0c1e8fa66 1 #include "IMU_10DOF.h"
maetugr 0:37f0c1e8fa66 2
maetugr 0:37f0c1e8fa66 3 IMU_10DOF::IMU_10DOF(PinName MOSI, PinName MISO, PinName SCLK, PinName CS) : mpu(MOSI, MISO, SCLK, CS)
maetugr 0:37f0c1e8fa66 4 {
maetugr 0:37f0c1e8fa66 5 dt = 0;
maetugr 0:37f0c1e8fa66 6 dt_sensors = 0;
maetugr 0:37f0c1e8fa66 7
maetugr 0:37f0c1e8fa66 8 angle = Filter.angle; // initialize array pointer
maetugr 0:37f0c1e8fa66 9
maetugr 7:90f876d47862 10 LoopTimer.start();
maetugr 0:37f0c1e8fa66 11 }
maetugr 0:37f0c1e8fa66 12
maetugr 0:37f0c1e8fa66 13 void IMU_10DOF::readAngles()
maetugr 0:37f0c1e8fa66 14 {
maetugr 7:90f876d47862 15 SensorTimer.start(); // start time for measuring sensors
maetugr 1:60882db03b0f 16 mpu.readGyro(); // reading sensor data
maetugr 1:60882db03b0f 17 mpu.readAcc();
maetugr 7:90f876d47862 18 SensorTimer.stop(); // stop time for measuring sensors
maetugr 7:90f876d47862 19 dt_sensors = SensorTimer.read();
maetugr 7:90f876d47862 20 SensorTimer.reset();
maetugr 0:37f0c1e8fa66 21
maetugr 0:37f0c1e8fa66 22 // meassure dt since last measurement for the filter
maetugr 7:90f876d47862 23 dt = LoopTimer.read(); // time in s since last loop
maetugr 7:90f876d47862 24 LoopTimer.reset();
maetugr 0:37f0c1e8fa66 25
maetugr 0:37f0c1e8fa66 26 Filter.compute(dt, mpu.Gyro, mpu.Acc, mpu.Acc);
maetugr 0:37f0c1e8fa66 27 }