Skip to content

BUG in the MPU6050 Calibration Process #787

@TLucking

Description

@TLucking

The accelerometer calibration routine (MPU6050_Base::PID()) uses a gravity constant that is exactly 2× too large. As a result, after running CalibrateAccel(), the sensor’s Z-axis reads ~2 g at rest (board flat) instead of ~1 g.

Fix:

  • if (ReadAddress == 0x3B) gravity = 32768 >> getFullScaleAccelRange();
  • if (ReadAddress == 0x3B) gravity = 32768 >> (getFullScaleAccelRange() + 1);
    // equivalent: gravity = 16384 >> getFullScaleAccelRange();

Explenation:
getFullScaleAccelRange() returns 0..3 for ±{2,4,8,16} g. The LSB-per-1 g sensitivity is 16384 >> fs. The code currently uses 32768 >> fs, which is 2 g. Shifting by +1 (i.e., dividing by 2) corrects the target from 2 g to 1 g across all ranges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions