cancel
Showing results for 
Search instead for 
Did you mean: 

Correct startup for LSM6DSOX fifo /w compression.

DFors.1
Associate II

When we detect movement, we enable switch the LSM6DSOX into a fifo /w compression mode. We noticed we sometimes get a few "junk" entries of Gyro data in the beginning. Once we the a few entries into the system, the data looks good.

What is the correct sequence to setup the registers to avoid any glitches in the compressed fifo data stream?

For the data below, the device is on a turn table running at a relatively constant rate. The turn table is up to speed before the LSM6DSOX is enabled.

 --- 2nd entry junk
W (11:05:42.883) IMU: 0A: 0x56 0xF3 0xFF 0x12 0x00 0x0D 0x00
W (11:05:42.885) IMU: 0A: 0x56 0x03 0x00 0x0C 0x00 0x08 0x00
W (11:05:42.890) IMU: 0A: 0x56 0xFA 0xFF 0x12 0x00 0x09 0x00
W (11:05:42.895) IMU: 0A: 0x56 0xFE 0xFF 0x0E 0x00 0x0B 0x00
 
--- 1st and 3rd entry junk
W (11:05:48.792) IMU: 0A: 0x53 0x00 0x00 0x4E 0x00 0xB7 0x00
W (11:05:48.793) IMU: 0A: 0x56 0xF8 0xFF 0x0F 0x00 0x1B 0x00
W (11:05:48.799) IMU: 0A: 0x56 0x00 0x00 0x10 0x00 0x0D 0x00
W (11:05:48.804) IMU: 0A: 0x56 0xFF 0xFF 0x12 0x00 0x09 0x00
 
--- 1st and 2nd entry junk
W (11:05:54.749) IMU: 0A: 0x53 0x00 0x00 0x4E 0x00 0xB7 0x00
W (11:05:54.750) IMU: 0A: 0x56 0x00 0x00 0x11 0x00 0x1C 0x00
W (11:05:54.756) IMU: 0A: 0x56 0xFF 0xFF 0x08 0x00 0x06 0x00
W (11:05:54.761) IMU: 0A: 0x56 0xFF 0xFF 0x0C 0x00 0x0E 0x00
 
--- good wakeup 
W (11:08:17.908) IMU: 0A: 0x53 0x23 0xFE 0x8E 0xFD 0xF8 0xFA
W (11:08:17.909) IMU: 0A: 0x56 0xC6 0xFE 0x54 0xFD 0x11 0xFC
W (11:08:17.910) IMU: 0A: 0x53 0x99 0xFD 0x03 0xFC 0xAC 0xFA
W (11:08:17.922) IMU: 0A: 0x56 0xDD 0xFE 0xFD 0xFE 0xB9 0xF9
 
--- good wakeup 
W (11:08:17.908) IMU: 0A: 0x53 0x23 0xFE 0x8E 0xFD 0xF8 0xFA
W (11:08:17.909) IMU: 0A: 0x56 0xC6 0xFE 0x54 0xFD 0x11 0xFC
W (11:08:17.910) IMU: 0A: 0x53 0x99 0xFD 0x03 0xFC 0xAC 0xFA
W (11:08:17.922) IMU: 0A: 0x56 0xDD 0xFE 0xFD 0xFE 0xB9 0xF9
ctrl1_xl = ((4 - accelRate) << 4);
    ctrl2_g = ((4 - gyroRate) << 4);
    fifo_ctrl3 = ((4 - gyroRate) << 4) | (4 - accelRate);
 
    imuMode = IMU_STATE_FIFO;
    writeIMURegister(spiImu, FUNC_CFG_ACCESS, 0x00); // Switch to standard regs
    writeIMURegister(spiImu, CTRL3_C,         0x01); // software reset
    writeIMURegister(spiImu, CTRL9_XL,        0xE2); // disable I3C
    writeIMURegister(spiImu, CTRL3_C,         0x44); // Block Data Update set
    writeIMURegister(spiImu, CTRL1_XL,        ctrl1_xl|0x0C); // Accelerometer sample rate, 8g
    writeIMURegister(spiImu, CTRL2_G,         ctrl2_g|0x04); // Gyroscope sample rate, 500 dps
    writeIMURegister(spiImu, CTRL6_C,         0x10); // Acceleromter perf mode off
    writeIMURegister(spiImu, CTRL7_G,         0x80); // Gyroscope perf more off
    writeIMURegister(spiImu, FIFO_CTRL1,      (FIFO_WATERMARK & 0xff)); //fifo watermark
    writeIMURegister(spiImu, FIFO_CTRL2,      0x46 | ((FIFO_WATERMARK & 0x100) >>8)); //compression on, 32 batch rate, bit 9 of fifo watermark
    writeIMURegister(spiImu, FIFO_CTRL3,      fifo_ctrl3); // Gyroscope sample rate, Accelerometer sample rate
    writeIMURegister(spiImu, FIFO_CTRL4,      0x06); //Continuous mode
 
    writeIMURegister(spiImu, FUNC_CFG_ACCESS, 0x80); //Switch to embedded regs
    writeIMURegister(spiImu, EMB_FUNC_EN_B,   0x08); //compression on
    writeIMURegister(spiImu, EMB_FUNC_INIT_B, 0b0001000); // reset the FIFO compression algorithm
    writeIMURegister(spiImu, FUNC_CFG_ACCESS, 0x00); //Switch to standard regs
 
    writeIMURegister(spiImu, INT1_CTRL,       0x38); //INT1 on FIFO threshold

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @DFors.1​ ,

Please have a look to the C example lsm6dsox_fifo_compressed.c on Github and compare your code with it.

You might try with lowering the ODR of the axl and the gyro, and check if you are still getting wrong samples, or adding an initial delay after the device wakeup.

-Eleon