Skip to main content
Visitor II
March 7, 2018
Question

LIS3DH

  • March 7, 2018
  • 2 replies
  • 2136 views
Posted on March 07, 2018 at 14:03

Hi Sir,

I am using ST accelerometer Sensor  LIS3DH (adapter board STEVAL-MKI105V1) with I2C interface.

I can now read the registers

. But for the registers which doesn't have default value, for example,

OUT_X_L (0x28),

OUT_

X

_H

(0x29),

OUT_Y_L

(0x2A),

OUT_Y_H

(0x2B),

OUT_Z_L

(0x2C),

OUT_Z_H

(0x2D),

the value read are all zero.

My questions:

1. How to get the correct accelerometer value for the registers which doesn't have default value? Any configurations needed before reading the registers?

2. “AN3308â€� chapter 4 Startup sequence to write the registers, but what values should be written? Could you help to advice?

Thanks,

Arna Lee

    This topic has been closed for replies.

    2 replies

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

    Or course you have to configure the sensor first, there are several modes and features which needs to be configured.

    Please read carefully the datasheet and the application note.

    You have to at lease set the Output Data Rate in CTRL_REG1.

    0690X00000609rEQAQ.png
    Arna LeeAuthor
    Visitor II
    March 8, 2018
    Posted on March 08, 2018 at 04:41

    Hello

    Batek.Miroslav

    Thank you for the comment.

    I tried to configure

    CTRL_REG1

    then read OUT_X_/OUT_Y_/OUT_Z_, for example,

    OUT_Y

    _L, but I got different/changing value even though I didn't move it. It is normal?

    Could you be kindly to review my log if anything wrong?

    Thanks a lot.

    --- Logs ---

    START...

    call LIS3DH_GetWHO_AM_I

    read LIS3DH_WHO_AM_I(0x0F) reg: 0x33

    --- UART2 RX HEX: ---

    7E 20 03 33 20 4E

    Cal_Checksum: 0x4E

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x20, Response: 0x57

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x80

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x80

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0xC0

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0xC0

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x80

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40

    --- UART2 RX HEX: ---

    7E 20 04 33 2A 43

    Cal_Checksum: 0x43

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x2A, Response: 0xC0

    ---

    Thanks,

    Arna Lee

    ST Employee
    March 10, 2018
    Posted on March 10, 2018 at 16:15

    It is absolutly normal, there is always some small noise, caused by the sensor itself or by vibration of the enviroment.

    Arna LeeAuthor
    Visitor II
    March 13, 2018
    Posted on March 13, 2018 at 03:35

    Hi Sir,

    I am confused.

    I just keep the sensor on the desk. But it looks like the XYZ data change a little big?

    Any other register needed to be configured before using XYZ register/data?

    **************************************

    START...

    call LIS3DH_GetWHO_AM_I

    read LIS3DH_WHO_AM_I(0x0F) reg: 0x33

    --- UART2 RX HEX: ---

    7E 20 03 33 20 4E

    Cal_Checksum: 0x4E

    call HAL_I2C_Mem_Read

    Read I2C device addr: 0x33, register addr 0x20, Response: 0x57

    --- UART2 RX HEX: ---

    7E 24 01 5B

    Cal_Checksum: 0x5B

    X=  -128 Y= -1856 Z=-16064

    --- UART2 RX HEX: ---

    7E 24 01 5B

    Cal_Checksum: 0x5B

    X=  -128 Y= -1664 Z=-16000

    --- UART2 RX HEX: ---

    7E 24 01 5B

    Cal_Checksum: 0x5B

    X=  -704 Y= -1536 Z=-16192

    **************************************

    Thanks,

    Arna

    ST Employee
    March 15, 2018
    Posted on March 15, 2018 at 16:46

    I would help if you convert the data into g unit, you would see the change is small and is caused by noise.

    It depends which mode you are using, according to the mode the output is 8, 10, 12 bit left adjusted in 16 bit output register.

    Arna LeeAuthor
    Visitor II
    March 23, 2018
    Posted on March 23, 2018 at 05:49

    Hi Miroslav,

    Thank you for the reply.

    It makes me more clear to understand.

    BTW, how to

    convert the raw XYZ data into g unit?

    Any reference?

    Thanks,

    Arna