21

At the moment I'm playing with the LSM303DLHC accelerometer/magnetometer/thermometer.

This is its datasheet: http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00027543.pdf

Everything is working quite well, but I don't know how to interpret the output values. The datasheet (page 9) says something like "1 mg/LSB" (no, it's not milligramm :D) about the linear acceleration sensitivity in my configuration. What the hell should that mean? Same with temperature sensor output change (8 LSB/°C) and magnetic gain setting (1100 LSB/gauss), only the other way around.

For example, what to do with this accelerometer output: 16384? That is my measured gravitational acceleration.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Genesis Rock
  • 707
  • 2
  • 5
  • 16
  • 1
    A guess: mg is millli g where g is acceleration due to gravity, and LSB is least significant bit. So adding 1000 the readout out should mean adding 1 G of acceleration. The fact that your reading is 16 G's should probably worry you (grin). – Dale Wilson Oct 03 '13 at 14:35
  • That would mean the precision of the temperature readings is 0.125C which seems plausible. – Dale Wilson Oct 03 '13 at 14:37
  • The fact with the physical units was clear. I'm confused about the term "LSB" in this context. From your explanation I conclude that it means an increase or decrease of the output by 1. To calculate the accelerometer's output I just have to multiply it with 1 mg? And for the megnetometer's output i have to divide the value by 1100 Gauss? – Genesis Rock Oct 03 '13 at 14:46
  • The fact that 16384 is 0x4000 worries me. That does not look like a valid reading. – Dale Wilson Oct 03 '13 at 15:14
  • @GenesisRock: Yes, your math is right: if it's Unit/LSB multiply decimal (or binary) number times Unit/LSB to get the physical quantity; and if it's LSB/Unit, you need to divide. For the reading 16384, it could either be the maxed out reading from your sensor (it can go to 16g) or, just as likely, you'reinterpreting the registers incorrectly (very easy to do). You can figure this out by moving it around. – tom10 Oct 03 '13 at 15:40
  • 2
    NOTE: I think you are reading big endian values or something. The accelerometer registers are little endian by default (there's a control register to switch it) and the data is signed integers (2's compliment). – Eric Rini Jan 18 '15 at 03:17
  • You may find this reference useful: https://blog.mide.com/accelerometer-specifications-decoding-a-datasheet – Afflatus Aug 30 '17 at 16:23
  • When I went looking for the sensitivity specs on the magnetometer, All I wanted was to know down to what lowest field intensity it would resolve in units that I am familiar with like gamma, tesla, gauss, oersted, etc.. The datasheet was pretty meaningless to the physicist. – Jim Butler Jan 21 '20 at 06:24

5 Answers5

16

Now I got the trick. There are several things on this MEMS you have to know, but which are not mentioned in the datasheet:

  1. The accelerometer's output register is just 12 bits and not 16 bits, so you need to right-shift the value by 4 and multiply it with 0,001 G. Furthermore it's little-endian.
  2. The magnetometer's output register is 16 bits, but big-endian. Furthermore the vector order is (X|Z|Y) not (X|Y|Z). To calculate the correct value you need to devide X and Y by 980 gauss⁻¹, while it's 1100 gauss⁻¹ for Z.
  3. The temperature sensor works, but it's not calibrated. So you can use it to measure temperature change, but no absolute temperatures. It's also just 12 bits, but big-endian and you have to devide the output by 8 C⁻¹.

With that Information it's possible to use the LSM303DLHC. But who the hell invented this? "Let's build a new accelerometer, magnetometer and thermometer in one package and screw the user up by mixing word length and endianness up without mentioning it in the datasheet."

Genesis Rock
  • 707
  • 2
  • 5
  • 16
  • 2
    Genesis Rock is correct. 12 bit resolution or left justification of the accelerometer data is not mentioned in the datasheet. ST dropped the ball on that in a significant way. Something like that should really be prominently shown. This isn't a misinterpretation of the registers - the information required to interpret them just isn't there! This answer helped me also. Thanks! – Dan Puccio Mar 27 '15 at 19:31
  • One correction: in LSM303DLHC datasheet, page 9, X and Y is 1100 and Z is 980. – machineaddict Jul 19 '17 at 07:31
13

LSB/unit or Unit/LSB is the factor(called sensitivity) with which you have to multiply the raw sensor data. Say Sensor A has X,Y and Z registers , the values coming in each of the registers needs to be Divided/multiplied with the LSB/unit or Unit/LSB factor. This is because the data sheet says @ the particular fullscale you will have this much sensitivity(LSB/unit or Unit/LSB)

for LSB/Unit :

x lsb means - 1 unit

1 lsb means - 1/x unit

value lsb(value in the register) = (1/x)*(value in the register) - Apply unitary method here.

similarly for Unit/LSB you have to multiply the sensitivity.

You can build Accelerometer,Magnetometer or Temperature sensor or may be Gyro-meter in one module, but what if a customer/User wants only one sensor?

Rgds, Rp

Raulp
  • 7,758
  • 20
  • 93
  • 155
2

The datasheet is definitively unclear regarding the interpretation of the Acceleration registers. Genesis Rock solution assume it is 12-bits, which works. (Another solution is to assume gain is 16 mg/LSB instead of 1 mg/LSB, but as the last 4 bits of the accelerations seem to always be zeros the former solution makes more sense).

But both for the temperature and acceleration, if you take into account only the 12 most significant bits. The last two bits are still also always zero, so the effective resolution would be 10-bits which is confusing.

I also can't make sense of the temperature reading unless there is an unknown offset not specified in the datasheet.

I hope others can confirm they are getting the same results.

Camilo Rada
  • 456
  • 3
  • 8
1

Regarding the 12 bit output of the accelerometer: there is a high-resolution flag on control register 4. It's off by default and there's no information on what high resolution means. I'm guessing that it might enable 16 bit output. Also on control register 4 is a flag to set the endianness of the accelerometer output. It's little endian by default. The data sheet is pretty weak overall.

kallanreed
  • 11
  • 3
1

The simple and embarrassing fact is that none of the responses have hit the target of the question.

The result is buried in another parameter that is supplied in the data sheet: the sensitivity. for example the FXAS21002C for 2000 dps sensitivity is 62.5 mdps/LSB (=0.0626 dps/LSB). the zero offset is 25 LSB thus the value in dps units is 0.0625 * 25 = 1.5625 dps

the same IMU has another sensitivity for 250 dps which is 7.825 mdps/LSB (=0.007825 dps/LSB) and since the offset is also 25 LSB then the calculation will expose the real value of 0.0078125 * 25 = 0.1953 dps

the example can be found here: https://learn.adafruit.com/comparing-gyroscope-datasheets/overview

M. Hooper
  • 11
  • 1