Reading IMU (BNO055) interferes with BLDC rotation rate

Whenever I read data from my IMU (BNO055) it interferes with the rotation of my brushless DC Motor. I get random spikes in RPM from the Motors - since I am building a quadcopter, this results in immense instability.

Setup:

  1. Reading IMU data
  2. Reading Potentiometer Value
  3. Writing to ESC to power BLDC

Observation:
BLDC rotation rate spikes irregularly (Motor turns faster for like a millisecond) whenever I read IMU data.

Remedies:

  1. I remove the line of code where I read the IMU data
  2. I introduce a delay of 100ms

I need at least 120Hz to achieve stable hover, so:

  1. I need the IMU data
  2. having a 100ms delay is not an option

Videos for showcase:

  1. https://www.youtube.com/shorts/WHC9-OSielg
    -> You can hear the spikes in RPM

  2. https://www.youtube.com/shorts/D3Z8-p7Zilw
    -> As soon as I remove one line of code (IMU reading), motor runs smoothly

My code:

#include <Arduino.h>

// Servo
#include <Servo.h>
Servo ESC;
int const escPin = 9;

// IMU
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BNO055.h>
#include <Adafruit_Sensor.h>
Adafruit_BNO055 myIMU = Adafruit_BNO055();

void setup()
{
  Serial.begin(115200);

  // Initializing ESC
  ESC.attach(escPin, 1000, 2000);

  // Initializing IMU
  myIMU.begin();
  myIMU.setExtCrystalUse(true);

  delay(1000);
}

void loop()
{
  // Reading IMU -> the line of code in question
  imu::Quaternion quat = myIMU.getQuat();

  // Reading Potentiometer
  float potVal = analogRead(A0);

  // Writing to Motor
  potVal = map(potVal, 0, 1023, 0, 180);
  ESC.write(potVal);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.