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

IMU/IMU_10DOF.cpp

Committer:
maetugr
Date:
2015-09-09
Revision:
1:60882db03b0f
Parent:
0:37f0c1e8fa66
Child:
7:90f876d47862

File content as of revision 1:60882db03b0f:

#include "IMU_10DOF.h"

IMU_10DOF::IMU_10DOF(PinName MOSI, PinName MISO, PinName SCLK, PinName CS) : mpu(MOSI, MISO, SCLK, CS)
{
    dt = 0;
    dt_sensors = 0;
    time_for_dt = 0;
    time_for_dt_sensors = 0;
    
    angle = Filter.angle;           // initialize array pointer
    
    LocalTimer.start();
}

void IMU_10DOF::readAngles()
{
    time_for_dt_sensors = LocalTimer.read(); // start time for measuring sensors
    mpu.readGyro(); // reading sensor data
    mpu.readAcc();
    dt_sensors = LocalTimer.read() - time_for_dt_sensors; // stop time for measuring sensors

    // meassure dt since last measurement for the filter
    dt = LocalTimer.read() - time_for_dt; // time in s since last loop
    time_for_dt = LocalTimer.read();      // set new time for next measurement
    
    Filter.compute(dt, mpu.Gyro, mpu.Acc, mpu.Acc);
}