cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH setup for fifo and tap interrupt

chandan bhatia
Associate II
Posted on February 19, 2018 at 07:51

I want to use LIS2D for FIFO and tap interrupt. Its generating FIFO interrupt but I am not able to get single tap interrupt.My register settings are as below. I want my FIFO interrupt of INT1 and Tap interrupt on INT2. Please suggest where I am going wrong.

CTRL_REG1 : 0x37

CTRL_REG2 : 

0x00

CTRL_REG3 : 

0x04

CTRL_REG4 : 

0x10

CTRL_REG5 : 

0x40

CTRL_REG6 : 

0xA0

CLICK_CFG : 0x15

Thanks.

12 REPLIES 12
Miroslav BATEK
ST Employee
Posted on February 20, 2018 at 15:14

I would suggest set the CTRL_REG6 to 0x80.

And you have to also set following registers for the single tap detection:

CLICK_THS (0x3A) ... 0x10

TIME_LIMIT (0x3B) ... 0x20

TIME_LATENCY (0x3C) ... 0x20

The values can be adjusted according to your needs.

chandan bhatia
Associate II
Posted on March 07, 2018 at 13:47

Thanks Its working fine.

I have one doubt. If accelerator is on rest on a desk and it should give one axis value around 9.8 and other as zero. But I noticed one thing, If I am moving my accelerator to some other direction,its x , y and z values are changing and giving acceleration value (which is correct) but  after going to new position later it should get back to one axis value as 9.8 and other axis around 0 but why this is not happening. Can you please suggest.

chandan bhatia
Associate II
Posted on March 07, 2018 at 15:18

Previous position values are around these 3 values :

200,848,-448

192,856,-448

200,840,-448

Later I changed the position and make it rest in new position. I got below values :

16,96,-944

24,104,-936

Note: Values are in milli G.

Thanks.

Posted on March 07, 2018 at 14:48

What are the values in the new position?

Posted on March 07, 2018 at 17:02

The value seems OK. I suppose the positions of the sensor are not exactly the same.

If you calculate the the absolute value of the acceleration (sqrt(X*X+Y*Y+Z*Z)) you will get 1g = 9.81m/s2 of gravity in all cases.

In the second position the Z axis is almost along the gravity vector.

chandan bhatia
Associate II
Posted on March 08, 2018 at 06:24

Yes correct but I am asking something else. Let me try it again.

Accelerometer calculate acceleration. so if I am moving from a location to b location, After reaching new postion b, sensor should give acceleration value but after some time being on rest as there is no acceleration, X, Y and Z should get back to previous rest value but why this is not happening. I am confused right now. Please let me know if my understanding is correct.

Thanks 

Posted on March 10, 2018 at 16:20

The X, Y, Z values in firts and second position will be the same only in case the postions of the sensor is absolutly the same (I mean the position towards to gravity vector).

suryaa
Associate II

Hi, I'm working on a similar program. Can you guide me as to which registers you are using to read the raw values. I tried using the OUT X, Y and Z registers but both interrupts aren't working well together.

This is my config:

  write_i2c(I2C_DEVICE_ADDRESS, REG_CTRL1, 0x37); //power on all axis, max sample rate(400 Hz)
  write_i2c(I2C_DEVICE_ADDRESS, REG_CTRL2, 0x00); //HPF disabled
  write_i2c(I2C_DEVICE_ADDRESS, REG_CTRL3, 0x04); //Watermark (WTM) interrupt enabled on INT1 pin
  write_i2c(I2C_DEVICE_ADDRESS, REG_CTRL4, 0x10); //Full Scale = ±4g
  write_i2c(I2C_DEVICE_ADDRESS, REG_CTRL5, 0x40); //FIFO enabled
  write_i2c(I2C_DEVICE_ADDRESS, REG_CTRL6, 0x80); //Click interrupt on INT2 pin
  write_i2c(I2C_DEVICE_ADDRESS, REG_FIFO_CTRL, 0x9F); //FIFO Stream Mode selected ; (N+1) samples to be read at the rise of WTM interrupt
  write_i2c(I2C_DEVICE_ADDRESS, REG_INT1_CFG, 0x3F); //Interrupt generation enabled on all axes for both high & low events
  write_i2c(I2C_DEVICE_ADDRESS, REG_INT1_THS, 0x03); //1LSb = 32 mg 
  write_i2c(I2C_DEVICE_ADDRESS, REG_CLICK_CFG, 0x2A); 
  write_i2c(I2C_DEVICE_ADDRESS, REG_CLICK_THS, 0x02);
  write_i2c(I2C_DEVICE_ADDRESS, REG_TIME_LIMIT, 0x10);
  write_i2c(I2C_DEVICE_ADDRESS, REG_TIME_LATENCY, 0x40);
  write_i2c(I2C_DEVICE_ADDRESS, REG_TIME_WINDOW, 0x90);

Regards

Miroslav BATEK
ST Employee

What you mean by "both interrupts aren't working well"? What is the behavior of your system?