ICM-20948 Motion Sensor Library for Teensy (the newer+better MPU-9250)

Zane470

Member
I've written an Arduino library for the ICM-20948 motion sensor which uses the internal DMP (digital motion processor). I've tested it using a Teensy 4.1 and it seems to work well.

Library can be found here:
https://github.com/ZaneL/Teensy-ICM-20948

Nodejs app which takes the quaternion output and rotates a 3D object in real time:
https://github.com/ZaneL/quaternion_sensor_3d_nodejs

Video demo: https://streamable.com/ivmgfz

1.png2.png
 
@Zane470 - very nice indeed. I have been using the Sparkfun library for the ICM-20948. Yours seems a bit more interesting :)
 
Hello, is there a calibration routine to be performed?

I tried to work on a project for an underground orientation instrument, but stumbled upon unreliable devices (mag + gyro + compass), even after extensive calibrations.
I would happily try again with your promising library, but I can't find how calibration works here..?
 
Hello, is there a calibration routine to be performed?

I tried to work on a project for an underground orientation instrument, but stumbled upon unreliable devices (mag + gyro + compass), even after extensive calibrations.
I would happily try again with your promising library, but I can't find how calibration works here..?

The datasheet claims that when using the DMP it does some sort of a continuous automatic calibration. After this weekend I'll look through the datasheet and code a bit more to see if that is actually running properly. I'll also look into adding a manual calibration routine.
 
I know this library has been made a while ago, but I would like to see the I2C portion of the code completed. What would it take to make this library work with I2C. From what I see, a new version of "idd_io_hal_read_reg" and "idd_io_hal_write_reg" would be needed. Is there anything else in the code that would need to change(apart from modifications to the object itself to accept I2C arguments)?
 
Great library, thanks a lot. It only works at 24MHz on my Teensy 4.0. I am using an evaluation board from InvenSense - EV_ICM-20948. When I switch to any other frequency above 24Mhz, it doesn't even return the WHOAMI value. Is there a way to fix it somehow?

ICM20948 WHOAMI value=0
Bad WHOAMI value=0
Load DMP3 image
ICM20948 ERROR!
 
Great library, thanks a lot. It only works at 24MHz on my Teensy 4.0. I am using an evaluation board from InvenSense - EV_ICM-20948. When I switch to any other frequency above 24Mhz, it doesn't even return the WHOAMI value. Is there a way to fix it somehow?

ICM20948 WHOAMI value=0
Bad WHOAMI value=0
Load DMP3 image
ICM20948 ERROR!

Managed to fix it with a few delay calls in the initialization code and using digitalWriteFast calls.
 
This seems to be the only library (from the vid) that works correctly with the IMC20948's DPM, and is what I am looking for.
Aany idea if there has been any work done on 1) having an I2C output and 2) how to calibrate the sensor.
I have managed to use the ICM20948 DPM library from Sparkfun to output quaternions, but the data is erratic, takes a lot to stabilise and not consistent.
thanks
 
The datasheet claims that when using the DMP it does some sort of a continuous automatic calibration. After this weekend I'll look through the datasheet and code a bit more to see if that is actually running properly. I'll also look into adding a manual calibration routine.

Thanks for the library. I can get the quaternion rotation vector by following the example. I would like to know is there any update findings in the calibration routine? Do the continuous automatic calibration works well or a manual calibration routine is needed?

Thank you very much.
 
In the end, I managed to make it work, seemingly without the need of calibrating. The only difference between Zane's and the Sparkfun library I was using (apart from there being no I2C support in the former's lobrary), is the DMP sensor being used. I was using the "INV_ICM20948_SENSOR_ORIENTATION" sensor, which should output 320bit 9-axis quaternion + heading accuracy, whereas Zane used the "INV_ICM20948_SENSOR_GAME_ROTATION_VECTOR" which outputs a 6-axis quaternion.
I do not know the difference between the 2 senso outputs, but the former always gave me erratic outputs and took ages to stabilise while the latter outputs data which you do not need to calibrate and seems to work fine (I am using Sparkfun's libraries cause Im working with I2C). Now it is working fine for me, but again, I do not understand the differences between the 2 sensors and their output.
 
The INV_SENSOR_TYPE_GAME_ROTATION_VECTOR sensor seems work fine for me (without calibration). Also tried the INV_SENSOR_TYPE_GEOMAG_ROTATION_VECTOR sensor, seems it is not stable and don't know how to use it.

I'm trying to set different values for quaternion_frequency, gyroscope_frequency, accelerometer_frequency, magnetometer_frequency to see how much bandwidth is need. From the example, I see "Max frequency = 225, min frequency = 1" for gyroscope_frequency. So do the actual output frequency will match what I have set such as setting .gyroscope_frequency = 95 and the actual output will be something around 95Hz?
 
Back
Top