MPU9250: A 9-Axis MEMS Sensor for Motion Tracking

Introduction to MEMS Sensors and the MPU9250

MEMS sensors have revolutionized the field of motion tracking by offering small, low-power, and cost-effective solutions for measuring various physical quantities such as acceleration, angular velocity, and magnetic field strength. These sensors consist of miniaturized mechanical structures integrated with electronic circuitry on a single chip, enabling them to detect and respond to changes in their environment.

The MPU9250 is a prime example of a MEMS sensor that combines multiple sensing capabilities into a single package. Developed by InvenSense (now part of TDK), the MPU9250 integrates a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetometer, providing a total of 9 degrees of freedom (DOF) for motion tracking.

Key Features of the MPU9250

  1. 9-axis motion tracking: The MPU9250 offers 3-axis acceleration, 3-axis angular velocity, and 3-axis magnetic field measurements, enabling comprehensive motion tracking capabilities.
  2. High performance: With a 16-bit analog-to-digital converter (ADC) for each sensor, the MPU9250 delivers high-resolution and low-noise measurements.
  3. Programmable ranges: The sensor allows users to configure the measurement ranges for each sensor, providing flexibility to adapt to different application requirements.
  4. Digital motion processor (DMP): The MPU9250 features an on-chip DMP that can perform complex motion processing algorithms, offloading computational tasks from the host processor.
  5. I2C and SPI interfaces: The sensor supports both I2C and SPI communication protocols, making it compatible with a wide range of microcontrollers and development platforms.

Understanding the MPU9250’s Sensors

To effectively utilize the MPU9250 for motion tracking, it is essential to understand the functionality and characteristics of its individual sensors: the accelerometer, gyroscope, and magnetometer.

Accelerometer

The accelerometer in the MPU9250 measures linear acceleration along three orthogonal axes (X, Y, and Z). It can detect both static and dynamic acceleration, making it useful for determining the orientation of an object with respect to gravity and measuring the object’s motion.

Key specifications of the MPU9250’s accelerometer:
– Programmable full-scale range: ±2g, ±4g, ±8g, ±16g
– Sensitivity: 16384 LSB/g, 8192 LSB/g, 4096 LSB/g, 2048 LSB/g (depending on the selected range)
– Output data rate (ODR): Up to 4 kHz

Gyroscope

The gyroscope measures angular velocity around the three axes (X, Y, and Z). It is essential for tracking rotational motion and maintaining orientation over time. By integrating the angular velocity measurements, it is possible to estimate the object’s orientation changes.

Key specifications of the MPU9250’s gyroscope:
– Programmable full-scale range: ±250°/s, ±500°/s, ±1000°/s, ±2000°/s
– Sensitivity: 131 LSB/(°/s), 65.5 LSB/(°/s), 32.8 LSB/(°/s), 16.4 LSB/(°/s) (depending on the selected range)
– Output data rate (ODR): Up to 8 kHz

Magnetometer

The magnetometer measures the strength and direction of the surrounding magnetic field, including the Earth’s magnetic field. By combining the magnetometer data with the accelerometer and gyroscope readings, it is possible to obtain an absolute orientation reference and improve the accuracy of the motion tracking system.

Key specifications of the MPU9250’s magnetometer (AK8963):
– Full-scale range: ±4800 μT
– Sensitivity: 0.6 μT/LSB
– Output data rate (ODR): Up to 100 Hz

Interfacing with the MPU9250

To integrate the MPU9250 into your project, you need to understand how to connect and communicate with the sensor using either the I2C or SPI interface.

Pin Configuration

The MPU9250 comes in a small QFN (Quad-Flat No-leads) package with dimensions of 3mm x 3mm x 1mm. The pin configuration of the MPU9250 is as follows:

Pin Name Description
1 VDDIO Digital I/O supply voltage (1.71V to 3.6V)
2 AD0/SDO I2C slave address LSB / SPI serial data output
3 REGOUT Regulator filter capacitor connection
4 FSYNC Frame synchronization digital input
5 INT Interrupt digital output
6 VDD Power supply voltage (2.4V to 3.6V)
7 GND Ground
8 RESV(1) Reserved
9 RESV(2) Reserved
10 NC No connect
11 NC No connect
12 NC No connect
13 NC No connect
14 NC No connect
15 AUXDA Auxiliary I2C serial data
16 AUXCL Auxiliary I2C serial clock
17 NC No connect
18 NC No connect
19 NC No connect
20 RESV(3) Reserved
21 AUX_SDA Auxiliary I2C serial data for external sensors
22 nCS SPI chip select (active low)
23 SCL/SCLK I2C serial clock / SPI serial clock
24 SDA/SDI I2C serial data / SPI serial data input

