Skip to main content
Explorer II
July 5, 2023
Solved

LSM303AH -1G/1G Unexpected Output, Less than 90 degrees

  • July 5, 2023
  • 1 reply
  • 3509 views

Hello,

I am having issues with my acceleration data being output from my LSM303AHTR. I have configured it for 2G Full scale making the "sensitivity" 0.061mg/lsb.

I have tested two LSM303AH chips on two of our custom PCBs. I am getting similar results on both chips, but I am not getting the same exact values on both chips.

I evaluated all axis at +Gravity, -Gravity, and 0 Gravity. All of the expected 0 Gravity values are being seen, however, I am getting less than 90 degrees for positive and negative 1G positions.

My method for obtaining degrees from counts follows. I believe it is correct because it works for other projects' accelerometers:

Register Value * Sensitivity = mg
G = mg*1000
arcsin(G)

We can abstract out my method for obtaining degrees and just focus on counts. The issue still remains. When I am reading an axis that has full gravity exposure, I should be getting +/- 16,383 counts.

For X +1G I am getting -16,900 counts, which converts to 90 degrees, but this is slightly off scale.
For X -1G I am getting -15,750 counts, which converts to -75 degrees.
For Y +1G I am getting 15,750 counts, which converts to 75 degrees (just like X -1G).
For Y -1G I am getting -16,080 counts, which converts to -75 degrees.
For Z +1G I am getting 16,550 counts, which converts to 90 degrees, but this is slightly off scale.
For Z -1G I am getting -17,000+ counts which is greatly off scale.

Regarding my code, it is very specific and wouldn't make sense to anyone. I am shifting the MSB 8 bits and OR'ring it with LSB and stuffing that into a Signed Int. Again, we can talk about the conversion process, but all that really matters are the Counts I'm reading, which are not what is expected.

It's worth noting that I am very familiar with how this chip works because I am accustomed to using LIS2DS12 which is essentially the same as LSM303 except it doesn't have a magnetometer built in. 

Any help is appreciated.
Thank you.


    This topic has been closed for replies.
    Best answer by niccolò

    Hi @wb346 ,

    I'm not sure I can see the issue:
    I see data that is only slightly off spec: the offset accuracy is 30 mg, and applying the sensitivity to your data I see
    X: -16,900, -15,750 (I imagine that one of those is with a +) -->   -1030,  -970  [mg]
    Y: 15,750 -16,080  --> 970, -980 [mg]
    Z: 16,550 -17,000  -->  1009, -1037 [mg]

    just focusing on the counts, as you suggested, I see no problem in the data (not a problem as big as a 15 degrees error), so I think that the problem is in the algorithm for angle calculation.
    I would try to use the formula used by the design tip and check if the problem is there

    1 reply

    Technical Moderator
    July 5, 2023

    Hi @wb346 ,

    Have you already tried to compute this following the guidelines reported in our design tip here?

    If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster.

    wb346Author
    Explorer II
    July 5, 2023

    @Federica Bossi Thanks for the reply. I have that document bookmarked, but I haven't read it in a while and I have not computed tilt using those formulas.
    This is the reason however, that I emphasized the counts. 

    The conversion from counts to degrees is irrelevant. I only mentioned the conversion so we could all use a metric that is widely understood (degrees).

    The problem remains that the counts coming out of the chip are not expected values. I'm also going to reflow the chip on both of my boards and see if that helps anything.

    Technical Moderator
    July 7, 2023

    Ciao @wb346 ,

    Ok, can you please share your full configuration?