Corrupted gyroscope data at 3pi+ (LSM6DS33)

Hi, i am working with the gyroscope of the 3pi+ robot. Using the following code to read the raw gyroscope date for the z axis, I regularly get some wrong values. (The robot is stationary placed with out moving it.)

#include <Wire.h>
#include <Pololu3piPlus32U4.h>
#include <Pololu3piPlus32U4IMU.h>

using namespace Pololu3piPlus32U4;
IMU imu;

void setup() {
  Serial.begin(9600);

  Wire.begin();
  imu.init();
  imu.configureForTurnSensing();  
}

void loop() {
  while (!imu.gyroDataReady()) {}  
  imu.readGyro();
  Serial.println(imu.g.z);
}

Any idea what happens?

Thanks, Stefan

Hi, Stefan.

I’m looking into whether this might be an issue with how we configure the IMU. Could you try adding the line:

  imu.writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL3_C, 0x44);

immediately after imu.configureForTurnSensing(); and let me know if it makes your results better?

Kevin

Much better. Thanx

1 Like

I’m glad that solved your issue, and we’ll change the library to include that setting.

By the way, I would also recommend calling imu.enableDefault(); before imu.configureForTurnSensing(); just to make sure everything else is set to reasonable defaults, but we’re looking into making the configureFor... functions call enableDefault automatically to make that unneeded in the future.

Kevin