I2C Communication

The MPU9250 can be configured to communicate via the I2C protocol, which requires only two wires: SCL (serial clock) and SDA (serial data). The sensor acts as an I2C slave device, and its 7-bit slave address is determined by the logic level on the AD0 pin:
– If AD0 is connected to GND, the slave address is 0x68 (1101000b)
– If AD0 is connected to VDD, the slave address is 0x69 (1101001b)

To read or write data from/to the MPU9250 via I2C, follow these steps:
1. Start the I2C communication by sending a START condition
2. Send the slave address followed by the R/W bit (0 for write, 1 for read)
3. Wait for the slave to acknowledge (ACK) the address
4. Send the register address you want to read from or write to
5. For a write operation, send the data byte(s) to be written; for a read operation, send a RESTART condition, followed by the slave address with the R/W bit set to 1, and then read the data byte(s) from the slave
6. Send a STOP condition to end the communication

SPI Communication

Alternatively, the MPU9250 can communicate via the SPI protocol, which requires four wires: SCLK (serial clock), SDI (serial data input), SDO (serial data output), and nCS (chip select, active low).

To read or write data from/to the MPU9250 via SPI, follow these steps:
1. Set the nCS pin low to start the SPI communication
2. Send the register address you want to read from or write to, with the most significant bit (MSB) set to 0 for a write operation or 1 for a read operation
3. For a write operation, send the data byte(s) to be written; for a read operation, send dummy bytes (e.g., 0x00) to generate the clock pulses needed to read the data from the slave
4. Set the nCS pin high to end the communication

Configuring and Reading Sensor Data

To start using the MPU9250, you need to configure its registers and read the sensor data. Here’s a step-by-step guide on how to set up and read data from the accelerometer, gyroscope, and magnetometer.

Initialization and Configuration

  1. Check the WHO_AM_I register (0x75) to verify the sensor’s identity. The expected value is 0x71.
  2. Reset the sensor by writing 0x80 to the PWR_MGMT_1 register (0x6B).
  3. Set the clock source by writing the desired value to the CLKSEL bits in the PWR_MGMT_1 register. For example, write 0x01 to select the PLL with X-axis gyroscope reference.
  4. Configure the accelerometer and gyroscope ranges by writing to the ACCEL_CONFIG (0x1C) and GYRO_CONFIG (0x1B) registers, respectively. Set the desired full-scale ranges using the appropriate bits.
  5. Set the sample rate divider in the SMPLRT_DIV register (0x19) to control the output data rate (ODR) of the sensor. The ODR is calculated as follows: ODR = 1000 / (1 + SMPLRT_DIV)

Reading Accelerometer and Gyroscope Data

  1. Read the six bytes of accelerometer data from registers ACCEL_XOUT_H (0x3B) to ACCEL_ZOUT_L (0x40). Combine the high and low bytes for each axis to form 16-bit signed values.
  2. Read the six bytes of gyroscope data from registers GYRO_XOUT_H (0x43) to GYRO_ZOUT_L (0x48). Combine the high and low bytes for each axis to form 16-bit signed values.
  3. Convert the raw sensor values to actual acceleration (in g) and angular velocity (in °/s) using the sensitivity scale factors based on the selected ranges.

Reading Magnetometer Data

  1. Check if the magnetometer is connected by reading the AKM_ID register (0x00) in the AK8963. The expected value is 0x48.
  2. Set the magnetometer to continuous measurement mode by writing 0x16 to the AK8963’s CNTL1 register (0x0A).
  3. Read the seven bytes of magnetometer data from registers HXL (0x03) to HZH (0x09). Combine the high and low bytes for each axis to form 16-bit signed values.
  4. Convert the raw magnetometer values to actual magnetic field strength (in μT) using the sensitivity scale factor (0.6 μT/LSB).

Sensor Fusion and Orientation Estimation

To obtain a complete and accurate representation of an object’s orientation, it is necessary to combine the data from the accelerometer, gyroscope, and magnetometer using sensor fusion algorithms. These algorithms filter, process, and integrate the sensor data to estimate the object’s orientation in 3D space.

Complementary Filter

A simple yet effective sensor fusion method is the complementary filter, which combines the accelerometer and gyroscope data to estimate the orientation. The accelerometer provides an absolute reference for the gravity vector, while the gyroscope measures the angular velocity. The complementary filter uses a weighted average of the accelerometer and gyroscope data, with the weights determined by a gain factor (α) that balances the trust in each sensor.

