2017-09-04 02:29 AM
Hello,
I'm currently working with an LSM9DS1 and want to read the gyroscope/accelerometer data via FIFO.
I enabled the FIFO in CTRL_REG9 and set FIFO mode in FIFO_CTRL. Everything else regarding the FIFO is set on default. I read the data by accessing the X/Y/Z output registers.
(This might be unrelated but at the moment I'm initializing the registers in order of the data sheet. Therefore I set the gyro before the accelerometer registers. I initialize the gyroscope with an ODR of 59.5 Hz and later the accelerometer with 50 Hz which doesn't seem logical. But I want do set the g scale of the accelerometer in CTRL_REG6_XL and by that automatically set the ODR.)
The problem now is that the read data is not written in the FIFO storage. (When I check the FIFO_SRC register the number of samples in the storage stays 0)
Two interesting things happen:
- if I keep all the settings as they are and only change CTRL_REG9 to bypass-mode I receive the data
- when in fifo-mode some data (about 10 inaccurate numbers) is received in random intervals
Do you have an idea how to solve that problem?
If you need any more information please let me know and thanks in advance
Sabrina
#lsm9ds1 #fifo2017-09-04 03:04 AM
Can you please provide your complete sensor configuration (register values)?
2017-09-04 07:06 AM
Here is the complete sensor configuration.
// CTRL_REG1_G
// Gyro output data rate (59.5 Hz): 010----- // Gyro full-scale selection (500 dps): CAUTION ---01--- if you change this value, change GYRO_SCALE accordingly // Gyro bandwidth selection (default): ------00 i2c_data_buff[0] = 0b01001000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x10, &i2c_data_buff[0], 1);// CTRL_REG2_G
// Int selection config (default): ----00-- // Out selection config (default): ------00 i2c_data_buff[0] = 0b00000000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x11, &i2c_data_buff[0], 1);// CTRL_REG3_G
// Low Power mode (disabled): 0------- // High-Pass filter (disabled): -0------ // Gyro high-pass filter cutoff (0,1): ----0101 i2c_data_buff[0] = 0b00000101; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x12, &i2c_data_buff[0], 1);// ORIENT_CFG_G
// Pitch (X) axis angular rate sign --0----- // Roll (Y) angular rate sign ---0---- // Yaw (Z) axis angular rate sign ----0--- // Directional user orientation -----000 i2c_data_buff[0] = 0b00000000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x13, &i2c_data_buff[0], 1);// CTRL_REG4
// Enable Gyro output yaw (Z) --1----- // Enable Gyro output roll (Y) ---1---- // Enable Gyro output pitch (X) ----1--- // Latched Interrupt (default) ------0- // 4D pos recognition (default) -------0 i2c_data_buff[0] = 0b00111000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x1E, &i2c_data_buff[0], 1);// CTRL_REG5_XL
// Enable accel xyz --111--- i2c_data_buff[0] = 0b00111000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x1F, &i2c_data_buff[0], 1);// CTRL_REG6_XL
// ODR 50Hz: 010----- // +-2g scale: CAUTION ---00--- : if you change this, you also have to change ACC_SCALE accordingly // No anti-aliasing filter: -------0 i2c_data_buff[0] = 0b01000000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x20, &i2c_data_buff[0], 1);// CTRL_REG7_XL
// No high resolution: 0------- // Bypass filter: -00--0-0 i2c_data_buff[0] = 0b00000000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x21, &i2c_data_buff[0], 1);// CTRL_REG8
// Reboot no: 0------- // Block update: -1------ // Interrupt activation level: --0----- // Push-pull mode: ---0---- // SPI: ----0--- // Address increment active: -----1-- // Big endian: ------0- // Software reset: -------0 i2c_data_buff[0] = 0b01000100; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x22, &i2c_data_buff[0], 1);// CTRL_REG9
// DRDY_mask_bit enable ----1--- // Fifo memory enable ------1- i2c_data_buff[0] = 0b00001010; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x23, &i2c_data_buff[0], 1);// FIFO_CTRL
// FIFO enable: 001----- i2c_data_buff[0] = 0b00100000; i2c_send(LSM9D_ACCEL_GYRO_ADDR, 0x2E, &i2c_data_buff[0], 1)2017-09-04 08:08 AM
You configuration seems to be correct, I tried it and it works as expected.
Don't you read the data continuously? If you are reading the data at high speed you are able to read all of them and they won't be stored in FIFO.
This would explain why you are reading 0 samples from FIFO_SRC register.
2017-09-04 10:53 PM
Hi Sabrina,
I was having similar trouble and found that the following post helped in deciphering how to setup and read using the FIFO buffer.
https://github.com/kriswiner/LSM9DS1/issues/5
Regards,
Shane
2017-09-11 09:29 AM
Hi Miroslav and Shane,
I wanted to read in FIFO mode to not loose data for the gyroscope as the results would not be as correct.
After following the link (I didn't realize he also configured a LSM9DS1) I added some loops which helped a lot.
Due to many changes I didn't notice that I call the accelerometer before the gyroscope in the main function which caused a lot of trouble.
Thank you for your help!
Regards,Sabrina