Post


MPU-9150 Hookup Guide

MPU-9150 Hookup Guide

Introduction

The MPU-9150 is a nine degrees ofreedom (9DOF) inertial measurement unit (IMU) in a sigle package. It houses a 3-axis accelerometer, 3-axis gyroscope, 3-axis magnetometer and a Digital Motion Processor™ (DMP™) hardware accelerator engine. The range of each sensor is configurable: the accelerometer's scale can be set to ±2g, ±4g, ±6g, ±8g, or ±16g, the gyroscope supports ±250, ±500, and ±2000 °/s, and the magnetometer has full-scale range of ±1200µT (±12 gauss).

MPU-9150

The MPU-9150 supports I2C. There is a single reference to in the datasheet for SPI, but all other evidence points to the contrary. We have only testing using I2C, and, for the purposes of this tutorial, we will only be covering how to use this device in I2C mode.

Covered In This Tutorial

This tutorial is devoted to all things MPU-9150. First we'll introduce you to the breakout board. Then we'll switch over to example code and show you how to interface with the board using an Arduino and our [SFE_MPU-9150 Arduino library](https://cdn.sparkfun.com/assets/learn_tutorials/3/9/7/MPU-9150_libraries.zip).

The tutorial is split into the following sections:

 

The MPU-9150 is a 3.3V device! Supplying voltages greater than 6V can permanently damage the IC. InvenSense recommends running from 2.375V to 3.465V. As long as your Arduino has a 3.3V supply output, and you're OK with using I2C, you shouldn't need any extra level shifting.

Suggested Reading

If you’re not familiar with some of the concepts below, we recommend checking out that tutorial before continuing on.

Hardware Overview

The Pinout

In total, the MPU-9150 Breakout breaks out 11 pins.

MPU-9150 product photo

The bare-minimum connections required are broken out on the left side of the board. These are the power and I2C pins (the communication interface the board defaults to):

Pin Label Pin Function Notes
GND Ground 0V voltage supply
VCC Power Supply Supply voltage to the chip. Should be regulated between 2.375V and 3.465V.
SDA I2C: Serial Data I2C: Serial data (bi-directional)
SCL Serial Clock I2C serial clock (up to 400kHz)

The remaining pins break out additional functionality and interrupt outputs:

Pin Label Pin Function Notes
ESD Auxiliary I2C master serial data 9150 can act as a master or pass-through to additional I2C devices.
ESC Auxiliary I2C master serial clock 9150 can act as a master or pass-through to additional I2C devices.
COUT Clock output Outputs a 50% duty cycle square wave (see register map).
CIN Clock input Optional external reference clock input, grounded through jumper.
I using an external clock source, cut 'CLK' jumper.
AD0 I2C Slave Address LSB If low I2C address is 0x68, else 0x69. Connected to jumper. (0x68 default)
FSYNC Frame synchronization External frame sync input that latches to capture external bus interrupts
If using this pin cut 'SYNC' jumper.
INT Interrupt pin Configurable digital output to signal the host processor of an event.

Power Supply

The VCC and GND pins are where you'll supply a voltage and 0V reference to the IC. The breakout board does not regulate this voltage, so make sure it falls within the allowed supply voltage range of the MPU-9150: 2.375V to 3.465V. Logic voltage levels can be as low as 1.8V ±5% up to VCC.

The communication pins are not 5V tolerant, so they’ll need to be regulated to within a few mV of VDD.

Communication

SDA, SCL, ESD, and ESC are used for the I2C interfaces. The auxiliary clock and data pins will require external pull-up resistors. These ave to be tuned on a case-by-case basis depending on bus capacitance to get proper rise times.

SDA and SCL have integrated 10KΩ pull-ups. If you plan on using more than one I2C device on the bus, you might want to remove these pull-ups. If the I2C lines are pulled-up too strongly by multiple sets of pull-ups, the bus will likely be out of spec and not function correctly.

The following image shows a stock PCBA on the left, and one with the pull-up resistors removed on the right. To remove these, I recommend reflowing a fair amount of solder onto the resistors. It doens't take very long to fully cover all 4 joints with molten solder and the two part will slide right off. So easily in my case that I wasn't able to capture a picture of the excess solder before the parts had come off. Wick off the excess solder, wipe clean with some DI water, and you are done.

pull-ups removed

Interrupts

There are a variety of interrupts on the MPU-9150. While connecting up to these is not as critical as the communication or power supply pins, using them will help you get the most out of the chip. The INT pin is a digital output to the host controller. The FSYNC pin can be configured as an interrupt input to optionally be passed through out the INT pin.

These can be programmed to interrupt as either active-high or active-low. More details on these configurations can be found in the product register map.

The Jumpers

The most commonly used jumper will be to the address pin (AD0). It defaults to being pulled to ground selecting address 0x68, but with a soldering iron can be changed to be pulled up, switching the I2C address to 0x69.

The AD0 pin broken out is connected directly to ground by default. Alternatively it's connected straight to VCC. Make sure to remove the solder from both sides of the 3-way jumper before connecting it externally.

Address jumper

The address selection jumper on the front of the board. Allows you to select the LSB of the I2C address

The intention of these jumpers is to make it as easy-as-possible to use the board; using as few wires as possible. The CLK jumper is used to ground the external clock input as the datasheet recommends when not using an external clock. Make sure to cut this jumper if you attach an external clock to the CIN connection. The SYNC jumper ties FSYNC to ground as the manufacturer instructs one to do when not using it. Make sure to cut this jumper if use the FSYNC through hole connection.

Back of MPU-9150 Breakout

To disable any of these jumpers, whip out your handy hobby knife, and carefully cut the small traces between middle pad and edge pads.

Funny Business

Be very careful trusting the datasheet. It's full of inconsistencies or lacking clarification. For example pin 22. There is a single reference to it functioning as a clock output (next image). There are several places stating that it's not to be used, such as the table shown two images below.

alt text

Only reference to CLKOUT in datasheet

 

alt text

One of several examples of pin 22 being recommended to not be connected or a clock

The register map reads "This bit also enables the clock output.", but that's the only reference. It's not even specified clearly to which bit they are referring. We were able to test this, and sure enough it outputs a clock. Maybe this clock is is okay to use. Maybe it was designed for factory testing only.

alt text

Enabling this clock output was persistent even after a power cycle. Be careful when changing under documented bits in the registers!

SPI is another example of being poorly documented. The following image implies that the address selection line is also SDO. The digital IO power supply pin is also the chip select line. Most serial peripherals we are familiar with don't source power out their chip select pins.

alt text

Only reference to SPI in the datasheet or the register map

Finally one last quote to show how amazing the datasheet is: "The internal registers and memory of the MPU-9150 can be accessed using either I2C at 400 kHz." Either fast mode I2C, or what? As often as we tell you to RTFM, sometimes the manual can be misleading.

Hardware Assembly

The basic use case for the MPU-9150 requires four connections to the µController or µProcessor; power, ground, I2C clock and data. The following images shows how we used a SparkFun FTDI Basic Breakout, and an 3.3V Arduino Pro Mini to power and interface to an MPU-9150. The demo required the use of an interrupt (right-most yellow jumper) connected to D2 (INT0).

hooked-up

An MPU-9150 wired up to and Arduino Pro Mini for the MPU6050_DMP6 demo

Make connections to the breakout anyway that makes you happy. The board in the above photo has a right angle header soldered to it. We could have used a straight header, or wire, etc. Please note that different mounting orientations will alter the orientation of the axes. Make sure your code matches the physical orientation for your projects.

For this demo, we made the following connections:

Arduino Pro Mini MPU‑9150 Breakout Notes
VCC VCC +3.3V
GND GND +0V
SDA SDA Serial data @ +3.3V CMOS logic
SCL SCL Serial clock @ +3.3V CMOS logic
D2 INT INT0 on Arduino | Interrupt output "totem pole or open-drain" on MPU-9150

The whole system in our testing was powered via USB through the FTDI basic.

USB to FTDI to Pro Mini to MPU-9150 Breakout Fritzing diagram

Electrical connections for demo

Installing the Arduino Library

Download and Install the Library

Visit the http://iocare.in/sensor-libraries

Download all labraries, contains library for MPU-6050 with examples.

The example Arduino code allows you to do things like print raw accelerometer, gyro, and magnetometer data. The original library came from i2cdevlib.com and was based on the very similar MPU-6050, which only used an accelerometer and gyro. The MPU-6050 device library was modified to include raw magnetometer data for the MPU-9150.

Running the MPU6050_DMP6 Example

Now, you can now run the example sketches. Open File ⇒ Examples ⇒ ioCaresensorpack⇒ Examples ⇒ MPU6050_DMP6.

Posted in Arduino 01 Aug 2017