ICM 20948 wake on motion with DMP

Hello,

I recently got a sparkfun ICM20948 board and was wondering if WOM is possible with the DMP enabled? I have tried combining the two example sketches to no success.

Hi Inuka (@InukaSilva ),

The 20948 supports a Wake-On-Motion (WOM) Interrupt - without needing the DMP. That should work OK if you configure it correctly.

The DMP has a different Significant Motion Detect (SMD) and Pick Up Gesture / Event. Unfortunately, this is only partially implemented in the SparkFun Library. I left myself a note about it here, but never had the time to revisit that part of the library…

Sorry about that,
Paul

my goal is to get a sleep mode going on the artemis redboard (not nessessarily for the IMU) and if motion is detected to become active. I want to be measuring eurler angle however which is why I need the DMP enabled. I did some more testing and have a sketch that looks like it works. Is there any other ways that would be better for doing a task like this?

Hi Inuka,

How low do you want your sleep current draw to be? For the lowest current draw, it might be better to add another, separate, simple accelerometer to generate the wake-on-motion interrupt. Then start the 20948 and restore the biases once the Artemis is awake?

I hope this helps,
Paul

Hello,

I would prefer to avoid that as I have a couple of other boards that I will be adding onto the setup. I was messing around with some test sketches, and I had a couple that were working even with DMP and WOM but I think that was very limited in terms of what I could do. the main concern is putting the redboard to sleep and setting an interrupt for waking up. is there another way where the DMP could be enabled and I could trigger an interrupt for the redboard to wake up, ideally all with those two boards?

I have an idea, not a huge concern with power consumption but would this work? my logic set ups is as follows:

if (interrupt has been trigged):
while (should be awake):
record data;

when it should fall back to sleep, could I disable dmp and then set up wake on motion? and vice versa when it gets triggered?

The DMP does support interrupts. I’m seeing references to DATA_INTR_CTL and DMP_Motion_Event_Control_Tilt_Interrupt in the source code. But I can’t recall ever testing it. Maybe it will meet your needs? But please remember that Significant Motion Detect (SMD) and Pick Up Gesture / Event are only partially implemented.

The library is structured such that DMP is either enabled - or not - when the code is compiled. I didn’t foresee users wanting to run with the DMP, then restart and run without. It’s possible, but you would need to hack the library quite a lot to achieve it. The main parts would be skipping the DMP binary blob download and making sure that the magnetometer is configured correctly. (The magnetometer configuration is very different with and without the DMP.)

You might have more luck using one of the Arduino wrappers for the original InvenSense eMD (embedded Motion Driver)?

I’m still a bit new to working with these boards so sorry for the questions in advance. Is the interrupt trigged from motion? I am thinking I could put the redboard into sleep mode and just turn the rates down for the DMP so then it uses less power. I am not using the magnetometer and probably only going to use the Quat 6, gyro, and accel data. I am not familiar with what you mean by Arduino Wrapper, if you could give me some more information about that. I’ve mainly been refernces the example sketches to figure out the library, but is there any other resources that you would recommend?

Hi Inuka (@InukaSilva ),

InvenSense do provide source code to communicate with the 20948 - the eMD (embedded Motion Driver). It is available in their Developer resources. But the code is opaque and very difficult to follow. Also, it is pure C and, as a minimum, needs a wrapper to support Arduino I2C and SPI interfaces. Users like ZaneL and ericalbers have done that.

Initially, the SparkFun library didn’t support the DMP. I started adding DMP support back in 2021. It turned into quite a task… InvenSense do provide documentation for the DMP, but it is only available under NDA and they admit it isn’t complete. We had to reverse-engineer how their eMD code was configuring the 20948 - especially the power modes and the magnetometer interface - to figure out some of the steps. It took weeks of effort to get the DMP support to where it is now, and it’s still not complete. Users still spot gremlins too; have a scroll through the Library Issues for more details.

Other users have taken our library have been able to make good use of it as is.

Your application is different. You can’t (currently) use the SparkFun Library with-DMP and without-DMP. It’s currently either-or; the library is compiled differently with-DMP compared to without. To be able to swap between the two, the library would need some rework. And I’m not sure if the with-DMP motion interrupt code will meet your needs. So, you may find the wrappers easier to work with?

I hope this helps,
Paul

Hello,

That information is really helpful, thank you so much. I took a quick glance at the two wrappers, I am not sure if they have the WOM integration, but I will continue see if anyone has already made a wrapper. I was messing around with the SparkFun library, and I got something that was working, but I was working on integrating the functionality of WOM DMP. I then tried to implement it further with the exact scenario and logic which it stopped working (it would record and stop but the WOM wouldn’t work a second time). I will continue to play around with the SparkFun library as well to see if it ends up working.

Thank you again for the help,

Inuka

After looking through the DMP library provided by ZaneL and seeing this comment:

None of the ICM-20948 Arduino libraries contained support for the DMP (Digital Motion Processor), so I sorted through the Invensense library (worst code ever written)

The DMP sensor calibration, which is by far the most important part of the sensor setup and determines the accuracy of the calculated orientation, seems opaque.

So, I began to wonder if anyone has independently tested the accuracy of the DMP output under various operating circumstances. A brief web search did not turn up any examples (terminated when I hit a spam page taking over my browser, and announcing that my computer had been infected with a virus, be warned).

If someone knows of independent, quantitative tests as to how well the DMP works in real life, or how its output compares to output from open source fusion code, I would be grateful for one or more examples.

Finally, in 2022, TDK changed the status of the ICM-20948 to Not Recommended for New Designs (NRND). At the time, they weren’t making the magnetometer chip, and claimed that manufacturer had discontinued the line. See this transition guide for new designs.

Given the NRND status and limited stock, I wonder if it is worth investing much energy in developing products that use the ICM-20948.

I was looking through the library and have found the method:

ICM_20948_Status_e ICM_20948::enableDMPSensorInt(enum inv_icm20948_sensor sensor, bool enable)
{
if (_device._dmp_firmware_available == true) // Should we attempt to enable the sensor interrupt?
{
status = inv_icm20948_enable_dmp_sensor_int(&_device, sensor, enable == true ? 1 : 0);
debugPrint(F(“ICM_20948::enableDMPSensorInt: _enabled_Android_intr_0: “));
debugPrintf((int)_device._enabled_Android_intr_0);
debugPrint(F(” _enabled_Android_intr_1: “));
debugPrintf((int)_device._enabled_Android_intr_1);
debugPrint(F(” _dataIntrCtl: “));
debugPrintf((int)_device._dataIntrCtl);
debugPrintln(F(””));
return status;
}
return ICM_20948_Stat_DMPNotSupported;
}

What this something I could try playing around with to get interrupts? would this be a similar set up as to the interrupt example that is part of the arduino library?

I left a cryptic note about this here

Best,
Paul