Hello all,
We are new to using this device and we’ve been having some difficulty in just reading outputs. My group and I are working on a project that uses an Arduino Uno board that uses the accelerometer and gyroscope to measure the movement of a segway-like device based off of the angle of the platform. We are trying to figure out how to just read the outputs of the LSM6DS33 in the Arduino program. We have been using Kevin Pololu’s code as a basis for ours and this is what we have so far:
include < Wire.h > //we know there's supposed to be #, but it doesn't show up on this forum
include < LSM6.h >
LSM6 imu;
char report[80];
void setup()
{
Serial.begin(9600);
Wire.begin();
if (!imu.init())
{
Serial.println("Failed to detect and initialize IMU!");
while (1);
}
imu.writeReg(LSM6::CTRL9_XL, 0x38); // Acc X, Y, Z axes enabled
imu.writeReg(LSM6::CTRL1_XL, 0x60); // Acc = 416Hz (High-Performance mode)
imu.writeReg(LSM6::INT1_CTRL, 0x01); // Acc Data Ready interrupt on INT1
imu.writeReg(LSM6::CTRL10_C, 0x38); // Gyro X, Y, Z axes enabled
imu.writeReg(LSM6::CTRL2_G, 0x60);// Gyro = 416Hz (High-Performance mode)
imu.writeReg(LSM6::INT2_CTRL, 0x02); // Gyro Data Ready interrupt on INT1
}
void loop()
{
imu.writeReg(LSM6::STATUS_REG, 0x0B); //this hex number represents the status register
imu.read();
snprintf(report, sizeof(report), "A: %6d %6d %6d G: %6d %6d %6d", imu.a.x, imu.a.y, imu.a.z, imu.g.x, imu.g.y, imu.g.z);
Serial.println(report);
delay(100);
}
We have been going off of this manual and basing our code around the Status Register on page 56:
We have been playing around with this code for a while, so if you see any extraneous or non sequitur code, please ignore. However, if there are any suggestions or comments about the read and write functions or any about how to fix the code to show some output data please let us know.
Thanks,
Alex