Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

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

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    17

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

    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

    Click image for larger version. 

Name:	1.png 
Views:	53 
Size:	10.9 KB 
ID:	20226Click image for larger version. 

Name:	2.png 
Views:	104 
Size:	245.7 KB 
ID:	20227

  2. #2
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    @Zane470 - very nice indeed. I have been using the Sparkfun library for the ICM-20948. Yours seems a bit more interesting

  3. #3
    Senior Member
    Join Date
    Oct 2015
    Location
    Roma (IT, EU)
    Posts
    360
    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..?

  4. #4
    Junior Member
    Join Date
    Dec 2018
    Posts
    17
    Quote Originally Posted by XFer View Post
    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.

  5. #5
    Junior Member
    Join Date
    Oct 2020
    Posts
    1
    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)?

  6. #6
    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!

  7. #7
    Quote Originally Posted by alexander.bsd View Post
    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.

  8. #8
    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

  9. #9
    Junior Member
    Join Date
    May 2021
    Posts
    2
    Quote Originally Posted by Zane470 View Post
    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.

  10. #10
    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.

  11. #11
    Junior Member
    Join Date
    May 2021
    Posts
    2
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •