IoT
fabo
mems
mpu9250

9軸加速度センサー MPU9250をArduinoで制御する その1(I2C)

More than 3 years have passed since last update.


MPU9250

rp-mpu-9250.png


Datasheet

MPU9250 Datasheet

MPU9250 Registermap


計測可能な値

MPU-9250では、MPU-9250とAK8963のCombo Memsである。MPU-9250とAK8963は別々のSlave Addressが割り振られているため、それぞれにアクセスする。

種類
概要

Gyroscope

Accelerometer

Magnetometer


Slave address

センサー
Slave address
用途

MPU9250
0x68
3軸加速度、ジャイロ

AK8963
0x0C
コンパス


(MPU9250)Register map(Selftest)

Address
Name
Type

0x00
SELF_TEST_X_GYRO
R/W
xg_st_data [7:0]

0x01
SELF_TEST_Y_GYRO
R/W
yg_st_data [7:0]

0x02
SELF_TEST_Z_GYRO
R/W
zg_st_data [7:0]

0x0D
SELF_TEST_X_ACCEL
R/W
XA_ST_DATA [7:0]

0x0E
SELF_TEST_Y_ACCEL
R/W
YA_ST_DATA [7:0]

0x0F
SELF_TEST_Z_ACCEL
R/W
ZA_ST_DATA [7:0]

0x13
XG_OFFSET_H
R/W
X_OFFS_USR [15:8]

0x14
XG_OFFSET_L
R/W
X_OFFS_USR [7:0]

0x21
YG_OFFSET_H
R/W
Y_OFFS_USR [15:8]

0x22
YG_OFFSET_L
R/W
Y_OFFS_USR [7:0]

0x17
ZG_OFFSET_H
R/W
Z_OFFS_USR [15:8]

0x18
ZG_OFFSET_L
R/W
Z_OFFS_USR [7:0]

0x19
SMPLRT_DIV
R/W
SMPLRT_DIV[7:0]


(MPU9250)Register map(Configuration)

Address
Name
Type

0x1A
CONFIG
R/W
Config

0x1B
GYRO_CONFIG
R/W
GyroscopeのConfig

0x1C
ACCEL_CONFIG
R/W
AccelerometerのConfig

0x1D
ACCEL_CONFIG2
R/W
AccelerometerのConfig

0x1E
LP_ACCEL_ODR
R/W
Lposc_clksel

0x1F
WOM_THR
R/W
WOM_Threshold [7:0]


(MPU9250)Register map(Accelerometer)

Address
Name
Type

0x3B
ACCEL_XOUT_H
R
ACCEL_XOUT_H[15:8]

0x3C
ACCEL_XOUT_L
R
ACCEL_XOUT_L[7:0]

0x3D
ACCEL_YOUT_H
R
ACCEL_YOUT_H[15:8]

0x3E
ACCEL_YOUT_L
R
ACCEL_YOUT_L[7:0]

0x3F
ACCEL_ZOUT_H
R
ACCEL_ZOUT_H[15:8]

0x40
ACCEL_ZOUT_L
R
ACCEL_ZOUT_L[7:0]


(MPU9250)Register map(Temperature)

Address
Name
Type

0x41
TEMP_OUT_H
R
TEMP_OUT_H[15:8]

0x42
TEMP_OUT_L
R
TEMP_OUT_L[7:0]


(MPU9250)Register map(Gyroscope)

Address
Name
Type

0x43
GYRO_XOUT_H
R
GYRO_XOUT_H[15:8]

0x44
GYRO_XOUT_L
R
GYRO_XOUT_L[7:0]

0x45
GYRO_YOUT_H
R
GYRO_YOUT_H[15:8]

0x46
GYRO_YOUT_L
R
GYRO_YOUT_L[7:0]

0x47
GYRO_ZOUT_H
R
GYRO_ZOUT_H[15:8]

0x48
GYRO_ZOUT_L
R
GYRO_ZOUT_L[7:0]


(MPU9250)Register map(Etc)

Address
Name
Type

0x75
WHO_AM_I
R
WHOAMI[7:0]

0x6B
PWR_MGMT_1
R
Power Management


(AK8963)Register map

Address
Name
Type

0x00
WIA
R
Device ID

0x01
INFO
R
Information

0x02
ST1
R
Status 1

0x03
HXL
R
Measurement X-axis data

0x04
HXH
R
Measurement X-axis data

0x05
HYL
R
Measurement Y-axis data

0x06
HYH
R
Measurement Y-axis data

0x07
HZL
R
Measurement Z-axis data

0x08
HZH
R
Measurement Z-axis data

0x90
ST2
R
Status 2

0x0A
CNTL
RW
Control

0x0C
ASTC
RW
Self-test

0x10
ASAX
R
X-axis sensitivity adjustment value

0x11
ASAY
R
Y-axis sensitivity adjustment value

0x12
ASAZ
R
Z-axis sensitivity adjustment value


(MPU9250)Who_am_i

WHO_AM_I
0x75


(AK8963)Who_am_i

Device ID
0x00


(MPU9250)PowerOn

PowerManegment1
0x6B

Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0

H_RESET
SLEEP
CYCLE
GYRO_STANDBY
PD_PTAT
CLKSEL2
CLKSEL1
CLKSEL0


(MPU9250)H_RESET

Bit
意味

0

1
RESET


(MPU9250)SLEEP

Bit
意味

0

1
Sleep modeへ


(MPU9250)CYCLE

Bit
意味

0

1
LP_ACCEL_ODR registerで定義された周期でSleepとデータ取得を繰り返す


(MPU9250)GYRO_STANDBY

Bit
意味

0

1
CyroとPLL回路が有効


(MPU9250)PD_PTAT

Bit
意味

0

1
Power down


