BNo085 read times

paulhat

Member
Hi All,

I have a BNo085 that takes around 1200 microseconds to read a single report (in this case rotation vector over SPI).
I have experimented with different report intervals and SPI speed ranging from 1MHz up to the maximum recommended 3MHz.
I could get read time down to around 1100ms at 3MHz but that still isnt great.
Using Teensy4.0.

Wondering if anyone has found a way to get these things reading faster?

Here is the code for measuring the time taken for the read -

Code:
void IMU_read()
{

start_time = micros();

if (bno08x.getSensorEvent(&sensorValue)){
counter ++;
quaternionToEuler(sensorValue.un.rotationVector.real, sensorValue.un.rotationVector.i,sensorValue.un.rotationVector.j,sensorValue.un.rotationVector.k,   &ypr, true);

}
else
Serial.println("cant read IMU");

finish_time = micros() - start_time ;

Serial.println(finish_time);

}

This bit sets the report up -
Code:
void setReports(void) {
long report_interval = 2500;
Serial.println("Setting desired reports");
if (! bno08x.enableReport(SH2_ROTATION_VECTOR,report_interval)) {//report interval in microseconds
Serial.println("Could not obtain rotation vector");
}
}

Any help appreciated.
 
I have a BNo085 that takes around 1200 microseconds to read a single report (in this case rotation vector over SPI).
I have experimented with different report intervals and SPI speed ranging from 1MHz up to the maximum recommended 3MHz.
I could get read time down to around 1100ms at 3MHz but that still isnt great.
Using Teensy4.0.

Are you confusing ms (milliseconds) and microseconds?
 
No mate, its microseconds. About 1.2 milliseconds per read.
For my application that's too long and is affecting the foc code I'm running with it.
Maybe I'm asking too much.
 
Sorry. I meant to say I am getting 1100 microseconds at 3MHZ. My bad.
The issue is not the rate i can poll the device at. I only want around 200Hz sampling. It's the time it takes that is the issue.
A bit of context. I built a balancing robot which works pretty good. There is however an issue at higher RPM where the time taken for IMU reads is reducing the performance of the FOC brushless motor algorithm. The result is high vibration and poor torque control. To cut a long story short.. the robot cant go too fast.
I can fix the motor issue entirely by removing the IMU reads.
I think I need to build robot V2 which has 2 MCU's. One controlling the motors and the other doing the IMU and PID stuff.

Here is a short video of the current setup -
 
You haven't shown the code for quaternionToEuler.
It might be useful to determine how much time is spent reading the sensor AND how much time is spent evaluating quaternionToEuler.
 
The conversion takes around 2us. Pretty fast.
Almost the entire 1200us is taken up by
Code:
bno08x.getSensorEvent(&sensorValue)

Code:
void quaternionToEuler(float qr, float qi, float qj, float qk, euler_t* ypr, bool Degrees) {

start_time = micros();

float sqr = sq(qr);
float sqi = sq(qi);
float sqj = sq(qj);
float sqk = sq(qk);

ypr->yaw = atan2(2.0 * (qi * qj + qk * qr), (sqi - sqj - sqk + sqr));
ypr->pitch = asin(-2.0 * (qi * qk - qj * qr) / (sqi + sqj + sqk + sqr));
ypr->roll = atan2(2.0 * (qj * qk + qi * qr), (-sqi - sqj + sqk + sqr));

if (Degrees) {
ypr->yaw *= RAD_TO_DEG;
ypr->pitch *= RAD_TO_DEG;
ypr->roll *= RAD_TO_DEG;
}

finish_time = micros() - start_time ;
Serial.println(finish_time);
}
 
Back
Top