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)
IMU/IMU_10DOF.cpp@8:609a2ad4c30e, 2015-11-19 (annotated)
- Committer:
- maetugr
- Date:
- Thu Nov 19 18:47:27 2015 +0000
- Revision:
- 8:609a2ad4c30e
- Parent:
- 7:90f876d47862
made I2C-Sensors working in parallel, added rolling buffer for PID derivative, played with the PID and frequency parameters in main
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 0:37f0c1e8fa66 | 1 | #include "IMU_10DOF.h" |
maetugr | 0:37f0c1e8fa66 | 2 | |
maetugr | 8:609a2ad4c30e | 3 | IMU_10DOF::IMU_10DOF(PinName MOSI, PinName MISO, PinName SCLK, PinName CS, PinName SDA, PinName SCL) : mpu(MOSI, MISO, SCLK, CS), mpu2(SDA, SCL) |
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 | 8:609a2ad4c30e | 18 | mpu2.read(); // reading sensor data |
maetugr | 7:90f876d47862 | 19 | SensorTimer.stop(); // stop time for measuring sensors |
maetugr | 7:90f876d47862 | 20 | dt_sensors = SensorTimer.read(); |
maetugr | 7:90f876d47862 | 21 | SensorTimer.reset(); |
maetugr | 0:37f0c1e8fa66 | 22 | |
maetugr | 0:37f0c1e8fa66 | 23 | // meassure dt since last measurement for the filter |
maetugr | 7:90f876d47862 | 24 | dt = LoopTimer.read(); // time in s since last loop |
maetugr | 7:90f876d47862 | 25 | LoopTimer.reset(); |
maetugr | 0:37f0c1e8fa66 | 26 | |
maetugr | 0:37f0c1e8fa66 | 27 | Filter.compute(dt, mpu.Gyro, mpu.Acc, mpu.Acc); |
maetugr | 8:609a2ad4c30e | 28 | //Filter.compute(dt, mpu2.data_gyro, mpu2.data_acc, mpu2.data_acc); |
maetugr | 0:37f0c1e8fa66 | 29 | } |