Skip to main content
Visitor II
October 20, 2017
Question

LIS2DH12 output x,y and z

  • October 20, 2017
  • 1 reply
  • 1778 views
Posted on October 20, 2017 at 10:46

Hello all, 

my problem is the output of the x,y and z registers.

The content of the registers change when moving, but only with fast movement. The values change during the acceleration. Unfortunately, after the movement the values fall back to the same value again.  The problem is, the values are the same in any orientation. My program accepts different values for x, y and z register in different positions, but the sensor doesn’t change these values. When the sensor is horizontal I accept g_z = 1, g_x = 0, g_y = 0  and when I turn it by 90 degrees I estimate g_z = 0,

g_y = 1, g_x = 0

at least the values should be different. However the values are the same.

Maybe I made some mistakes in the register settings or the sensor is not able to do this?????

My register settings:

Address                                             value

0x1f                                                    0xc0=     1100 0000 // edit: revised

0x20                                                   0x77=     0111 0111

0x23                                                   0x80=     1000 0000

0x24                                                   0x70=     0111 0000

0x2e                                                   0x80=     1000 0000

    This topic has been closed for replies.

    1 reply

    ST Employee
    October 20, 2017
    Posted on October 20, 2017 at 11:17

    The configuration seems to be correct, I think the problem will be in your reading procedure. Please check that you red both low and high part of the output registers.  I would recommend you to start read the data without using FIFO, because it is little bit more complex.

    Note: 0xC0 = 1100 0000

    jan nAuthor
    Visitor II
    October 20, 2017
    Posted on October 20, 2017 at 15:00

    Hello Miroslav,

    i changed the sensor to non-FIFO mode, but the values are still the same in any direction.

    Here is how I convert the data from the register to mg:

    uint8_t hight;

    uint8_t low;

    int16_t result;

    double result1;

    low = readvalue(0x28);

    hight = readvalue(0x29);

    result = ((hight<<8) | low) >> 6; // convert to 10 bit 

    if(result & 1<<9){

    result |= (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(1<<10); //convert 10 bit in 16 bit two's complement

    }

    result1 = result*4 / 1024.0; // *4 because 2g mode, 1024 because of 10 bit

    ST Employee
    October 20, 2017
    Posted on October 20, 2017 at 15:30

    The conversion is not correct (i.e. result = ((hight<<8) | low) >> 6; you rotate the high byte in 8 bit variable).

    Use following commands, it will also manage the two's complement format.

    result = ((int16_t)high<<8)+(uint16_t)low;

    result = result>>6; // in case of normal mode = 10bit output

    result1 = result * 4; // LSB to mg (FS=2g), see sensitivity in datasheet