3
\$\begingroup\$

I have an L3GD20, which is an accelerometer with a temperature sensor built in, and I want to make sure my math isn't funky regarding the temperature. I'm not exactly experienced with embedded hardware.

I've been playing around with the temperature sensor on the L3GD20. According to the datasheet, the temperature is represented in 8 bit 2's complement, so it goes from -128 to 127. However, the datasheet includes this little snipp:

Temperature sensor characteristics

So, if I'm understanding the datasheet, the temperature sensor will deliver a temperature range of -40c to +85c in 8 bit 2's complement. So, a raw value of 127 (0x7F) from the sensor would correspond to +85c, and a raw value of -128 (0x80) would correspond to -40c. Therefore, the spacing between consecutive readings (for example, 0x00 and 0x01) is approximately 0.5c. I came to this conclusion by taking the temperature range and dividing it by the output range of the sensor: (85 - (-40)) / (127 - (-128)).

But then here's the part where my math gets fuzzy. If the temperature range remained the same (125c from smallest to largest), but was centered on 0, it would go from -62.5 to +62.5). But it doesn't. It goes from -40 to 85c. Therefore, the temperature range has a positive offset of 22.5c. But since there's approximately 2 codes from the temperature sensor for every degree Celsius, a raw value of 0x00 from the sensor would correspond to 11.25c, correct?

TL;DR version: I have a temperature sensor that ranges from -40c to +85c, and gives the reading back in 8 bit 2's complement. In order to get the actual temperature in degrees Celsius, I believe I need to add 11.25 (or just 11 to keep things simple) to the sensor output. Is this correct?

\$\endgroup\$
6
\$\begingroup\$

You're confusing the operating specifications of the chip with the readout format.

Basically, the Electrical characteristics specify the range of temperatures at which the IC is guaranteed to work properly. This is a physical characteristic of the device. As the datasheet says Operating temperature range, e.g. this is the temperature range over which the IC is supposed to work properly. It has no relation to the theoretical range of the register containing the measurement value.

The temperature sensor readout is specified as "-1 °C/digit". Therefore, each increment of the temperature output equals one degree C. My guess would be that the value of the temperature readout would probably directly correspond to the actual IC die temperature in degrees C, though you should verify this.

The two specifications are unrelated. It's like a car speedometer. My car's speedometer goes up to ~150 miles/hour. However, it's not intended to actually be driven at those speeds. As such, the readout range (0-150 Mph) significantly exceeds the intended operating conditions (~0 - ~85 Mph), as they're different characteristics.

\$\endgroup\$
  • 1
    \$\begingroup\$ +1 For good answer plus the excellent speedometer analogy. \$\endgroup\$ – Michael Karas Sep 22 '13 at 14:04
0
\$\begingroup\$

As I known, L3GD20 is a gyroscope device. Anymore, you can get real temperature from its register which is just map to celsius temperature directly. i.e. you read 0x13 from gyro, then the temperature in this device is though to be 19 degree celsius.

\$\endgroup\$
0
\$\begingroup\$

The device has a relative temperature sensor with negative temperature coefficient. It can therefore only be used to sense temperature variation. Note there is no temperature accuracy spec.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.