# MPU9250
Arduino library for communicating with the [MPU-9250](https://www.invensense.com/products/motion-tracking/9-axis/mpu-9250/) and MPU-9255 nine-axis Inertial Measurement Units (IMU).
# Description
The InvenSense MPU-9250 is a System in Package (SiP) that combines two chips: the MPU-6500 three-axis gyroscope and three-axis accelerometer; and the AK8963 three-axis magnetometer. The MPU-9250 supports I2C, up to 400 kHz, and SPI communication, up to 1 MHz for register setup and 20 MHz for data reading. The following selectable full scale sensor ranges are available:
| Gyroscope Full Scale Range | Accelerometer Full Scale Range | Magnetometer Full Scale Range |
| --- | --- | --- |
| +/- 250 (deg/s) | +/- 2 (g) | +/- 4800 (uT) |
| +/- 500 (deg/s) | +/- 4 (g) | |
| +/- 1000 (deg/s) | +/- 8 (g) | |
| +/- 2000 (deg/s) | +/- 16 (g) | |
The MPU-9250 samples the gyroscopes, accelerometers, and magnetometers with 16 bit analog to digital converters. It also features programmable digital filters, a precision clock, an embedded temperature sensor, programmable interrupts (including wake on motion), and a 512 byte FIFO buffer.
# Usage
This library supports both I2C and SPI commmunication with the MPU-9250.
## Installation
Simply clone or download this library into your Arduino/libraries folder.
## Function Description
This library supports both I2C and SPI communication with the MPU-9250. The *MPU9250* object declaration is overloaded with different declarations for I2C and SPI communication. All other functions remain the same. Additionally, a derived class, *MPU250FIFO*, is included, which provides FIFO setup and data collection functionality in addition to all of the functionality included in the base *MPU9250* class.
## MPU9250 Class
### I2C Object Declaration
**MPU9250(TwoWire &bus,uint8_t address)**
An MPU9250 object should be declared, specifying the I2C bus and MPU-9250 I2C address. The MPU-9250 I2C address will be 0x68 if the AD0 pin is grounded or 0x69 if the AD0 pin is pulled high. For example, the following code declares an MPU9250 object called *IMU* with an MPU-9250 sensor located on I2C bus 0 with a sensor address of 0x68 (AD0 grounded).
```C++
MPU9250 IMU(Wire,0x68);
```
### SPI Object Declaratioon
**MPU9250(SPIClass &bus,uint8_t csPin)**
An MPU9250 object should be declared, specifying the SPI bus and chip select pin used. Multiple MPU-9250 or other SPI objects could be used on the same SPI bus, each with their own chip select pin. The chip select pin can be any available digital pin. For example, the following code declares an MPU9250 object called *IMU* with an MPU-9250 sensor located on SPI bus 0 with chip select pin 10.
```C++
MPU9250 IMU(SPI,10);
```
### Common Setup Functions
The following functions are used to setup the MPU-9250 sensor. These should be called once before data collection, typically this is done in the Arduino *void setup()* function. The *begin* function should always be used. Optionally, the *setAccelRange* and *setGyroRange*, *setDlpfBandwidth*, and *setSrd* functions can be used to set the accelerometer and gyroscope full scale ranges, DLPF bandwidth, and SRD to values other than default. The *enableDataReadyInterrupt* and *disableDataReadyInterrupt* control whether the MPU-9250 generates an interrupt on data ready. The *enableWakeOnMotion* puts the MPU-9250 into a low power mode and enables an interrupt when motion detected is above a given threshold. Finally, *enableFifo* sets up and enables the FIFO buffer. These functions are described in detail, below.
**int begin()**
This should be called in your setup function. It initializes communication with the MPU-9250, sets up the sensor for reading data, and estimates the gyro bias, which is removed from the sensor data. This function returns a positive value on a successful initialization and returns a negative value on an unsuccesful initialization. If unsuccessful, please check your wiring or try resetting power to the sensor. The following is an example of setting up the MPU-9250.
```C++
int status;
status = IMU.begin();
```
#### Configuration Functions
**(optional) int setAccelRange(AccelRange range)**
This function sets the accelerometer full scale range to the given value. By default, if this function is not called, a full scale range of +/- 16 g will be used. The enumerated accelerometer full scale ranges are:
| Accelerometer Name | Accelerometer Full Scale Range |
| ------------------ | ------------------------------ |
| ACCEL_RANGE_2G | +/- 2 (g) |
| ACCEL_RANGE_4G | +/- 4 (g) |
| ACCEL_RANGE_8G | +/- 8 (g) |
| ACCEL_RANGE_16G | +/- 16 (g) |
This function returns a positive value on success and a negative value on failure. Please see the *Advanced_I2C example*. The following is an example of selecting an accelerometer full scale range of +/- 8g.
```C++
status = IMU.setAccelRange(MPU9250::ACCEL_RANGE_8G);
```
**(optional) int setGyroRange(GyroRange range)**
This function sets the gyroscope full scale range to the given value. By default, if this function is not called, a full scale range of +/- 2000 deg/s will be used. The enumerated gyroscope full scale ranges are:
| Gyroscope Name | Gyroscope Full Scale Range |
| ------------------ | -------------------------- |
| GYRO_RANGE_250DPS | +/- 250 (deg/s) |
| GYRO_RANGE_500DPS | +/- 500 (deg/s) |
| GYRO_RANGE_1000DPS | +/- 1000 (deg/s) |
| GYRO_RANGE_2000DPS | +/- 2000 (deg/s) |
This function returns a positive value on success and a negative value on failure. Please see the *Advanced_I2C example*. The following is an example of selecting an gyroscope full scale range of +/- 250 deg/s.
```C++
status = IMU.setGyroRange(MPU9250::GYRO_RANGE_250DPS);
```
**(optional) int setDlpfBandwidth(DlpfBandwidth bandwidth)**
This is an optional function to set the programmable Digital Low Pass Filter (DLPF) bandwidth. By default, if this function is not called, a DLPF bandwidth of 184 Hz is used. The following DLPF bandwidths are supported:
| Bandwidth Name | DLPF Bandwidth | Gyroscope Delay | Accelerometer Delay | Temperature Bandwidth | Temperature Delay |
| --- | --- | --- | --- | --- | --- |
| DLPF_BANDWIDTH_184HZ | 184 Hz | 2.9 ms | 5.8 ms | 188 Hz | 1.9 ms |
| DLPF_BANDWIDTH_92HZ | 92 Hz | 3.9 ms | 7.8 ms | 98 Hz | 2.8 ms |
| DLPF_BANDWIDTH_41HZ | 41 Hz | 5.9 ms | 11.8 ms | 42 Hz | 4.8 ms |
| DLPF_BANDWIDTH_20HZ | 20 Hz | 9.9 ms | 19.8 ms | 20 Hz | 8.3 ms |
| DLPF_BANDWIDTH_10HZ | 10 Hz | 17.85 ms | 35.7 ms | 10 Hz | 13.4 ms |
| DLPF_BANDWIDTH_5HZ | 5 Hz | 33.48 ms | 66.96 ms | 5 Hz | 18.6 ms |
This function returns a positive value on success and a negative value on failure. Please see the *Advanced_I2C example*. The following is an example of selecting a DLPF bandwidth of 20 Hz.
```C++
status = IMU.setDlpfBandwidth(MPU9250::DLPF_BANDWIDTH_20HZ);
```
**(optional) int setSrd(uint8_t srd)**
This is an optional function to set the data output rate. The data output rate is set by a sample rate divider, *uint8_t SRD*. The data output rate is then given by:
*Data Output Rate = 1000 / (1 + SRD)*
By default, if this function is not called, an SRD of 0 is used resulting in a data output rate of 1000 Hz. This allows the data output rate for the gyroscopes, accelerometers, and temperature sensor to be set between 3.9 Hz and 1000 Hz. Note that data should be read at or above the selected rate. In order to prevent aliasing, the data should be sampled at twice the frequency of the DLPF bandwidth or higher. For example, this means for a DLPF bandwidth set to 41 Hz, the data output rate and data collection should be at frequencies of 82 Hz or higher.
The magnetometer is fixed to an output rate of:
没有合适的资源?快使用搜索试试~ 我知道了~
(源码)基于Arduino和Labview的无人机加速度测量系统.zip
共20个文件
ino:7个
pdf:6个
md:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 122 浏览量
2024-11-24
01:18:46
上传
评论
收藏 3.4MB ZIP 举报
温馨提示
# 基于Arduino和Labview的无人机加速度测量系统 ## 项目简介 这是一个基于Arduino和Labview的无人机加速度测量系统。通过使用MPU 9250传感器,我们能够精确地测量无人机的加速度。该项目旨在提供一种简单而有效的方法来监控无人机的加速度率,以确保其性能和安全。 ## 项目的主要特性和功能 1. 硬件配置 主要使用Arduino Mega作为微控制器,与MPU 9250传感器进行通信。 通过串行通信将MPU 9250传感器数据发送到Labview程序。 2. 软件功能 Labview程序持续测量并显示加速度数据,包括在面板上和图形上。 提供了一种用户友好的界面来查看实时数据和图形。 3. 传感器库 MPU9250.cpp库文件提供了与MPU9250传感器通信的功能,包括初始化传感器、读取传感器数据、设置传感器参数等。 ## 安装使用步骤 1. 软件安装
资源推荐
资源详情
资源评论
收起资源包目录
(源码)基于Arduino和Labview的无人机加速度测量系统.zip (20个子文件)
MPU9250-master
MPU9250.h 11KB
examples
FIFO_SPI
FIFO_SPI.ino 3KB
Advanced_I2C
Advanced_I2C.ino 3KB
Basic_I2C
Basic_I2C.ino 2KB
Interrupt_SPI
Interrupt_SPI.ino 3KB
Basic_SPI
Basic_SPI.ino 2KB
WOM_I2C
WOM_I2C.ino 2KB
keywords.txt 1KB
docs
AK8963C.pdf 650KB
MPU-9250-Datasheet.pdf 655KB
MPU-9255-Datasheet.pdf 469KB
MPU-9250-Register-Map.pdf 508KB
MPU-9255-Register-Map.pdf 723KB
MPU-9250-AXIS.png 32KB
Embedded-Masters-MPU-9250-Breakout.pdf 598KB
README.md 31KB
MPU9250.cpp 32KB
Acceleration.vi 23KB
README.md 2KB
Acceleration
Acceleration.ino 903B
共 20 条
- 1
资源评论
t0_54coder
- 粉丝: 2550
- 资源: 5606
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功