Skip to content

Commit 2f43c43

Browse files
committed
Add support for the ICM20948
1 parent 0e882f3 commit 2f43c43

11 files changed

Lines changed: 582 additions & 23 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* MPU6500
1111
* MPU6050
1212
* ICM20689
13-
* ICM20690
13+
* ICM20690
14+
* ICM20948
1415
* BMI055
1516
* BMX055 (Magnetometer currently untested)
1617
* BMI160
@@ -24,6 +25,7 @@
2425
* AK8975
2526
* AK8963
2627
* AK09918
28+
* BMM150
2729

2830
### Using non default I2C ports:
2931
If you're planning on using an IMU on a non-default I2C port, you can specify the port in the constructor of your IMU, for example:
@@ -49,9 +51,7 @@ creates a hybrid `MPU6050` and `QMC5883L` IMU object that behaves as a single IM
4951
### Planned:
5052
* BNO080 (probably soonish)
5153
* GY-85
52-
* BMM150
5354
* BNO055 (the one I bought is DOA... might take a bit)
54-
* ICM20948
5555
* BMI270 (if I can get my hands on one)
5656
5757
### Data types
@@ -108,6 +108,7 @@ creates a hybrid `MPU6050` and `QMC5883L` IMU object that behaves as a single IM
108108
109109
![2](MountIndex.png)
110110
111+
##### TODO: VQF? built in filters?
111112
##### TODO: get DMP working for pure quaternion output from invsense IMU's
112113
##### TODO: get FIFO working for all IMU's that have it.
113114
##### TODO: get timestamping working

datasheets/AK09916-Datasheet.pdf

789 KB
Binary file not shown.

datasheets/ICM-20948-Datasheet.pdf

1.09 MB
Binary file not shown.

examples/Calibrated_HadesVR/Calibrated_HadesVR.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
MPU6050 IMU; //Change to the name of any supported IMU
1010
#define IMU_GEOMETRY 0 //Change to your current IMU geometry (check docs for a reference pic).
1111

12-
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
12+
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 ICM20948 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
1313

1414
calData calib = { 0 }; //Calibration data
1515
AccelData IMUAccel; //Sensor data

examples/Calibrated_quat/Calibrated_quat.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define PERFORM_CALIBRATION //Comment to disable startup calibration
77
ICM20689 IMU; //Change to the name of any supported IMU!
88

9-
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
9+
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 ICM20948 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
1010

1111
calData calib = { 0 }; //Calibration data
1212
AccelData IMUAccel; //Sensor data

examples/Calibrated_relativty/Calibrated_relativty.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MPU6050 IMU; //Change to the name of any supported IMU!
1515

1616
#define IMU_GEOMETRY 0 //Change to your current IMU geomtery (check docs for a reference pic).
1717

18-
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
18+
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 ICM20948 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
1919

2020
#define FILTER_MAX_BETA 0.15
2121
#define FILTER_MIN_BETA 0.015

examples/Calibrated_sensor_output/Calibrated_sensor_output.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define PERFORM_CALIBRATION //Comment to disable startup calibration
66
MPU6050 IMU; //Change to the name of any supported IMU!
77

8-
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
8+
// Currently supported IMUS: MPU9255 MPU9250 MPU6886 MPU6500 MPU6050 ICM20689 ICM20690 ICM20948 BMI055 BMX055 BMI160 LSM6DS3 LSM6DSL QMI8658
99

1010
calData calib = { 0 }; //Calibration data
1111
AccelData accelData; //Sensor data

examples/IMUIdentifier/IMUIdentifier.ino

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <Wire.h>
2+
#include <avr/pgmspace.h>
23
// Similar to https://github.com/Levi--G/IMU-WhoAmIVerifier
34

45
//Do be aware that MPU9150's will report as 6050s, this is because a 9150 is a 6050 with a magnetometer
@@ -16,12 +17,12 @@ typedef struct IMU {
1617
uint8_t Address2;
1718
uint8_t Register;
1819
uint8_t ExpectedID;
19-
const char* IMUName PROGMEM;
20-
const char* IMUCapabilities PROGMEM;
20+
const char* IMUName;
21+
const char* IMUCapabilities;
2122
bool LibSupported;
2223
};
2324

