Close

MPU-6050+Compass (9-axis IMU)

A project log for MagiLog: Open Automotive Datalogging

Developing a full featured datalogger on the cheap

nigelNigel 04/06/2018 at 21:330 Comments

One of the most important data types I'll be logging is inertial measurements of the car. As our logging rate will be higher than the GPS update rate we need to use IMU data not only for its own purposes but to interpolate between GPS updates. There are a few options for how to merge the two, but I'll likely go with a Kalman Filter.

The IMU unit I originally specced was the MPU-6050, in particular the official eval board with an included AKM compass for 9 axis data. In retrospect I should have selected the MPU-6000 at the time as it has an  SPI interface that is both easier to use than I2C and does not require me to make an additional protocol hardware block for the FPGA. In the time since I purchased that board Invensense (Now owned by TDK) has come out with an upgraded version called the MPU-9250. The 9250 removes the need for an external compass and comes with an SPI interface. Sparkfun makes  a breakout board that's around a quarter the cost of the official dev board so I'll likely end up picking one of those up.

In the meantime I'll use what I have to get familiar with the register system and the general I/O workflow of using this line of sensors.

The tool I'll be using to interface with most peripherals during this initial dev phase will be the Bus Pirate, which you can think of as a kind of multitool for serial based communication. To hook up the eval board to the bus pirate we make the following connections: (You'll want to be careful that you use the right hookup guide for your Bus Pirate version. Use "v" to confirm)

MPU VCC -> BP 5V

MPU 2x Gnd -> BP Gnd

MPU LDO_en -> BP 5V

MPU SDA -> BP MOSI

MPU SCL -> BP CLK

MPU FSYNC -> BP Gnd

MPU Int_i -> BP Gnd

BP 3.3V -> BP Vpu

Before diving in completely I recommend you familiarize yourself with the communication protocol. It's explained in the MPU-60X0 datasheet.

Once you have everything all connected fire up your preferred terminal program and connect to the bus pirate over a COM port. From here first enter m to open the protocol list and then 4 to select I2C. Once you finish up with the options turn on the power supplies and the pull up resistors to finish configuring the Bus Pirate for I2C. Run the I2C scanner macro "(1)" to make sure that we are picking up that the device is connected to the bus.

From here check to see if we can read a static register like the "Who Am I" register. Once we have confirmed the connection we check the sleep status to see it has powered up in sleep mode, followed by confirming that data out registers are still empty.

We then write to the power management register to turn off sleep and verify that our settings have taken. Once that's done we can read any of the data registers to get the most recent data from that set.

I'll need to keep playing around with this and start to think of the easiest way in hardware to combine two 8-bit frames into one 16-bit number. Both SPI and I2C use 8 bit numbers so we'll need to read from two adjacent registers to get the entire number. I also need to figure out the specifics of the data fusion and where that actual computation will be taking place.

Discussions