is there a way to reset the work of bno055 in the loop?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
DjangoTango
 
Posts: 18
Joined: Sun Oct 31, 2021 12:12 pm

is there a way to reset the work of bno055 in the loop?

Post by DjangoTango »

Hi All,
I am using the bno055 to register some data. Suddenly, during the records, without a systematic time, the bno055 stops varying its output. If I reset the controller, the bno055 seems to work. I tried to reset the sensor directly inside the loop to avoid the controller's reset, but nothing happened. I did not find so much info about the reset of bno055. Can someone give me some tips to reach the solution?
Here's my code:

Code: Select all

/*** BUFFER******/
#include <SDRAM.h>
SDRAMClass mySDRAM;
float  *dataA;

/****  BNO055  ****/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno(-1, BNO055_ADDRESS_A, &Wire1);



/***Calculus****/
float q0A, q1A, q2A, q3A, gxA, gyA, gzA, normA, angle, accA, vxA, vyA, vzA, rollA, pitchA, yawA, axA, ayA, azA, gyxA, gyyA, gyzA;
float radtodeg = 57296 / 1000;
int j=0;

void setup() {
  Wire1.begin();
  Wire1.setClock(400000); //4Khz
  while (!_UART_USB_);

  /****  BNO055  ****/
  if (!bno.begin()) {
    _UART_USB_.print("Ooops, BNO055 Coscia not detected");
    while (1);
  }
  bno.setExtCrystalUse(true);

  dataA = (float*)SDRAM.malloc(0.5 * 512 * 512);
 

}

void loop() {
  imu::Quaternion quatA = bno.getQuat();
  q0A = quatA.w(); q1A = quatA.x(); q2A = quatA.y(); q3A = quatA.z();
  gxA = q1A * q3A - q0A * q2A; gyA = q0A * q1A + q2A * q3A; gzA = q0A * q0A + q3A * q3A - 0.5f;
  normA = sqrt(gxA * gxA + gyA * gyA + gzA * gzA); normA = 1.0 / normA;
  gxA *= normA; gyA *= normA; gzA *= normA;
  angle = acos(gxA); angle = angle * radtodeg;
  dataA1[j] = angle;
  if (angle==dataA[j-1] && angle==dataA[j-2]){
    /*******RESET******/
    bno.begin();
    delay(1000);
  }
  j++;
 
}


User avatar
gammaburst
 
Posts: 1015
Joined: Thu Dec 31, 2015 12:06 pm

Re: is there a way to reset the work of bno055 in the loop?

Post by gammaburst »

Difficult to guess without more clues.
What type of microcontroller/computer is this?
How exactly is it wired to the BNO055?
Anything else connected to the I2C bus?
Does the project behave better if you remove "bno.setExtCrystalUse(true);"?
Does the project behave better if you add "delay(10);" to the main "loop()"?

Do you know if your I2C controller performs a proper bus-clear when it detects a slave device holding SDA low? A controller that fails to do that can cause an I2C project to "gets stuck" and require awkward power-cycling or other manual intervention/reset to get it running again.

I'm unable to easily run your code without modifications:
- I'm unfamiliar with SDRAM.h and _UART_USB_
- dataA1 seems undefined
- beware, malloc() return status is ignored
- beware, j will eventually exceed the allocated buffer

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”