angle = α * (angle + gyro_data * dt) + (1 - α) * accel_data

Where:
angle is the estimated orientation angle
gyro_data is the angular velocity from the gyroscope
accel_data is the angle calculated from the accelerometer
dt is the time interval between measurements
α is the complementary filter gain (0 < α < 1)

Kalman Filter

The Kalman filter is a more advanced sensor fusion algorithm that provides an optimal estimate of the orientation by combining the sensor data with a model of the system’s dynamics. It recursively updates the orientation estimate based on the predicted state (from the gyroscope) and the measured state (from the accelerometer and magnetometer), taking into account the uncertainty in each measurement.

The Kalman filter consists of two main stages: prediction and update. In the prediction stage, the filter uses the gyroscope data to estimate the current orientation based on the previous estimate. In the update stage, the filter combines the predicted orientation with the measurements from the accelerometer and magnetometer to refine the estimate.

Implementing a Kalman filter for orientation estimation is more complex than a complementary filter, but it offers better performance and adaptability to varying sensor noise and system dynamics.

Madgwick and Mahony Filters

The Madgwick and Mahony filters are two popular sensor fusion algorithms specifically designed for MEMS IMU (Inertial Measurement Unit) applications. These filters are based on quaternion representations of orientation and use a gradient descent optimization approach to minimize the error between the predicted and measured orientation.

The Madgwick filter incorporates both the accelerometer and magnetometer measurements to correct the gyroscope drift, while the Mahony filter relies primarily on the accelerometer data for correction. Both filters have been widely used in various applications due to their computational efficiency and robust performance.

Implementing these filters requires a good understanding of quaternion algebra and optimization techniques. However, there are many open-source libraries and examples available that can help you integrate these algorithms into your projects.

Applications and Use Cases

The MPU9250’s 9-axis motion tracking capabilities make it suitable for a wide range of applications across various industries. Some notable use cases include:

  1. Robotics: The MPU9250 can be used in robotic applications for orientation estimation, stabilization, and navigation. It enables robots to maintain balance, avoid obstacles, and perform precise movements.

  2. Drones and UAVs: Motion tracking is crucial for the stability and control of drones and unmanned aerial vehicles (UAVs). The MPU9250 provides the necessary data for attitude estimation, flight control, and autonomous navigation.

  3. Virtual reality (VR) and augmented reality (AR): The MPU9250 can be integrated into VR and AR headsets to track the user’s head movements and provide an immersive experience. It enables accurate rendering of virtual environments based on the user’s real-world motion.

  4. Wearable devices: The sensor’s small size and low power consumption make it ideal for wearable applications such as fitness trackers, smartwatches, and motion-sensing clothing. It can be used to monitor physical activity, detect gestures, and provide input for user interfaces.

  5. Gaming controllers: The MPU9250 can enhance gaming experiences by enabling motion-based controls in video game controllers, allowing users to interact with games using natural movements and gestures.

  6. Inertial navigation systems (INS): When combined with GPS and other sensors, the MPU9250 can be used in inertial navigation systems for position tracking and guidance in applications such as autonomous vehicles, mobile robots, and personal navigation devices.

Conclusion

The MPU9250 is a powerful and versatile 9-axis MEMS sensor that offers extensive motion tracking capabilities for a wide range of applications. Its integration of an accelerometer, gyroscope, and magnetometer, along with advanced features like a digital motion processor and flexible communication interfaces, makes it an attractive choice for developers and engineers working on projects that require accurate and reliable motion sensing.

By understanding the sensor’s functionality, interfacing options, and data processing techniques, you can effectively harness the potential of the MPU9250 to create innovative motion tracking solutions. Whether you are building a robot, drone, wearable device, or virtual reality system, the MPU9250 provides the foundation for capturing and interpreting the complex dynamics of motion in the physical world.

As you embark on your journey to integrate the MPU9250 into your projects, remember to carefully consider your application requirements, select appropriate sensor fusion algorithms, and leverage the wealth of resources and community support available online. With the right approach and implementation, the MPU9250 can help you unlock new possibilities in motion tracking and bring your ideas to life.

FAQ

  1. What is the difference between the MPU9250 and the MPU6050?
    The main difference is that the MPU9250 includes a magnetometer (AK8963) in addition to the accelerometer and gyroscope found in the MPU

CATEGORIES:

Uncategorized

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Comments

No comments to show.