![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
v1.0
Dependencies: BNO055_fusion mbed MODSERIAL dsp
Fork of Bosch_BNO055_Fusion_example by
main.cpp@5:9594519c9462, 2015-04-16 (annotated)
- Committer:
- kenjiArai
- Date:
- Thu Apr 16 11:25:47 2015 +0000
- Revision:
- 5:9594519c9462
- Parent:
- 4:6d1118089a36
- Child:
- 6:0590c7ff8c34
used bug fixed library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kenjiArai | 0:31451519d283 | 1 | /* |
kenjiArai | 0:31451519d283 | 2 | * mbed Application program for the mbed Nucleo F401 |
kenjiArai | 0:31451519d283 | 3 | * BNO055 Intelligent 9-axis absolute orientation sensor |
kenjiArai | 0:31451519d283 | 4 | * by Bosch Sensortec |
kenjiArai | 0:31451519d283 | 5 | * |
kenjiArai | 0:31451519d283 | 6 | * Copyright (c) 2015 Kenji Arai / JH1PJL |
kenjiArai | 0:31451519d283 | 7 | * http://www.page.sannet.ne.jp/kenjia/index.html |
kenjiArai | 0:31451519d283 | 8 | * http://mbed.org/users/kenjiArai/ |
kenjiArai | 0:31451519d283 | 9 | * Created: March 30th, 2015 |
kenjiArai | 5:9594519c9462 | 10 | * Revised: April 16th, 2015 |
kenjiArai | 0:31451519d283 | 11 | * |
kenjiArai | 0:31451519d283 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
kenjiArai | 0:31451519d283 | 13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
kenjiArai | 0:31451519d283 | 14 | * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
kenjiArai | 0:31451519d283 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
kenjiArai | 0:31451519d283 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
kenjiArai | 0:31451519d283 | 17 | */ |
kenjiArai | 0:31451519d283 | 18 | |
kenjiArai | 0:31451519d283 | 19 | // Include --------------------------------------------------------------------------------------- |
kenjiArai | 0:31451519d283 | 20 | #include "mbed.h" |
kenjiArai | 0:31451519d283 | 21 | #include "BNO055.h" |
kenjiArai | 0:31451519d283 | 22 | |
kenjiArai | 0:31451519d283 | 23 | // Definition ------------------------------------------------------------------------------------ |
kenjiArai | 3:f5b5c4d795ce | 24 | #define NUM_LOOP 100 |
kenjiArai | 3:f5b5c4d795ce | 25 | |
kenjiArai | 0:31451519d283 | 26 | // Object ---------------------------------------------------------------------------------------- |
kenjiArai | 0:31451519d283 | 27 | Serial pc(USBTX,USBRX); |
kenjiArai | 2:cf77282aea7b | 28 | #if defined(TARGET_LPC1114) |
kenjiArai | 2:cf77282aea7b | 29 | DigitalOut pwr_onoff(dp17); |
kenjiArai | 2:cf77282aea7b | 30 | I2C i2c(dp5, dp27); // SDA, SCL |
kenjiArai | 2:cf77282aea7b | 31 | BNO055 imu(i2c, dp18); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default |
kenjiArai | 2:cf77282aea7b | 32 | #elif defined(TARGET_LPC1768) |
kenjiArai | 2:cf77282aea7b | 33 | DigitalOut pwr_onoff(p30); |
kenjiArai | 2:cf77282aea7b | 34 | I2C i2c(p28, p27); // SDA, SCL |
kenjiArai | 2:cf77282aea7b | 35 | BNO055 imu(i2c, p29); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default |
kenjiArai | 2:cf77282aea7b | 36 | #elif defined(TARGET_STM32L152RE) || defined(TARGET_STM32F401RE) || defined(TARGET_STM32F411RE) |
kenjiArai | 2:cf77282aea7b | 37 | DigitalOut pwr_onoff(PB_10); |
kenjiArai | 0:31451519d283 | 38 | I2C i2c(PB_9, PB_8); // SDA, SCL |
kenjiArai | 2:cf77282aea7b | 39 | BNO055 imu(i2c, PA_8); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default |
kenjiArai | 2:cf77282aea7b | 40 | #elif defined(TARGET_RZ_A1H) |
kenjiArai | 2:cf77282aea7b | 41 | DigitalOut pwr_onoff(P8_11); |
kenjiArai | 2:cf77282aea7b | 42 | I2C i2c(P1_3, P1_2); // SDA, SCL |
kenjiArai | 2:cf77282aea7b | 43 | BNO055 imu(i2c, P8_13); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default |
kenjiArai | 2:cf77282aea7b | 44 | #else |
kenjiArai | 2:cf77282aea7b | 45 | #error "Not cheched yet" |
kenjiArai | 2:cf77282aea7b | 46 | #endif |
kenjiArai | 3:f5b5c4d795ce | 47 | Timer t; |
kenjiArai | 0:31451519d283 | 48 | |
kenjiArai | 0:31451519d283 | 49 | // RAM ------------------------------------------------------------------------------------------- |
kenjiArai | 0:31451519d283 | 50 | BNO055_ID_INF_TypeDef bno055_id_inf; |
kenjiArai | 0:31451519d283 | 51 | BNO055_EULER_TypeDef euler_angles; |
kenjiArai | 0:31451519d283 | 52 | BNO055_QUATERNION_TypeDef quaternion; |
kenjiArai | 0:31451519d283 | 53 | BNO055_LIN_ACC_TypeDef linear_acc; |
kenjiArai | 0:31451519d283 | 54 | BNO055_GRAVITY_TypeDef gravity; |
kenjiArai | 0:31451519d283 | 55 | BNO055_TEMPERATURE_TypeDef chip_temp; |
kenjiArai | 0:31451519d283 | 56 | |
kenjiArai | 0:31451519d283 | 57 | // ROM / Constant data --------------------------------------------------------------------------- |
kenjiArai | 0:31451519d283 | 58 | |
kenjiArai | 0:31451519d283 | 59 | // Function prototypes --------------------------------------------------------------------------- |
kenjiArai | 0:31451519d283 | 60 | |
kenjiArai | 0:31451519d283 | 61 | //------------------------------------------------------------------------------------------------- |
kenjiArai | 0:31451519d283 | 62 | // Control Program |
kenjiArai | 3:f5b5c4d795ce | 63 | //------------------------------------------------------------------------------------------------- |
kenjiArai | 4:6d1118089a36 | 64 | // Calibration |
kenjiArai | 4:6d1118089a36 | 65 | // Please refer BNO055 Data sheet 3.10 Calibration & 3.6.4 Sensor calibration data |
kenjiArai | 4:6d1118089a36 | 66 | void bno055_calbration(void){ |
kenjiArai | 4:6d1118089a36 | 67 | uint8_t d; |
kenjiArai | 3:f5b5c4d795ce | 68 | |
kenjiArai | 4:6d1118089a36 | 69 | pc.printf("------ Enter BNO055 Manual Calibration Mode ------\r\n"); |
kenjiArai | 4:6d1118089a36 | 70 | //---------- Gyroscope Caliblation ------------------------------------------------------------ |
kenjiArai | 4:6d1118089a36 | 71 | // (a) Place the device in a single stable position for a period of few seconds to allow the |
kenjiArai | 4:6d1118089a36 | 72 | // gyroscope to calibrate |
kenjiArai | 4:6d1118089a36 | 73 | pc.printf("Step1) Please wait few seconds\r\n"); |
kenjiArai | 4:6d1118089a36 | 74 | t.start(); |
kenjiArai | 4:6d1118089a36 | 75 | while (t.read() < 10){ |
kenjiArai | 4:6d1118089a36 | 76 | d = imu.read_calib_status(); |
kenjiArai | 4:6d1118089a36 | 77 | pc.printf("Calb dat = 0x%x target = 0x30(at least)\r\n", d); |
kenjiArai | 4:6d1118089a36 | 78 | if ((d & 0x30) == 0x30){ |
kenjiArai | 4:6d1118089a36 | 79 | break; |
kenjiArai | 4:6d1118089a36 | 80 | } |
kenjiArai | 4:6d1118089a36 | 81 | wait(1.0); |
kenjiArai | 4:6d1118089a36 | 82 | } |
kenjiArai | 4:6d1118089a36 | 83 | pc.printf("-> Step1) is done\r\n\r\n"); |
kenjiArai | 4:6d1118089a36 | 84 | //---------- Magnetometer Caliblation --------------------------------------------------------- |
kenjiArai | 4:6d1118089a36 | 85 | // (a) Make some random movements (for example: writing the number ‘8’ on air) until the |
kenjiArai | 4:6d1118089a36 | 86 | // CALIB_STAT register indicates fully calibrated. |
kenjiArai | 4:6d1118089a36 | 87 | // (b) It takes more calibration movements to get the magnetometer calibrated than in the |
kenjiArai | 4:6d1118089a36 | 88 | // NDOF mode. |
kenjiArai | 4:6d1118089a36 | 89 | pc.printf("Step2) random moving (try to change the BNO055 axis)\r\n"); |
kenjiArai | 4:6d1118089a36 | 90 | t.start(); |
kenjiArai | 4:6d1118089a36 | 91 | while (t.read() < 30){ |
kenjiArai | 4:6d1118089a36 | 92 | d = imu.read_calib_status(); |
kenjiArai | 4:6d1118089a36 | 93 | pc.printf("Calb dat = 0x%x target = 0x33(at least)\r\n", d); |
kenjiArai | 4:6d1118089a36 | 94 | if ((d & 0x03) == 0x03){ |
kenjiArai | 4:6d1118089a36 | 95 | break; |
kenjiArai | 4:6d1118089a36 | 96 | } |
kenjiArai | 4:6d1118089a36 | 97 | wait(1.0); |
kenjiArai | 4:6d1118089a36 | 98 | } |
kenjiArai | 4:6d1118089a36 | 99 | pc.printf("-> Step2) is done\r\n\r\n"); |
kenjiArai | 4:6d1118089a36 | 100 | //---------- Magnetometer Caliblation --------------------------------------------------------- |
kenjiArai | 4:6d1118089a36 | 101 | // a) Place the device in 6 different stable positions for a period of few seconds |
kenjiArai | 4:6d1118089a36 | 102 | // to allow the accelerometer to calibrate. |
kenjiArai | 4:6d1118089a36 | 103 | // b) Make sure that there is slow movement between 2 stable positions |
kenjiArai | 4:6d1118089a36 | 104 | // The 6 stable positions could be in any direction, but make sure that the device is |
kenjiArai | 4:6d1118089a36 | 105 | // lying at least once perpendicular to the x, y and z axis. |
kenjiArai | 4:6d1118089a36 | 106 | pc.printf("Step3) Change rotation each X,Y,Z axis KEEP SLOWLY!!"); |
kenjiArai | 4:6d1118089a36 | 107 | pc.printf(" Each 90deg stay a 5 sec and set at least 6 position.\r\n"); |
kenjiArai | 4:6d1118089a36 | 108 | pc.printf(" e.g. (1)ACC:X0,Y0,Z-9,(2)ACC:X9,Y0,Z0,(3)ACC:X0,Y0,Z9,"); |
kenjiArai | 4:6d1118089a36 | 109 | pc.printf("(4)ACC:X-9,Y0,Z0,(5)ACC:X0,Y-9,Z0,(6)ACC:X0,Y9,Z0,\r\n"); |
kenjiArai | 4:6d1118089a36 | 110 | pc.printf(" If you will give up, hit any key.\r\n", d); |
kenjiArai | 4:6d1118089a36 | 111 | t.stop(); |
kenjiArai | 4:6d1118089a36 | 112 | while (true){ |
kenjiArai | 4:6d1118089a36 | 113 | d = imu.read_calib_status(); |
kenjiArai | 4:6d1118089a36 | 114 | imu.get_gravity(&gravity); |
kenjiArai | 5:9594519c9462 | 115 | pc.printf("Calb dat = 0x%x target = 0xff ACC:X %4.1f, Y %4.1f, Z %4.1f\r\n", |
kenjiArai | 4:6d1118089a36 | 116 | d, gravity.x, gravity.y, gravity.z); |
kenjiArai | 4:6d1118089a36 | 117 | if (d == 0xff){ break;} |
kenjiArai | 4:6d1118089a36 | 118 | if (pc.readable()){ break;} |
kenjiArai | 4:6d1118089a36 | 119 | wait(1.0); |
kenjiArai | 4:6d1118089a36 | 120 | } |
kenjiArai | 4:6d1118089a36 | 121 | if (imu.read_calib_status() == 0xff){ |
kenjiArai | 4:6d1118089a36 | 122 | pc.printf("-> All of Calibration steps are done successfully!\r\n\r\n"); |
kenjiArai | 4:6d1118089a36 | 123 | } else { |
kenjiArai | 4:6d1118089a36 | 124 | pc.printf("-> Calibration steps are suspended!\r\n\r\n"); |
kenjiArai | 4:6d1118089a36 | 125 | } |
kenjiArai | 4:6d1118089a36 | 126 | t.stop(); |
kenjiArai | 4:6d1118089a36 | 127 | } |
kenjiArai | 4:6d1118089a36 | 128 | |
kenjiArai | 4:6d1118089a36 | 129 | int main(){ |
kenjiArai | 4:6d1118089a36 | 130 | imu.set_mounting_position(MT_P6); |
kenjiArai | 4:6d1118089a36 | 131 | pwr_onoff = 0; |
kenjiArai | 4:6d1118089a36 | 132 | pc.printf("\r\n\r\nIf pc terminal soft is ready, please hit any key!\r\n"); |
kenjiArai | 4:6d1118089a36 | 133 | char c = pc.getc(); |
kenjiArai | 4:6d1118089a36 | 134 | pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n"); |
kenjiArai | 4:6d1118089a36 | 135 | // Is BNO055 avairable? |
kenjiArai | 4:6d1118089a36 | 136 | if (imu.chip_ready() == 0){ |
kenjiArai | 4:6d1118089a36 | 137 | do { |
kenjiArai | 4:6d1118089a36 | 138 | pc.printf("Bosch BNO055 is NOT avirable!!\r\n Reset\r\n"); |
kenjiArai | 4:6d1118089a36 | 139 | pwr_onoff = 1; // Power off |
kenjiArai | 4:6d1118089a36 | 140 | wait(0.1); |
kenjiArai | 4:6d1118089a36 | 141 | pwr_onoff = 0; // Power on |
kenjiArai | 4:6d1118089a36 | 142 | wait(0.02); |
kenjiArai | 4:6d1118089a36 | 143 | } while(imu.reset()); |
kenjiArai | 4:6d1118089a36 | 144 | } |
kenjiArai | 4:6d1118089a36 | 145 | pc.printf("Bosch BNO055 is available now!!\r\n"); |
kenjiArai | 4:6d1118089a36 | 146 | pc.printf("AXIS_REMAP_CONFIG:0x%02x, AXIS_REMAP_SIGN:0x%02x\r\n", |
kenjiArai | 4:6d1118089a36 | 147 | imu.read_reg0(BNO055_AXIS_MAP_CONFIG), imu.read_reg0(BNO055_AXIS_MAP_SIGN)); |
kenjiArai | 4:6d1118089a36 | 148 | imu.read_id_inf(&bno055_id_inf); |
kenjiArai | 4:6d1118089a36 | 149 | pc.printf("CHIP ID:0x%02x, ACC ID:0x%02x, MAG ID:0x%02x, GYR ID:0x%02x, ", |
kenjiArai | 4:6d1118089a36 | 150 | bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id, bno055_id_inf.gyr_id); |
kenjiArai | 4:6d1118089a36 | 151 | pc.printf("SW REV:0x%04x, BL REV:0x%02x\r\n", |
kenjiArai | 4:6d1118089a36 | 152 | bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id); |
kenjiArai | 4:6d1118089a36 | 153 | pc.printf("If you would like to calibrate the BNO055, please hit 'y' (No: any other key)\r\n"); |
kenjiArai | 4:6d1118089a36 | 154 | c = pc.getc(); |
kenjiArai | 4:6d1118089a36 | 155 | if (c == 'y'){ |
kenjiArai | 4:6d1118089a36 | 156 | bno055_calbration(); |
kenjiArai | 4:6d1118089a36 | 157 | } |
kenjiArai | 4:6d1118089a36 | 158 | pc.printf("[E]:Euler Angles[deg],[Q]:Quaternion[],[L]:Linear accel[m/s*s],"); |
kenjiArai | 4:6d1118089a36 | 159 | pc.printf("[G]:Gravity vector[m/s*s],[T]:Chip temperature,Acc,Gyr[degC],[S]:Status,[M]:time[mS]\r\n"); |
kenjiArai | 4:6d1118089a36 | 160 | t.start(); |
kenjiArai | 4:6d1118089a36 | 161 | while(1) { |
kenjiArai | 4:6d1118089a36 | 162 | imu.get_Euler_Angles(&euler_angles); |
kenjiArai | 4:6d1118089a36 | 163 | pc.printf("[E],Y,%+6.1f,R,%+6.1f,P,%+6.1f,", |
kenjiArai | 4:6d1118089a36 | 164 | euler_angles.h, euler_angles.r, euler_angles.p); |
kenjiArai | 4:6d1118089a36 | 165 | imu.get_quaternion(&quaternion); |
kenjiArai | 4:6d1118089a36 | 166 | pc.printf("[Q],W,%d,X,%d,Y,%d,Z,%d,", |
kenjiArai | 4:6d1118089a36 | 167 | quaternion.w, quaternion.x, quaternion.y, quaternion.z); |
kenjiArai | 4:6d1118089a36 | 168 | imu.get_linear_accel(&linear_acc); |
kenjiArai | 4:6d1118089a36 | 169 | pc.printf("[L],X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", |
kenjiArai | 4:6d1118089a36 | 170 | linear_acc.x, linear_acc.y, linear_acc.z); |
kenjiArai | 4:6d1118089a36 | 171 | imu.get_gravity(&gravity); |
kenjiArai | 4:6d1118089a36 | 172 | pc.printf("[G],X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", |
kenjiArai | 4:6d1118089a36 | 173 | gravity.x, gravity.y, gravity.z); |
kenjiArai | 4:6d1118089a36 | 174 | imu.get_chip_temperature(&chip_temp); |
kenjiArai | 4:6d1118089a36 | 175 | pc.printf("[T],%+d,%+d,", |
kenjiArai | 4:6d1118089a36 | 176 | chip_temp.acc_chip, chip_temp.gyr_chip); |
kenjiArai | 4:6d1118089a36 | 177 | pc.printf("[S],0x%x,[M],%d\r\n", |
kenjiArai | 4:6d1118089a36 | 178 | imu.read_calib_status(), t.read_ms()); |
kenjiArai | 4:6d1118089a36 | 179 | } |
kenjiArai | 4:6d1118089a36 | 180 | } |
kenjiArai | 4:6d1118089a36 | 181 | |
kenjiArai | 4:6d1118089a36 | 182 | |
kenjiArai | 4:6d1118089a36 | 183 | // Diffrent output format as for your reference |
kenjiArai | 4:6d1118089a36 | 184 | #if 0 |
kenjiArai | 0:31451519d283 | 185 | int main() { |
kenjiArai | 0:31451519d283 | 186 | uint8_t i; |
kenjiArai | 0:31451519d283 | 187 | |
kenjiArai | 2:cf77282aea7b | 188 | pwr_onoff = 0; |
kenjiArai | 0:31451519d283 | 189 | pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n"); |
kenjiArai | 0:31451519d283 | 190 | // Is BNO055 avairable? |
kenjiArai | 0:31451519d283 | 191 | if (imu.chip_ready() == 0){ |
kenjiArai | 2:cf77282aea7b | 192 | do { |
kenjiArai | 2:cf77282aea7b | 193 | pc.printf("Bosch BNO055 is NOT avirable!!\r\n"); |
kenjiArai | 2:cf77282aea7b | 194 | pwr_onoff = 1; // Power off |
kenjiArai | 2:cf77282aea7b | 195 | wait(0.1); |
kenjiArai | 2:cf77282aea7b | 196 | pwr_onoff = 0; // Power on |
kenjiArai | 2:cf77282aea7b | 197 | wait(0.02); |
kenjiArai | 2:cf77282aea7b | 198 | } while(imu.reset()); |
kenjiArai | 0:31451519d283 | 199 | } |
kenjiArai | 0:31451519d283 | 200 | imu.set_mounting_position(MT_P6); |
kenjiArai | 0:31451519d283 | 201 | pc.printf("AXIS_REMAP_CONFIG:0x%02x, AXIS_REMAP_SIGN:0x%02x\r\n", |
kenjiArai | 0:31451519d283 | 202 | imu.read_reg0(BNO055_AXIS_MAP_CONFIG), imu.read_reg0(BNO055_AXIS_MAP_SIGN)); |
kenjiArai | 0:31451519d283 | 203 | imu.read_id_inf(&bno055_id_inf); |
kenjiArai | 0:31451519d283 | 204 | pc.printf("CHIP:0x%02x, ACC:0x%02x, MAG:0x%02x, GYR:0x%02x, , SW:0x%04x, , BL:0x%02x\r\n", |
kenjiArai | 0:31451519d283 | 205 | bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id, |
kenjiArai | 0:31451519d283 | 206 | bno055_id_inf.gyr_id, bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id); |
kenjiArai | 0:31451519d283 | 207 | while(1) { |
kenjiArai | 0:31451519d283 | 208 | pc.printf("Euler Angles data\r\n"); |
kenjiArai | 2:cf77282aea7b | 209 | for (i = 0; i < NUM_LOOP; i++){ |
kenjiArai | 0:31451519d283 | 210 | imu.get_Euler_Angles(&euler_angles); |
kenjiArai | 0:31451519d283 | 211 | pc.printf("Heading:%+6.1f [deg], Roll:%+6.1f [deg], Pich:%+6.1f [deg], #%02d\r\n", |
kenjiArai | 0:31451519d283 | 212 | euler_angles.h, euler_angles.r, euler_angles.p, i); |
kenjiArai | 0:31451519d283 | 213 | wait(0.5); |
kenjiArai | 0:31451519d283 | 214 | } |
kenjiArai | 0:31451519d283 | 215 | pc.printf("Quaternion data\r\n"); |
kenjiArai | 2:cf77282aea7b | 216 | for (i = 0; i < NUM_LOOP; i++){ |
kenjiArai | 0:31451519d283 | 217 | imu.get_quaternion(&quaternion); |
kenjiArai | 0:31451519d283 | 218 | pc.printf("W:%d, X:%d, Y:%d, Z:%d, #%02d\r\n", |
kenjiArai | 0:31451519d283 | 219 | quaternion.w, quaternion.x, quaternion.y, quaternion.z, i); |
kenjiArai | 0:31451519d283 | 220 | wait(0.5); |
kenjiArai | 0:31451519d283 | 221 | } |
kenjiArai | 0:31451519d283 | 222 | pc.printf("Linear accel data\r\n"); |
kenjiArai | 2:cf77282aea7b | 223 | for (i = 0; i < NUM_LOOP; i++){ |
kenjiArai | 0:31451519d283 | 224 | imu.get_linear_accel(&linear_acc); |
kenjiArai | 0:31451519d283 | 225 | pc.printf("X:%+6.1f [m/s*s], Y:%+6.1f [m/s*s], Z:%+6.1f [m/s*s], #%02d\r\n", |
kenjiArai | 0:31451519d283 | 226 | linear_acc.x, linear_acc.y, linear_acc.z, i); |
kenjiArai | 0:31451519d283 | 227 | wait(0.5); |
kenjiArai | 0:31451519d283 | 228 | } |
kenjiArai | 0:31451519d283 | 229 | pc.printf("Gravity vector data\r\n"); |
kenjiArai | 2:cf77282aea7b | 230 | for (i = 0; i < NUM_LOOP; i++){ |
kenjiArai | 0:31451519d283 | 231 | imu.get_gravity(&gravity); |
kenjiArai | 0:31451519d283 | 232 | pc.printf("X:%+6.1f [m/s*s], Y:%+6.1f [m/s*s], Z:%+6.1f [m/s*s], #%02d\r\n", |
kenjiArai | 0:31451519d283 | 233 | gravity.x, gravity.y, gravity.z, i); |
kenjiArai | 0:31451519d283 | 234 | wait(0.5); |
kenjiArai | 0:31451519d283 | 235 | } |
kenjiArai | 0:31451519d283 | 236 | pc.printf("Chip temperature data\r\n"); |
kenjiArai | 2:cf77282aea7b | 237 | for (i = 0; i < (NUM_LOOP / 4); i++){ |
kenjiArai | 0:31451519d283 | 238 | imu.get_chip_temperature(&chip_temp); |
kenjiArai | 0:31451519d283 | 239 | pc.printf("Acc chip:%+d [degC], Gyr chip:%+d [degC], #%02d\r\n", |
kenjiArai | 0:31451519d283 | 240 | chip_temp.acc_chip, chip_temp.gyr_chip, i); |
kenjiArai | 0:31451519d283 | 241 | wait(0.5); |
kenjiArai | 0:31451519d283 | 242 | } |
kenjiArai | 0:31451519d283 | 243 | } |
kenjiArai | 0:31451519d283 | 244 | } |
kenjiArai | 3:f5b5c4d795ce | 245 | #endif |