Projects

Wednesday, 26 February 2014

MPU 9150: We are reading the magnetometer



Hi there. 
During the weekend we dedicated some time to integrate the MPU-9150 with Arduino Mega board to access the compass data. 

We needed to update the firmware wrt the one provided by Sparkfun. However after solving some problem we finally got the magnetometers measurements. 
We ended up using the code from Pansenti (just take note not to ask for too high output rates from the magnetometer, 50Hz is a good value).
If you want you can use the code made available at Sparkfun, you will have to make some corrections. Unlike all the other sensors and respective registers, the magnetometer writes to its data registers in little-endian! To correct the code, just swap the byte order at the function that reads the magnetometer. In the file MPU6050.cpp, in function getMotion9, change the lines 1729-1731 to:

*mx = (((int16_t)buffer[1]) << 8) | buffer[0];
*my = (((int16_t)buffer[3]) << 8) | buffer[2];
*mz = (((int16_t)buffer[5]) << 8) | buffer[4];

Here below you can find a simple video with the main steps we followed. 


Soon the comparison among the MPU-9150 and the HMC5883L compass performances!
Stay tunned!

3 comments:

  1. The Pansenti lib is no longer available on GitHub,
    I think this is a fork or copy

    https://github.com/richards-tech/MPU9150Lib

    ReplyDelete
  2. Sorry, forgot to post my name etc (above)

    ReplyDelete
  3. Oh MPU-9150? Is that the first 9-axis motion tracking device designed for low power? Great attempt. The video was helpful too. And sure, we will stay tunned for the performance of HMC5883L compass! Looking forward for more news on magnetometer readings and new magnetometer applications in geology.

    ReplyDelete