Project

General

Profile

Actions

Bug #455

open
SB

IMU configuration for Tawaki board

Bug #455: IMU configuration for Tawaki board

Added by Szymon Bielenin 5 months ago. Updated 5 months ago.

Status:
New
Priority:
Normal
Assignee:
-

Description

Modification of the ICM42688P configuration

I configured the Tawaki IMU (ICM42688P) as Betaflight suggested:
  1. I set up the Anti-Aliasing filter (Cutoff ≈ 258 Hz) for Gyro and Acc
  2. I increased the ODR to 8kHz, which moves the UI FILTERS BW to 2096 Hz and delay to 0.2 ms
  3. I moved the configuration of the ICM42688_GYRO_ACCEL_CONFIG0 register while the ACC and Gyro are turn off (as datasheet suggests at 12.9)

The results speaks by themselves: the general noise is reduced 10 times, and the quad is flying much smoother. Since this filtering is done with high frequency (32kHz) and before sampling by FC, the improvement is almost for free (in practice, we can ignore the phase shift for interesting BW).

Comparison of the raw data and after LPF of the rotorcraft for an accelerometer and gyro.

Old configuration:
gyroscope noise level for hovering with minimal configuration of the IMU
accelerometer noise level for hovering with minimal configuration of the IMU

New configuration:
gyroscope noise level for hovering with a new configuration of the IMU
accelerometer noise level for hovering with a new configuration of the IMU

Issues

For this particular IMU sensor (ICM42688) there is reported issue (gyro stall for a few miliseconds). Proposed solution, from Betaflight/Ardupilot, is disabling the AFSR (adaptive full scale range option) which is undocumented (at least in the official datasheet) option on this chip. However when I implemented this fix the Accelerometer readings got corrupted (instead of 9.8 m/s^2 I read around 4 m/s^2 as gravity). I couldn't fix it with FSR change so for now it is commented out. Also I did not check if such problem really occures but if Betaflight reported this issue with many boards with the same IMU, in my opinion the fix is worth implementing if possible.
The code with Betaflight fix:


// Disable AFSR (gyro stall fix) - in datasheet not described, and bits 6,7 are reserved, but Betaflight sets them to 0x40 (AFSR disabled) in their ICM42688 driver, so do the same just in case
  uint8_t * const intf1 = tk3_padmem(uint8_t, TK3_ICM42688_MEM);
  if (tk3sens_read(TK3_ICM42688,1,ICM42688_INTF_CONFIG1, intf1))
    goto fail;
  uint8_t intf1_val = *intf1;

  intf1_val &= ~0xC0;
  intf1_val |=  0x40; 
  if (tk3sens_write(TK3_ICM42688, 1, ICM42688_INTF_CONFIG1, intf1_val)) 
    goto fail;

Files

IMU_config_comparison_OC_A.png (103 KB) IMU_config_comparison_OC_A.png accelerometer noise level for hovering with minimal configuration of the IMU Szymon Bielenin, 2026-02-11 13:40
IMU_config_comparison_OC_G.png (112 KB) IMU_config_comparison_OC_G.png gyroscope noise level for hovering with minimal configuration of the IMU Szymon Bielenin, 2026-02-11 13:40
IMU_config_comparison_NC_G.png (113 KB) IMU_config_comparison_NC_G.png gyroscope noise level for hovering with a new configuration of the IMU Szymon Bielenin, 2026-02-11 13:40
IMU_config_comparison_NC_A.png (121 KB) IMU_config_comparison_NC_A.png accelerometer noise level for hovering with a new configuration of the IMU Szymon Bielenin, 2026-02-11 13:40

AM Updated by Anthony Mallet 5 months ago Actions #1

Thanks for this work!

Could you mention the rotocraft LP filter cutoff freq in the plots?

On Wednesday 11 Feb 2026, at 14:28, Szymon Bielenin wrote:

1 I set up the Anti-Aliasing filter (Cutoff ≈ 258 Hz) for Gyro and Acc
2 I increased the ODR to 8kHz, which moves the UI FILTERS BW to 2096
Hz and delay to 0.2 ms
3 I moved the configuration of the ICM42688_GYRO_ACCEL_CONFIG0
register while the ACC and Gyro are turn off (as datasheet suggests at 12.9)

If you could attach a diff of the code that would be helpful.

SB Updated by Szymon Bielenin 5 months ago · Edited Actions #3

Anthony Mallet wrote in #note-1:

Thanks for this work!

Could you mention the rotocraft LP filter cutoff freq in the plots?
100 Hz for gyro and 5Hz for Accel

On Wednesday 11 Feb 2026, at 14:28, Szymon Bielenin wrote:

1 I set up the Anti-Aliasing filter (Cutoff ≈ 258 Hz) for Gyro and Acc
2 I increased the ODR to 8kHz, which moves the UI FILTERS BW to 2096
Hz and delay to 0.2 ms
3 I moved the configuration of the ICM42688_GYRO_ACCEL_CONFIG0
register while the ACC and Gyro are turn off (as datasheet suggests at 12.9)

If you could attach a diff of the code that would be helpful.

Actions

Also available in: PDF Atom