Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gyro bmi160 and fix gyro i2c address #83

Merged
merged 5 commits into from
Sep 20, 2023

Conversation

AutoPlantBali
Copy link

esp32 bmi160 on spi
esp32_bmi160_spi

esp32 bmi160 on i2c
esp32_bmi160_i2c

rp2040 bmi160 on spi
rp2040_bmi160_spi

fix i2c address detect 0x76 and 0x77
#81

Copy link
Owner

@rtlopez rtlopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AutoPlantBali Thanks for your contribution. I'd like to ask, that did you build any craft with this gyro? can you confirm that this code works "in the air"? Can you show any blacbox recording?

Fix for alternative i2c address looks fine.

Cheers


/* Issue a dummy-read to force the device into SPI comms mode */
uint8_t dummy = 0;
_bus->readByte(_addr, 0x7F, &dummy);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid using magic numbers in code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add it to the define list

delay(1);

// Set Accel ODR to 400hz, BWP mode to Oversample 4, LPF of ~40.5hz
_bus->writeByte(_addr, BMI160_RA_ACCEL_CONF, 0x0A);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this comment match real setting? 400 Hz ODR and 40Hz LPF is actually useless, either for accel and gyro.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** Get accelerometer output data rate.

  • The acc_odr parameter allows setting the output data rate of the accelerometer
  • as described in the table below.
  • 5 = 25/2Hz
  • 6 = 25Hz
  • 7 = 50Hz
  • 8 = 100Hz
  • 9 = 200Hz
  • 10 = 400Hz
  • 11 = 800Hz
  • 12 = 1600Hz
  • 13 = 3200Hz


int getRate() const override
{
return 8000;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't studied the BMI160 documentation deeply yet, but it seems that its native operating frequency is 3200Hz. It is good for ODR to be equal to gyro reading rate. So return 3200 here, and set correct ODR in setRate() method below. You can find proper formula in datasheet. Accel ODR is not as much important, can be fixed on frequency close to 500Hz.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it by taking the response from the sensor

@AutoPlantBali
Copy link
Author

Hi @AutoPlantBali Thanks for your contribution. I'd like to ask, that did you build any craft with this gyro? can you confirm that this code works "in the air"? Can you show any blacbox recording?

Fix for alternative i2c address looks fine.

Cheers

I made a board that supports mpu6500, mpu9250, bmi160, lsm6ds and bmp280. Next month I will order the PCB and start assembling it. I will show the results of testing using this sensor
esp_fc_top

@rtlopez rtlopez changed the base branch from master to develop September 20, 2023 20:21
@rtlopez rtlopez merged commit 2f10631 into rtlopez:develop Sep 20, 2023
4 checks passed
@rtlopez
Copy link
Owner

rtlopez commented Sep 20, 2023

Hi @AutoPlantBali, I merged your changes to develop branch, as I want to do some tests first. Next time It would be better if you put different features and fixes in separate PRs. Thanks again.

@rtlopez
Copy link
Owner

rtlopez commented Sep 21, 2023

Hi @AutoPlantBali I've connected brand new BMI160 gyro, and calibration not passed. It seems that gyro has stored inaccurate offset values in NVM, this caused that gyro bias for x and y axis was around 10 deg/s. If I turn off applying offset, then bias is about 1 deg/s. Can you test these changes from develop branch with your device?
19ed007
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants