Monday, February 4, 2013

AVR Atmega MPU6050 gyroscope and accelerometer lib + processing

Updated to version 05

The MPU-6050 has an embedded 3-axis MEMS gyroscope, a 3-axis MEMS accelerometer, and a Digital Motion Processor (DMP) hardware accelerator engine with an auxiliary I2C port that interfaces to 3rd party digital sensors such as magnetometers.



In this libray, two attitude extimation mode are implemented, based on gyro + accelerometer
  • internal DMP processor
  • mahony filter


Gyro calibration is suggested to get more accurate parameters.
Setup parameters are stored in file mpu6050.h

A processing.org sketch is provided to display attitude estimation.


This library is developed on Eclipse, built with avr-gcc on Atmega168 @ 16MHz.

In addition to the processing sketch, Omid Abolghasemi provides this Matlab code to visualize quaternion data:
http://www.mathworks.com/matlabcentral/fileexchange/45302-serialport-quaternion-data-visualize


Changelog
  • 05: moved timer settings to header file
  • 04: fixed get/set accelerometer and accelgyroscope offset for DMP
  • 03: init fix to prevent random incorrect +/- 16g scaling register setup at startup (fix by Len Spyker)
  • 02: attitude estimation refactored to fit standards
  • 01: first release


Code


Notes
  • read risk disclaimer
  • excuse my bad english