Skip to main content
Visitor II
January 21, 2021
Solved

LIS2DE12 self test

  • January 21, 2021
  • 4 replies
  • 1819 views

I am trying to set up a self test process for an assembly including an LIS2DE12. The device works normally when I tilt and invert it. When I try to put it in to self-test mode by writing either 02h or 04h to CTRL_REG4 the readings are the same as with 00h written to CTRL_REG4.

I initially tried using the process for the LIS3DH on Page 57 of AN3308 but that says to write 80h to CTRL_REG4, which does not seem to be valid because that would set the BDU bit to 1, not valid for an 8 bit part, and not set either of the self test bits.

Can someone please shed some light on whether the self-test function is available with the LIS2DE12 and what I can expect from it.

Thanks in advance,

Rob

    This topic has been closed for replies.
    Best answer by RKeit.1

    Hello again Eleon,

    I have found the problem and now getting good consistent results in self test mode. I had forgotten to set the write bit used by the state engine that controls the SMBUS in the MCU I am using. I still can't get it to work with the Arduino but that doesn't matter.

    Results I am getting, with the device sitting at an angle:

    $ normal mode CTRL_REG4 = 00h

    FD 19 3B                                    

    FE 19 3A                                    

    FF 19 3A                                    

    FE 18 3A                                    

    FE 18 3B                                    

    !                     self test mode  CTRL_REG4 = 04h                

    E1 FD 51                                    

    E1 FB 50                                    

    E2 FD 4F                                    

    E2 FC 51                                    

    E2 FC 50                                    

    E3 FD 50                                    

    $ normal mode CTRL_REG4 = 00h                                       

    FE 19 39                                    

    FE 18 3A                                    

    FE 19 3A

      

    Thanks again,

    Rob

    4 replies

    ST Employee
    January 22, 2021

    Hi Rob @RKeit.1​ ,

    I suggest you to check also the C code implementing the self-test procedure for the LIS2DE12 that you can find on Github at this link --> lis2de12_self_test.c

    This procedure is a little long, so it might be useful to have a double check on that code, besides the procedure described in the AN3308 p.57 (which is for the LIS3DH )

    Please let me know if the code is useful for your purposes.

    -Eleon

    RKeit.1Author
    Visitor II
    January 22, 2021

    Hello Eleon,

    Thank you for your answer. That gives me some clues. One thing I am still unsure of is the magnitude of the variations in readings during self test. Is it like a few LSBs or bigger? Does it occur on all axes? I know the answers are probably in the documentation but I have winter brain fog.

    I see the term mg used. Is that milli-gravity? If so then it could be too small for the readings to be noticeable with only 8 bits or buried in the noise from my wobbly desk. I am working with an 8 bit MCU to develop the test process so I am just looking at the raw X, Y and Z bytes.

    Also, does the device stay in self-test mode indefinitely, until CTRL_REG4 is re-written?

    Rob

    RKeit.1AuthorAnswer
    Visitor II
    January 22, 2021

    Hello again Eleon,

    I have found the problem and now getting good consistent results in self test mode. I had forgotten to set the write bit used by the state engine that controls the SMBUS in the MCU I am using. I still can't get it to work with the Arduino but that doesn't matter.

    Results I am getting, with the device sitting at an angle:

    $ normal mode CTRL_REG4 = 00h

    FD 19 3B                                    

    FE 19 3A                                    

    FF 19 3A                                    

    FE 18 3A                                    

    FE 18 3B                                    

    !                     self test mode  CTRL_REG4 = 04h                

    E1 FD 51                                    

    E1 FB 50                                    

    E2 FD 4F                                    

    E2 FC 51                                    

    E2 FC 50                                    

    E3 FD 50                                    

    $ normal mode CTRL_REG4 = 00h                                       

    FE 19 39                                    

    FE 18 3A                                    

    FE 19 3A

      

    Thanks again,

    Rob

    ST Employee
    January 25, 2021

    Very good @RKeit.1​ !

    Remember also to use the LSB-to-milli "g" (meaning 1 gravity acceleration 9.81m/s^2 divided by 1000) conversion formulas. This is the standard magnitude for computing the acceleration with an accelerometer. The formula in the FS = 2g case is (source: lis2de12_reg.c)

    float_t lis2de12_from_fs2_to_mg(int16_t lsb)
    {
     return ( (float_t)lsb / 256.0f ) * 15.6f;
    }

    -Eleon

    RKeit.1Author
    Visitor II
    January 25, 2021

    I do all that on the cloud. I am working with a very basic MCU and do everything in raw bytes.

    Also. Not in the documentation: There are two test modes. Mode 1, CTRL_REG4 = 04, moves the readings one way and Mode 2, CTRL_REG4 - 02, moves them the same amount in the opposite direction. Average the readings from both modes. If the answer is the regular reading (within two LSBs) then all is OK.

    Now I am having fun (not) trying to reliably generate interrupts at 10 Hz ODR.

    Rob

    ST Employee
    January 27, 2021

    Hi Rob @RKeit.1​ ,

    I'll go on your other post for this topic.

    -Eleon