cancel
Showing results for 
Search instead for 
Did you mean: 

H3LIS200DL Readings and Conversion

Rogers.Gary
Senior II
Posted on June 13, 2017 at 06:03

Hello:

I am getting some bizarre values from this device, and maybe it's not configured correctly, or I am not reading it correctly.

It appears I can send and read from the device. I can use the 'WHO_AM_I' and get back the value 32, which is correct. I then set the control register 1 at 0x20  to 0x27 = b00100111, which sets PM to normal, and x, y and z enabled. To check if the register has taken the value, I read it back, and it says 0x27.

I'm assuming then that after doing this, I can just read the output registers at x,y and z, and  I am doing reads every 100ms (I do not have the interrupts configured at this point, and for now, not converting from two's complement)

However, I am unable to get the output registers to change from 0xFF, no matter what I do with the board it's mounted on. I have tried some pretty hard 'nudges' and it will not change. Additionally, if I continuously read the status register, it is always 0xEE, which makes little sense.

Can someone provide some insight as to what might be going wrong?

Thanks for your help!

Roger.

5 REPLIES 5
Miroslav BATEK
ST Employee
Posted on June 13, 2017 at 09:52

You assumption is correct if you set the register CTRL_REG1 (0x20) to 0x27, the sensor is running and you can read the data from output registers.

The value 0xEE in STATUS_REG means you are reading only OUT_X register. Can you please check your reading procedure.

The range of the sensor is 100g or 200g so the output value 0xFF is OK if the sensor is still, but if you make significant movement with the sensor the output value should change.

Rogers.Gary
Senior II
Posted on June 13, 2017 at 19:10

thank you for taking the time to reply, Miroslav.

makes perfect sense, tested that and it does return 0 when all registers are read. I may have a couple other questions as I continue to set and test the device, so I do appreciate your support on this forum!

Rogers.Gary
Senior II
Posted on June 14, 2017 at 04:05

hi miroslav,

so I can confirm the status register does change when I read each register - for example, if I comment one read out, the register value also changes.

Problem - I cannot get the value to change on any axis. It always remains at 0x255. I am applying some significant hits to the enclosure/board. I also have an analog sensor on there (+/-6g) and it does register high counts from the ADC.

What could be wrong? (now I'm worried)

Rogers.Gary
Senior II
Posted on June 14, 2017 at 04:33

I have done some further testing. It does seem to be functioning! I guess I was not quite 'accelerating' it the way it needs to in order to register. I may need to do some adjustment on the filters and/or data rate. Can you explain the data output? Here's what I'm doing with th output value. Checking the first bit, if it's 0, mask it and invert the others. Otherwise don't adjust. The values don't seem right for how it is being moved. Here's the code:

volatile uint8_t x = SPI_read( LIS200DL_OUT_X );

if(  x && 0x80  )

{

   x ^= (-0 ^ x) & (1 << 8);

   valX = x ^ 1;

}

else

{

   valX = x;

}

Is this correct?

Thanks again....

Rogers.Gary
Senior II
Posted on June 14, 2017 at 05:51

ok, got it working now. check sign bit, if negative, invert and add 1, otherwise use value. positive or negative, multiply by the scale sensitivity to get g.