cancel
Showing results for 
Search instead for 
Did you mean: 

I am using the LIS2DH12 and get expected values in normal mode. When changing to high res mode the scaling is not as expected.

CLaw.1
Associate II

FS=11, BLE=0, LPen=0, HR=0 (10-bit normal mode, +/-16g FS). I expect the sensitivity to be 48mg/digit, and sure enough, if I right-align my 10-bit value and divide by 48 I get a value of about 1054 on the z-axis.

When I set HR=1, no other changes, I expect the sensitivity to be 12. I right-align the 12-bit z-axis reading and divide by 12, I get a value of the order of 16300.

Could someone suggest what I might be doing wrong?

Incidentally, in section 4.2.3 of AN5005 there is an example of the expected reading for 1g when set to FS of 2g in high res mode. With BLE=0 the supposed reading is 00h 40h. By my calculation, I believe this should have a sensitivity of 1 (table 3, section 3) and therefore equates to 1024mg, not 1g as documented. Would others agree with that?

6 REPLIES 6
Eleon BORLINI
ST Employee

Hi @CLaw.1​ ,

please consider the LIS2DH12 C drivers on Github (lis2dh12_reg.c) for a double check of your code. In particular the functions:

float_t lis2dh12_from_fs16_hr_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 16.0f ) * 12.0f;
}
 
float_t lis2dh12_from_fs16_nm_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 64.0f ) * 48.0f;
}

Considering the calculation for the section 4.2.3 of AN5005, the case of hr FS +-2g, you have:

  • reg 29h = 15h concatenate with reg 29h = E0h --> 15E0h --> [int16 two's complement conversion on 16bits] --> 5600dec --> [+-2g FS conversion function] --> 350mg

Please let me know if something is not clear.

-Eleon

CLaw.1
Associate II

Hi Eleon

Thank you for your response. The actual readings I get from the device when set to FS +-16 HR mode are

0x00, 0x04, 0x00, 0x04, 0x00, 0x50

On the z-axis I have the 16-bit value of 0x5000, and using the function above, lis2dh12_from_fs16_hr_to_mg this gives a final answer of 15360, whereas I would expect something in the region of -1000.

The setup of the registers is as follows:

CTRL_REG1 0b01000111

wait 500ms

CTRL_REG2 0b11000001

wait 10ms

CTRL_REG3 0b01000000

CTRL_REG4 0b00111000

CTRL_REG5 0b00000000

CTRL_REG6 0b00000000

REFERENCE 0b00000000

INT1_CFG_ 0b00101010

CTRL_REG5 0b00000000

wait 500ms

Regarding 4.2.3 of AN5005, I can see that the examples lead to 350mg and -350mg, but I was specifically querying the example of 1g, where the readings from the sensor are shown to be 0x00, 0x40. Using your description, above, this leads to a 16-bit number of 0x4000, which when converted gives a final answer of 1024, not 1000 (1g) as the paper shows. IN order to correctly yield 1g I think the example readings should be 0x80, 0x3E, would you agree?

Charles

Eleon BORLINI
ST Employee

Hi Charles,

supposing you want to measure the 1g gravity value along z axis, you first have to be sure that your device is in flat position, with z axis pointing upwards.

Second, you should check if there are offset not compensated at Time0, for example due to the soldering or tho any eventual bending of the board.

Third, you could check if the device well behaves with FS +-2g. In the +-16g case, in fact, 1LSB is 12mg, and in your case the difference is 1024mg - 1000mg = 24mg, so not just the double of a single digit sensitivity...

If you have doubts on the configuration (which should be ok), I suggest you to also have a look to the C drivers on Github, particularly the lis2dh12_read_data_polling.c, for the register configuration.

-Eleon

CLaw.1
Associate II

Hi Eleon

Yes, the device is perfectly flat. The readings taken in +-2g normal mode are

0x40, 0x01, 0xc0, 0x00, 0xc0, 0xbf

By my calculation this gives final values of

X = 20mg; Y = 12mg; Z = -1028mg

which are pretty much where I might expect them to be. Therefore, I believe that the device is behaving well in +-2g normal mode. I also find that it behaves well in +-16g normal mode. The issue I have is in HR mode, which leads me to believe that I could be doing something wrong, either in the interpretation of the readings or in the configuration. I'm hoping that someone can point me towards my error. I will certainly look at the lis2dh12_read_data_polling.c code as you suggest.

Regards

Charles

Eleon BORLINI
ST Employee

Hi Charles @CLaw.1​ ,

the lis2dh12_read_data_polling.c Github example configures the device in HR mode, FS +-2g.

Can you please compare your code with this one and see if everything is fine?

-Eleon

Grgva.1
Associate

Supposing you want to measure the 1g gravity value along z axis, you first need to be sure that your tool is in flat function, with z axis pointing upwards.

Second, you ought to test if there are offset now not compensated at Time0, for example due to the soldering or the any eventual bending of the board.