Unable to read IMU data from ICM20608-G

by tarabyte   Last Updated October 16, 2018 02:25 AM

I'm poking around with IMUs, and the configuration and initialization associated with this guy seems particularly finicky. I'm just trying to read a raw accelerometer sample, but there seems to be some initialization piece I'm missing.

// Wait sufficiently long after applying power BEFORE you
// attempt to interact with the sensor

// Initialize
r = icm_init();
printf("r = %d\n", r);

// Probe the sensor
r = icm_check_whoami();
printf("r = %d\n", r);

// Turn on all the sensors
r = icm_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL);
printf("r = %d\n", r);

// Confirm the sensors are turned on
uint8_t is_powered;
r = icm_get_power_state(&is_powered);
printf("r = %d, is_powered = %d\n", r, is_powered);

while (1) {

  // Attempt to read a raw sample
  short accel[3];
  r = icm_get_accel_reg(&accel, NULL);
 printf("r = %d, accel = (%d, %d, %d)\n", r, accel[0], accel[1], accel[2]);

  short gyro[3];
  r = icm_get_gyro_reg(&gyro, NULL);
 printf("r = %d, gyro = (%d, %d, %d)\n", r, gyro[0], gyro[1], gyro[2]);
  • I have no bad return codes
  • I've confirmed I an read back the correct value from the WHOAMI register
  • I enable all the sensors
  • I confirm the sensors are powered
  • I give the sensors plenty of time to acquire a sample
  • The sensors always give me back 0.

The API comes from the inv_icm20608.c file from the Embedded MotionDriver 608-G download, at path STM32F4_MD20608/Projects/eMD20608/core/driver/eMPL

https://www.invensense.com/developers/software-downloads/ https://www.invensense.com/products/motion-tracking/6-axis/icm-20608-2/

Tags : i2c imu

Related Questions