11 experiments

MPU-6050 Journey

  1. Experiment #002

    MPU6050 Accelerometer Calibration: Six-Position Method on STM32

    How to calibrate an MPU6050 accelerometer using gravity as the only reference — six static positions, no jig or rotary stage. Covers measuring bias and scale, validating the result, and which constants belong in firmware.

    Read article Source code

  2. Experiment #003

    MPU6050 Gyroscope Calibration: Bias Compensation and Scale Factor Without a Rate Table

    How to calibrate an MPU6050 gyroscope with nothing but gravity and a pair of hands — measuring the zero point at startup, extracting the scale factor by tilting between two resting positions, and comparing what each compensation actually buys.

    Read article Source code

  3. Experiment #004

    MPU6050 Timing and Sampling: Why a 1 kHz Sensor Does Not Sample Every 1000 µs

    How to measure an MPU6050's real sampling interval from inside the MCU, using the Cortex-M DWT cycle counter on the data-ready interrupt. Covers the clock source that made the sensor 1.2 % fast, how measurement resolution hides jitter, and why an integral needs a measured dt.

    Read article Source code

  4. Experiment #005

    MPU6050 Noise and Filtering: How Much Is Noise, and What Does a Filter Cost?

    How much of a stationary MPU6050's output is noise, what the internal DLPF removes, and what the same job costs in software. Measured with FFT, a spectrogram and standard deviation, with the response delay each cutoff frequency buys.

    Read article Source code

  5. Experiment #006

    MPU6050 Roll and Pitch: Estimating Attitude from the Gravity Vector

    Turning three calibrated accelerometer channels into roll and pitch with two atan2 calls. The geometry behind the equations, the plus or minus 180 degree wrap, why pitch stops at 90 degrees, how stable the result is, and what linear acceleration does to it.

    Read article Source code

  6. Experiment #007

    When Accelerometer Roll Estimation Fails: The Pitch Singularity

    As pitch approaches 90 degrees the accelerometer roll estimate becomes unstable while the sensor barely moves. Why the information disappears, what a regularization coefficient buys, what it costs, and the measured tradeoff across five values of the coefficient.

    Read article Source code

  7. Experiment #008

    Can a Gyroscope Be Used as an Attitude Sensor?

    Integrating MPU6050 gyro rates into roll, pitch and yaw. It passes straight through the orientation where the accelerometer breaks down, it is the only source of relative yaw, and over five stationary minutes it wandered 1.1, 0.8 and 0.37 degrees. Then the temperature moved.

    Read article Source code

  8. Experiment #009

    What Does a Complementary Filter Actually Fix?

    Blending the MPU6050 accelerometer and gyroscope with one line of arithmetic. Six time constants recorded side by side. It cut attitude noise by six to seven times and removed a 23 degree integration error. It only damps a linear-acceleration disturbance rather than rejecting it, and it does not repair the collapse of roll near 90 degrees of pitch.

    Read article Source code

  9. Experiment #010

    Quaternion Attitude Estimation

    Replacing Euler angles with a quaternion inside the estimator, and deriving the propagation equation rather than copying it. A proportional gravity feedback loop was run at three gains at once. The loop's time constant measured 1 divided by the gain across two decades, and a quaternion sailed through 90 degrees of pitch while the Euler roll read from it swung 140 degrees in 62 milliseconds.

    Read article Source code

  10. Experiment #011

    Mahony AHRS and Online Gyroscope Bias Estimation

    Adding integral feedback to the quaternion estimator from experiment 010 so that it learns a gyroscope bias while the firmware keeps running. Four integral gains ran side by side on the same samples while a known offset was written into the gyroscope calibration by hand. The estimates reached 88 and 81 percent of the offset on two axes and had the opposite sign on the third, and the shortfall matched the one component of the bias that gravity cannot show.

    Read article Source code