cancel
Showing results for 
Search instead for 
Did you mean: 

LSM9DS1 G threshold is 8 bit but X, Y & Z are 16 bit values

frackers
Senior

Trying to determine how I set an acceleration threshold when the threshold register is half the size of the acceleration vector registers.

The gyro makes sense as the threshold for it is the same size as the 3 vector registers but the G sensor just doesn't make any sense at all.

Also, can I only put values above a threshold into the FIFO or are all values entered into it (assuming its not in bypass mode)

6 REPLIES 6
Eleon BORLINI
ST Employee

​Hi @frackers​ , the accelerometer threshold (e.g. INT_GEN_THS_X_XL​ reg) basically applies to the MSB part of the accelerometer data.

The programmable FIFO threshold refers to the fact that you can write in FIFO a number of samples equal or less the threshold you set. One of the use of this threshold is to synchronize data acquisition of various parts of a system. Regards

frackers
Senior

My threshold question was posed while I was designing - now I'm implementing I can't get any acceleration data (or the XLDA bit set in the STATUS_REG) at all.

Is there some global enable I'm missing or does the gyro have to be enabled to get XL data?

This is my init code:

  // software reset
   // auto inc address
 
  xgWriteByte (CTRL_REG8, 0x05);
   HAL_Delay (10);
  
  who_am_i = xgReadByte (WHO_AM_I_XG);
 
   tempRegValue = 0xc0;     // 952Hz
   xgWriteByte(CTRL_REG1_G, tempRegValue);
  
  // angular rate - default 0
   xgWriteByte(CTRL_REG2_G, 0x00);
  
  // acceleration rate = 1 (10Hz)
   // scale 4g
   // sample rate -1 (determined by data rate)
   tempRegValue = (1<<5) | (1<<4) | (1<<3);    // enable X, Y, Z axis
   xgWriteByte(CTRL_REG4, tempRegValue);
  
  // ENABLE X, Y, Z AXIS
   tempRegValue = 0x38;  //(1<<5) | (1<<4) | (1<<3);
   xgWriteByte(CTRL_REG5_XL, tempRegValue);
  
  tempRegValue = (0x2 << 3);  // 4g
   tempRegValue |= (0x1 << 5);  // 10Hz
   // bandwidth determined by ODR
   xgWriteByte(CTRL_REG6_XL, tempRegValue);
  
  tempRegValue = 0;     // high res & filters off
   xgWriteByte(CTRL_REG7_XL, tempRegValue);
 

Eleon BORLINI
ST Employee

​Hi @frackers did you get the right value for the​ WHO_AM_I reg, right? And are you able to read gyro data but no axl data? I can suggest you also to check this C code (example). Regards

frackers
Senior

I was getting the WHO_AM_I register OK but never getting a status response that indicated there was data available.

I have found 1 bug already in the example code and that is that the MAG sensor I2C addresses are the wrong way round for SA0 = 0/1 The code has:

#define LSM9DS1_MAG_I2C_ADD_L      0x3DU
#define LSM9DS1_MAG_I2C_ADD_H      0x39U

but it should be:

#define LSM9DS1_MAG_I2C_ADD_L      0x39U
#define LSM9DS1_MAG_I2C_ADD_H      0x3DU

according to  DocID025715 Rev 3. With the changes I get the MAG WHO_AM_I correctly.

Things are certainly looking up now as I appear to be getting real values out ;)

Thanks for the tip, @frackers​ , so now you can read all the data sensors or just the magnetometer (SA1, please check here for a discussion on the topic)? Did you correctly configured the SA0 bit in case of axl/gyro? Regards

frackers
Senior

Hi Eleon

Thanks to your input I'm now able to read data from all 3 axis of all 3 sensors. Great to have another task crossed off the list ;)