-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Open
Description
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
Labels
No labels