Collection of Arduino sketches for TDK's combo accel/gyro motion sensor
The basic sketch configures the sensors' data rates and full scale sensitivities as well as low-pass data filters. It performs the sensor self tests, calibrates the sensors, sets up the data ready interrupts. The main loop is interrupt-based and best absolute orientation estimation results are obtained running the gyro and accel at 200 Hz or more. Sensor fusion using the open-source Madgwick fusion algorithm is iterated every time new gyro data is available; magnetometer data is read upon interrupt at the 100 Hz maximum rate so that most of the fusion results use "stale" mag data. This shouldn't affect accuracy though, and with proper calibration this sensor combination is capable of delivering better than 1 degree rms heading accuracy. In fact, even with the somewhat crude calibration employed here, I have noticed the jitter for the 9 DoF sensors and Euler angles is very low.
The APEX sketch uses the ICM42688 accel embedded function (APEX) engine to demonstrate two of the embedded functions, tilt detection, which uses the DMP, and wake-on-motion, which does not. The sketch shows how to set up the wake-on-motion detect and DMP for tilt detection, route the APEX interrupts to INT2, and use the status registers to detect which APEX function is causing the interrupt. The APEX detection is run in parallel with the usual accel/gyro/barometer data output, but I have turned the magnetometer off here. These embedded functions are similar to those found in other accelerometers. They are not really the focus of my interest in this sensor but it is useful to be able to get them to work nonetheless. These and others APEX functions are explained in detail in TDK's AN-000173 "ICM-426xx APEX Motion Functions: Description and Usage" available on TDK's CM42688 product page.
Lastly, the ICM42688 allows the 50 ppm accurate embedded PLL to be replaced by a 30 - 50 kHz external clock signal. The STM32L4 is capable of outputting a 32.768 kHz square wave from the 1-ppm-accuracy RTC embedded clock. I am curious to see if any difference between using the internal ICM42688 PLL and a more accurate external CLKIN signal can be detected in gyro drift and/or heading accuracy. I will post the sketch I use and any results when obtained.
Overall, the ICM42688 is a worthy high-performance accel/gyro combo sensor that is a candidate to replace the LSM6DSM/T, its nearest competitor, in any absolute orientation estimation engine requiring the best accuracy.
The design for the breakout board I designed for testing the ICM42688 can be found in the OSH Park shared space here.
I am using the STM32L432KC (Ladybug) breakout board for testing the ICM42688. Ladybug available on Tindie.
Copyright 2022 Tlera Corporation. All rights reserved.