Skip to main content
Visitor II
February 19, 2018
Question

LIS2DH setup for fifo and tap interrupt

  • February 19, 2018
  • 9 replies
  • 2469 views
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.

    This topic has been closed for replies.

    9 replies

    ST Employee
    February 20, 2018
    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.

    Visitor II
    March 7, 2018
    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.

    ST Employee
    March 7, 2018
    Posted on March 07, 2018 at 14:48

    What are the values in the new position?

    Visitor II
    March 7, 2018
    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.

    ST Employee
    March 7, 2018
    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.

    Visitor II
    March 8, 2018
    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 

    ST Employee
    March 10, 2018
    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).

    Visitor II
    November 19, 2018

    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

    ST Employee
    November 19, 2018

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

    Visitor II
    November 19, 2018

    I'm trying to incorporate tilt detection and click detection, click detection (from ISR) is only displayed after displaying about 6 or 7 sets of raw values of all three axes.

    Without FIFO enabled, I am able to detect the clicks correctly but I want to be able to obtain raw values of all axes and also have click detection.

    Visitor II
    November 20, 2018

    Hi, I implemented raw data with fifo interrupt with double click @25HZ, Below are my registers setting,

    CTRL_REG1 - 0x37

    CTRL_REG2 - 0x04

    CTRL_REG3 - 0x04

    CTRL_REG4 - 0x10

    CTRL_REG5 - 0x40

    CTRL_REG6 - 0x80

    FIFO_CTRL_REG - 0x80 |0x19

    CLICK_CFG - 0x20 (enabling only for Z axis)

    Visitor II
    November 20, 2018

    Hi, so did you read the values from the FIFO_READ_START register by storing it in a buffer?