(MPU9250)CLKSEL

Bit
意味

000
Internal 20MHz oscillator

001
Auto selects the best available clock source

010
Auto selects the best available clock source

011
Auto selects the best available clock source

100
Auto selects the best available clock source

101
Auto selects the best available clock source

110
Internal 20MHz oscillator

111
Stops the clock and keeps timing generator in reset

PowerManegment2
0x6C


arduino

#define MPU9250_POWER_MNG1_REG 0x6B

#define MPU9250_POWER_MNG1_REG 0x6C

void powerOn()
{
// 実行しなくてもDefaultでOnになっている
writeI2c(MPU9250_POWER_MNG1_REG, 0x00);
writeI2c(MPU9250_POWER_MNG2_REG, 0x00);
}


(MPU9250)Configuration

CONFIGURATION
0x1A

Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0

RESV
FIFO_MODE
EXT_SYNC_SET2
EXT_SYNC_SET1
EXT_SYNC_SET0
DLPF_CFG2
DLPF_CFG1
DLPF_CFG0


(MPU9250)EXT_SYNC_SET

Bit
意味

000
function disabled

001
TEMP_OUT_L[0]

010
GYRO_XOUT_L[0]

011
GYRO_YOUT_L[0]

100
GYRO_ZOUT_L[0]

101
ACCEL_XOUT_L[0]

110
ACCEL_YOUT_L[0]

111
ACCEL_ZOUT_L[0]


(MPU9250)DLPF_CFG

FCHOICE1
FCHOICE2
DLPF_CFG
Gyroscope
Bandwidth(Hz)
Gyroscope
Delay(ms)
Gyroscope
Fs(kHz)
Temperature
Bandwidth(Hz)
Temperature
Delay(ms)

x
0
x
8800
0.064
32
4000
0.04

0
1
x
3600
0.11
32
4000
0.04

1
1
0
250
0.97
8
4000
0.04

1
1
1
184
2.9
1
188
1.9

1
1
2
92
3.9
1
98
2.8

1
1
3
41
5.9
1
42
4.8

1
1
4
20
9.9
1
20
8.3

1
1
5
10
17.85
1
10
13.4

1
1
6
5
33.48
1
5
18.6

1
1
7
3600
0.17
8
4000
0.04


(MPU9250)Gyroscope Configuration

GYRO_CONFIG
0x1B

Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0

XGYRO_Cten
YGYRO_Cten
ZGYRO_Cten
GYRO_FS_SEL1
GYRO_FS_SEL0
-
Fchoice_b1
Fchoice_b2


(MPU9250)GYRO_FS_SEL

Bit
意味

00
+250dps

01
+500 dps

10
+1000 dps

11
+2000 dps


(MPU9250)Accelerometer Configuration

ACCL_CONFIG
0x1C

Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0

ax_st_en
ay_st_en
az_st_en
ACCEL_FS_SEL1
ACCEL_FS_SEL0
RESV
RESV
RESV


(MPU9250)ACCEL_FS_SEL

Bit
意味

00
±2g

01
±4g

10
±8g

11
±16g

ACCL_CONFIG2
0x1D

Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0

RESV
RESV
RESV
RESV
accel_fchoice_b
A_DLPFCFG2
A_DLPFCFG1
A_DLPFCFG0

ACCEL_FCHOICE
A_DLPF_CFG
Output
Bandwidth
(Hz)
Output
Delay
(ms)
Output
Noise

Density
(ug/rtHz)
Rate
(kHz)

0
X
1.13K
0.75
250
4

1
0
460
1.94
250
1

1
1
184
5.80
250
1

1
2
92
7.80
250
1

1
3
41
11.80
250
1

1
4
20
19.80
250
1

1
5
10
35.70
250
1

1
6
5
66.96
250
1

1
7
460
1.94
250
1


(AK8963)Control

CTRL1
0x0A

Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0

0
0
0
BIT
MODE3
MODE2
MODE1
MODE0


(AK8963)MODE

Bit
意味

0000
Power-down mode

0001
Single measurement mode

0010
Continuous measurement mode 1

0110
Continuous measurement mode 2

0100
External trigger measurement mode

1000
Self-test mode

1111
Fuse ROM access mode


(AK8963)BIT

Bit
意味

0
14-bit output

1
16-bit output


(MPU9250)Read Accelerometer

Address
Name
Type

0x3B
ACCEL_XOUT_H
R
ACCEL_XOUT_H[15:8]

0x3C
ACCEL_XOUT_L
R
ACCEL_XOUT_L[7:0]

0x3D
ACCEL_YOUT_H
R
ACCEL_YOUT_H[15:8]

0x3E
ACCEL_YOUT_L
R
ACCEL_YOUT_L[7:0]

0x3F
ACCEL_ZOUT_H
R
ACCEL_ZOUT_H[15:8]

0x40
ACCEL_ZOUT_L
R
ACCEL_ZOUT_L[7:0]


(MPU9250)Read Temperature

Address
Name
Type

0x41
TEMP_OUT_H
R
TEMP_OUT_H[15:8]

0x42
TEMP_OUT_L
R
TEMP_OUT_L[7:0]


(MPU9250)Read Gyroscope

Address
Name
Type

0x43
GYRO_XOUT_H
R
GYRO_XOUT_H[15:8]

0x44
GYRO_XOUT_L
R
GYRO_XOUT_L[7:0]

0x45
GYRO_YOUT_H
R
GYRO_YOUT_H[15:8]

0x46
GYRO_YOUT_L
R
GYRO_YOUT_L[7:0]

0x47
GYRO_ZOUT_H
R
GYRO_ZOUT_H[15:8]

0x48
GYRO_ZOUT_L
R
GYRO_ZOUT_L[7:0]


(AK8963)