24-
const IMU IMUList[NUM_IMUS] =
25+
const IMU IMUList[NUM_IMUS] PROGMEM =
2526
{
2627
{0x68, 0x69, 0x75, 0x68, "MPU6050", "3A,3G", true},
2728
{0x68, 0x69, 0x75, 0x70, "MPU6500", "3A,3G", true},
@@ -36,6 +37,7 @@ const IMU IMUList[NUM_IMUS] =
3637
{0x6B, 0x6A, 0x0F, 0x6A, "LSM6DSL or LSM6DS3TR-C", "3A,3G", true},
3738
{0x68, 0x69, 0x75, 0x98, "ICM20689", "3A,3G", true},
3839
{0x68, 0x69, 0x75, 0x20, "ICM20690", "3A,3G", true},
40+
{0x68, 0x69, 0x00, 0xEA, "ICM20948", "3A,3G,3M", true},
3941
{0x6B, 0x6A, 0x00, 0x05, "QMI8658", "3A,3G", true},
4042
{0x18, 0x19, 0x00, 0xFA, "BMI055 or BMX055", "3A,3G or 3A,3G,3M", true},
4143
{0x1E, 0x1E, 0x0C, 0x33, "HMC5883L", "3M", true},
@@ -61,7 +63,6 @@ const IMU IMUList[NUM_IMUS] =
6163
{0x68, 0x69, 0x00, 0xE1, "ICM20649", "3A,3G", false},
6264
{0x68, 0x69, 0x75, 0xA9, "ICG20660", "3A,3G", false},
6365
{0x68, 0x69, 0x75, 0x91, "IAM20680", "3A,3G", false},
64-
{0x68, 0x69, 0x00, 0xEA, "ICM20948", "3A,3G,3M", false},
6566
{0x68, 0x69, 0x75, 0x6C, "IIM42351", "3A", false},
6667
{0x68, 0x69, 0x75, 0x6D, "IIM42352", "3A", false},
6768
{0x68, 0x69, 0x75, 0x4E, "ICM40627", "3A,3G", false},
@@ -72,6 +73,12 @@ const IMU IMUList[NUM_IMUS] =
7273
{0x68, 0x69, 0x00, 0x68, "MPU3050", "3G", false}
7374
};
7475

76+
static inline IMU getIMU(uint8_t i) {
77+
IMU tmp;
78+
memcpy_P(&tmp, &IMUList[i], sizeof(IMU));
79+
return tmp;
80+
}
81+
7582
void setup() {
7683
Serial.begin(9600);
7784
while (!Serial) ;
@@ -101,10 +108,11 @@ void loop() {
101108
bool detected = false;
102109
for (int i = 0; i < NUM_IMUS; i++)
103110
{
111+
IMU imu = getIMU(i);
104112
#ifdef WIRE_HAS_TIMEOUT
105113
if (errorflag || Wire.getWireTimeoutFlag()) {
106114
Serial.print(F("Error while reading address 0x"));
107-
Serial.print(IMUList[i].Address1, HEX);
115+
Serial.print(imu.Address1, HEX);
108116
Serial.print(F(": "));
109117
if (Wire.getWireTimeoutFlag()) {
110118
Serial.println(F("I2C bus timed out. (Bad IMU? check wiring.)"));
@@ -119,16 +127,16 @@ void loop() {
119127
return;
120128
}
121129
#endif
122-
if (readByte(IMUList[i].Address1, IMUList[i].Register) == IMUList[i].ExpectedID)
130+
if (readByte(imu.Address1, imu.Register) == imu.ExpectedID)
123131
{
124132
detected = true;
125133
Serial.print(F("IMU Found: "));
126-
Serial.print(IMUList[i].IMUName);
134+
Serial.print(imu.IMUName);
127135
Serial.print(F(" On address: 0x"));
128-
Serial.println(IMUList[i].Address1, HEX);
136+
Serial.println(imu.Address1, HEX);
129137
Serial.print(F("This IMU is capable of the following axis: "));
130-
Serial.println(IMUList[i].IMUCapabilities);
131-
if (IMUList[i].LibSupported) {
138+
Serial.println(imu.IMUCapabilities);
139+
if (imu.LibSupported) {
132140
Serial.println(F("This IMU is supported by the FastIMU library."));
133141
}
134142
else
@@ -137,21 +145,21 @@ void loop() {
137145
}
138146
Serial.println(F("======================================"));
139147
}
140-
else if (readByte(IMUList[i].Address2, IMUList[i].Register) == IMUList[i].ExpectedID)
148+
else if (readByte(imu.Address2, imu.Register) == imu.ExpectedID)
141149
{
142150
detected = true;
143151
Serial.print(F("IMU Found: "));
144-
Serial.print(IMUList[i].IMUName);
152+
Serial.print(imu.IMUName);
145153
Serial.print(F(" On address: 0x"));
146-
Serial.println(IMUList[i].Address2, HEX);
154+
Serial.println(imu.Address2, HEX);
147155
Serial.print(F("This IMU is capable of the following axis: "));
148-
Serial.println(IMUList[i].IMUCapabilities);
149-
if (IMUList[i].LibSupported) {
156+
Serial.println(imu.IMUCapabilities);
157+
if (imu.LibSupported) {
150158
Serial.println(F("This IMU is supported by the FastIMU library."));
151159
}
152160
else
153161
{
154-
Serial.println(F(" This IMU is not supported by the FastIMU library."));
162+
Serial.println(F("This IMU is not supported by the FastIMU library."));
155163
}
156164
Serial.println(F("======================================"));
157165
}

0 commit comments

Comments
 (0)