Some improvements on mrcrsch's BNO055_fusion library
Fork of BNO055_fusion by
Diff: BNO055.h
- Revision:
- 3:0ad6f85b178f
- Parent:
- 2:0f225b686cd5
- Child:
- 4:9e6fead1e93e
--- a/BNO055.h Wed Apr 08 11:27:57 2015 +0000 +++ b/BNO055.h Fri Apr 10 11:18:12 2015 +0000 @@ -7,7 +7,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: March 30th, 2015 - * Revised: April 8th, 2015 + * Revised: April 10th, 2015 * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE @@ -223,7 +223,7 @@ /** Reset * @param none - * @return 0 = sucess, 1 = Not avirable chip + * @return 0 = sucess, 1 = Not available chip */ uint8_t reset(void); @@ -274,7 +274,8 @@ char dt[10]; // working buffer uint8_t chip_addr; uint8_t chip_mode; - uint8_t ready_flg; + uint8_t ready_flag; + uint8_t page_flag; uint8_t chip_id; uint8_t acc_id; @@ -464,4 +465,74 @@ #define GYRO_ANY_MOTION_THRES 0x1e #define GYRO_ANY_MOTION_SET 0x1f +//--------------------------------------------------------- +//----- Calibration example ------------------------------- +//--------------------------------------------------------- +#if 0 +// Calibration +// Please refer BNO055 Data sheet 3.10 Calibration & 3.6.4 Sensor calibration data +void bno055_calbration(void){ + uint8_t d; + + pc.printf("------ Enter BNO055 Manual Calibration Mode ------\r\n"); + //---------- Gyroscope Caliblation ------------------------------------------------------------ + // (a) Place the device in a single stable position for a period of few seconds to allow the + // gyroscope to calibrate + pc.printf("Step1) Please wait few seconds\r\n"); + t.start(); + while (t.read() < 10){ + d = imu.read_calib_status(); + pc.printf("Calb dat = 0x%x target = 0x30(at least)\r\n", d); + if ((d & 0x30) == 0x30){ + break; + } + wait(1.0); + } + pc.printf("-> Step1) is done\r\n\r\n"); + //---------- Magnetometer Caliblation --------------------------------------------------------- + // (a) Make some random movements (for example: writing the number ‘8’ on air) until the + // CALIB_STAT register indicates fully calibrated. + // (b) It takes more calibration movements to get the magnetometer calibrated than in the + // NDOF mode. + pc.printf("Step2) random moving (try to change the BNO055 axis)\r\n"); + t.start(); + while (t.read() < 30){ + d = imu.read_calib_status(); + pc.printf("Calb dat = 0x%x target = 0x33(at least)\r\n", d); + if ((d & 0x03) == 0x03){ + break; + } + wait(1.0); + } + pc.printf("-> Step2) is done\r\n\r\n"); + //---------- Magnetometer Caliblation --------------------------------------------------------- + // a) Place the device in 6 different stable positions for a period of few seconds + // to allow the accelerometer to calibrate. + // b) Make sure that there is slow movement between 2 stable positions + // The 6 stable positions could be in any direction, but make sure that the device is + // lying at least once perpendicular to the x, y and z axis. + pc.printf("Step3) Change rotation each X,Y,Z axis KEEP SLOWLY!!"); + pc.printf(" Each 90deg stay a 5 sec and set at least 6 position.\r\n"); + pc.printf(" e.g. (1)ACC:X0,Y0,Z-9,(2)ACC:X9,Y0,Z0,(3)ACC:X0,Y0,Z9,"); + pc.printf("(4)ACC:X-9,Y0,Z0,(5)ACC:X0,Y-9,Z0,(6)ACC:X0,Y9,Z0,\r\n"); + pc.printf(" If you will give up, hit any key.\r\n", d); + t.stop(); + while (true){ + d = imu.read_calib_status(); + imu.get_gravity(&gravity); + pc.printf("Calb dat = 0x%x target = 0xff ACC:X %3.0f, Y %3.0f, Z %3.0f\r\n", + d, gravity.x, gravity.y, gravity.z); + if (d == 0xff){ break;} + if (pc.readable()){ break;} + wait(1.0); + } + if (imu.read_calib_status() == 0xff){ + pc.printf("-> All of Calibration steps are done successfully!\r\n\r\n"); + } else { + pc.printf("-> Calibration steps are suspended!\r\n\r\n"); + } + t.stop(); +} +#endif + #endif // BNO055_H