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.h@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 | // by MaEtUgR |
maetugr | 0:37f0c1e8fa66 | 2 | |
maetugr | 0:37f0c1e8fa66 | 3 | #ifndef IMU_10DOF_H |
maetugr | 0:37f0c1e8fa66 | 4 | #define IMU_10DOF_H |
maetugr | 0:37f0c1e8fa66 | 5 | |
maetugr | 0:37f0c1e8fa66 | 6 | #include "mbed.h" |
maetugr | 0:37f0c1e8fa66 | 7 | #include "MPU9250.h" // Combined Gyroscope & Accelerometer & Magnetometer over SPI |
maetugr | 8:609a2ad4c30e | 8 | #include "MPU6050.h" // Combined Gyroscope & Accelerometer |
maetugr | 0:37f0c1e8fa66 | 9 | #include "IMU_Filter.h" // Class to calculate position angles (algorithm from S.O.H. Madgwick, see header file for info) |
maetugr | 0:37f0c1e8fa66 | 10 | |
maetugr | 0:37f0c1e8fa66 | 11 | class IMU_10DOF |
maetugr | 0:37f0c1e8fa66 | 12 | { |
maetugr | 0:37f0c1e8fa66 | 13 | public: |
maetugr | 8:609a2ad4c30e | 14 | IMU_10DOF(PinName MOSI, PinName MISO, PinName SCLK, PinName CS, PinName SDA, PinName SCL); |
maetugr | 0:37f0c1e8fa66 | 15 | void readAngles(); // read all sensors and calculate angles |
maetugr | 0:37f0c1e8fa66 | 16 | |
maetugr | 0:37f0c1e8fa66 | 17 | float * angle; // where the measured and calculated data is saved |
maetugr | 0:37f0c1e8fa66 | 18 | float temperature; |
maetugr | 0:37f0c1e8fa66 | 19 | float pressure; |
maetugr | 0:37f0c1e8fa66 | 20 | float altitude; |
maetugr | 0:37f0c1e8fa66 | 21 | |
maetugr | 0:37f0c1e8fa66 | 22 | float dt; // time for entire loop |
maetugr | 0:37f0c1e8fa66 | 23 | float dt_sensors; // time only to read sensors |
maetugr | 0:37f0c1e8fa66 | 24 | |
maetugr | 0:37f0c1e8fa66 | 25 | MPU9250 mpu; // The sensor Hardware Driver |
maetugr | 8:609a2ad4c30e | 26 | MPU6050 mpu2; |
maetugr | 0:37f0c1e8fa66 | 27 | |
maetugr | 0:37f0c1e8fa66 | 28 | private: |
maetugr | 7:90f876d47862 | 29 | Timer LoopTimer; // local time to calculate processing speed for entire loop |
maetugr | 7:90f876d47862 | 30 | Timer SensorTimer; // local time to calculate processing speed for just reading sensors |
maetugr | 0:37f0c1e8fa66 | 31 | |
maetugr | 0:37f0c1e8fa66 | 32 | IMU_Filter Filter; // Filterclass to join sensor data |
maetugr | 0:37f0c1e8fa66 | 33 | }; |
maetugr | 0:37f0c1e8fa66 | 34 | |
maetugr | 0:37f0c1e8fa66 | 35 | #endif |