Hello,
I am working on a motorcycle data logger project and I would like add the acquisition of the BNO055 IMU data (angle orientation, angle rate and acceleration). I have several sensors with different sample rate:
-hall Effect sensor associates to an interrupt routine (high speed -> 1000Hz).
-IMU and steering encoder 100 Hz
-GPS 20 Hz
I am currently working on the IMU independently (keeping in mind that I have to include the code in the main data logger sketch) and I am having several problems. My sketch is based on one of the examples from the BNO055 library. I have just added the acquisition of the accelerometer and the gyroscope data.
The sketch is the following:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
/* Set the delay between fresh samples */
const int periodIMU=1000;
unsigned long previousTimeIMU=0;
unsigned long currentTime=0;
#define BNO055_SAMPLERATE_DELAY_MS (periodIMU)
Adafruit_BNO055 bno = Adafruit_BNO055();
//------------------------------------------------------------------------------------------------//
void setup(void)
{
Serial.begin(115200);
Serial.println("BNO055 Data Test");
Serial.println("");
/* Initialise the sensor */
if(!bno.begin())
{
Serial.print("No BNO055 detected ... Check your wiring or I2C ADDR!"); // There was a problem detecting the BNO055 ... check your connections
while(1);
}
delay(1);
int8_t temp = bno.getTemp(); // Display current temperature
Serial.print("Current Temperature: ");
Serial.print(temp);
Serial.println(" C");
Serial.println("");
bno.setExtCrystalUse(true);
Serial.println("Calibration status values: 0=uncalibrated, 3=fully calibrated");
// Display column headers
Serial.print("\t\t");
Serial.print("Position");
Serial.print("\t\t\t");
Serial.print("Angular velocity");
Serial.print("\t\t\t\t");
Serial.print("Acceleration");
Serial.print("\t\t\t\t");
Serial.println("Calibration");
// Display column sub-headers
Serial.print("Time ");
Serial.print("\t\t");
Serial.print("Roll; Pitch; Yaw");
Serial.print("\t\t");
Serial.print("Roll rate; Pitch rate; Yaw rate");
Serial.print(" \t\t");
Serial.print("Accel X, Accel Y, Accel Z");
Serial.print("\t\t");
Serial.println("Sys; Gyro; Accel; Mag");
}
The main problem is the calibration process. Considering a 1Hz sample rate I obtain the following results on the serial monitor:
BNO055 Data Test
Current Temperature: 24 C
Calibration status values: 0=uncalibrated, 3=fully calibrated
Position Angular velocity Acceleration Calibration
Time Roll; Pitch; Yaw Roll rate; Pitch rate; Yaw rate Accel X, Accel Y, Accel Z Sys; Gyro; Accel; Mag
1000 359.94; 0.69; -4.00 -0.00; -0.00; 0.00 0.13; 0.69; 9.63 0; 0; 0; 0
2000 359.94; 0.69; -4.00 0.00; 0.00; -0.00 0.12; 0.70; 9.63 2; 3; 0; 0
3000 359.94; 0.69; -4.00 -0.00; 0.00; -0.00 0.12; 0.67; 9.66 2; 3; 0; 0
4000 359.94; 0.69; -4.00 0.00; 0.00; 0.00 0.11; 0.68; 9.62 2; 3; 0; 0
5000 359.94; 0.69; -4.00 -0.00; 0.00; 0.00 0.12; 0.71; 9.64 2; 3; 0; 0
6000 9.31; 22.75; -5.88 0.50; -2.23; -0.66 6.31; -0.16; 9.09 0; 3; 0; 0
7000 30.06; 43.19; 13.75 -0.86; -1.96; 0.17 6.88; -2.36; 6.68 0; 3; 0; 1
8000 10.19; 24.81; -19.19 -0.36; 0.60; -0.11 6.25; 2.74; 8.89 0; 3; 0; 2
9000 7.44; 45.75; -40.31 0.12; -0.64; -0.69 7.18; 4.03; 4.91 0; 3; 0; 2
10000 16.12; 38.50; -97.44 -0.25; 0.40; 0.18 5.56; 6.91; -1.34 0; 3; 0; 2
11000 8.63; 33.94; -29.06 -0.94; 0.60; 0.37 5.09; 4.32; 6.31 0; 3; 0; 2
12000 357.31; 42.25; -11.13 -0.36; -1.12; 0.61 5.76; 3.82; 6.14 0; 3; 0; 2
13000 154.25; 51.81; -51.63 0.18; -0.07; -1.11 7.69; 3.76; 3.37 0; 3; 0; 3
14000 183.38; 21.00; -58.19 -0.09; 0.79; -1.13 3.12; 6.75; 4.28 1; 3; 0; 3
15000 167.50; 29.44; -1.50 -1.56; 0.36; 0.86 3.66; -0.13; 7.70 0; 3; 0; 3
16000 168.88; 26.12; 53.88 -0.27; 0.04; -0.22 3.98; -7.51; 4.68 0; 3; 0; 3
17000 191.81; 21.75; -10.63 1.57; 1.50; -0.35 3.11; 1.58; 8.48 0; 3; 0; 3
18000 185.13; 73.37; -16.62 -0.44; -1.34; -0.50 9.05; 1.69; 2.22 0; 3; 0; 3
19000 191.75; 51.25; -26.12 1.30; 2.69; -0.60 8.37; 1.12; 6.52 0; 3; 0; 3
20000 203.81; 4.75; -20.81 -0.26; -0.20; 0.15 1.91; 6.57; 12.18 0; 3; 0; 3
It is almost impossible to get simultaneously calibration of the 3 sensors (accelerometer, gyroscope and magnetometer) and of the system. I don’t understand why?
Taking into account the fact that the IMU will be installed under the seat on motorcycle, I think it is important to calibrate it before the driving scenario but I don’t know if it is necessary to calibrate each time the main loop is repeated?
The second problem is the refresh time. Consider that after having set the BNO055_SAMPLERATE_DELAY_MS () to 100 Hz the data are exactly available every 10 ms. Keeping only the view of the currenTime data to avoid long repeated serial.print() function. It takes around 1 seconds to reach the sample rate without delay. I would appreciate help to solve the problem.
Current Temperature: 23 C
Calibration status values: 0=uncalibrated, 3=fully calibrated
Position Angular velocity Acceleration Calibration
Time Roll; Pitch; Yaw Roll rate; Pitch rate; Yaw rate Accel X, Accel Y, Accel Z Sys; Gyro; Accel; Mag
596
600
604
607
611
614
618
621
625
629
632
636
640
644
647
651
654
658
661
665
669
672
676
679
684
687
691
694
698
701
705
709
712
716
719
723
727
731
734
738
741
745
749
752
756
759
763
766
771
774
778
781
785
789
792
796
799
803
806
811
814
818
821
825
829
832
836
839
844
847
851
856
860
867
872
878
883
889
897
903
910
915
921
926
930
936
942
947
952
958
962
966
971
977
982
988
992
998
1002
1009
1013
1020
1030
1040
1050
1060
1070
1080
1090
1100
1110
1120
1130
1140
1150
1160
1170
1180
1190
1200
1210
1220
1230 …
I hope find someone experienced with this IMU.
Any advice of the global syntax of my sketch is welcomed.
Thank you,
Pm