A technician must decide whether decoded temperature is safe before changing signed sensor count on the real device. The result is unresolved until the rule and units are checked. Predict the direction first.
See the relationship before changing it
The figure reads from left to right. The blue card is signed sensor count. The middle card applies this page's rule. The green card is decoded temperature. Walk the arrows once: set the input, apply the rule, then read the result with its unit.
The retained audit below checks several chapter fixtures. This model keeps those stated values fixed and changes only signed sensor count, so the numeric fixture does not switch without explanation.
Derive the baseline in four named moves
- 1
Name the input. The chapter baseline is -400 counts.
- 2
Name the relationship. temperature = signed count x 0.0625 degrees C/count
- 3
Substitute with units. -400 x 0.0625 = -25.0 degrees C
- 4
Read the result. Keep the unit beside the value. Use it only inside the technical boundary on this page.
Predict, then change signed sensor count
Try Predict the direction of temperature = signed count x 0.0625 degrees C/count. Test another signed sensor count, then compare decoded temperature.
Observe Signed decoding makes counts below zero represent temperatures below zero. Reset signed sensor count to -400 and compare decoded temperature.
Explain Signed decoding makes counts below zero represent temperatures below zero.
Check yourself
What should you do before trusting a moved-control result?
What does this small model leave out?
1. Start with the physical story
The sensor sends a bit pattern, not a signed JavaScript or C number. Firmware must first isolate the field, then interpret its sign, then apply degrees per count. Correct decoding cannot recover detail already lost to quantisation or slow polling.
2. Name every algebra move
Count the codes12 bits give 2¹²=4096 patterns.
Find the sign thresholdBit 11 begins at 2¹¹=2048.
Sign-extendIf raw≥2048, subtract 4096.
Apply physical scaleMultiply the signed count by 0.0625°C.
Bound acquisitionUse q/√12 for rounding rms and fs/2 for Nyquist.
3. Reproduce the chapter case
signed=3696−4096=−400 counts
T=−400(0.0625)=−25.0°C
Tunsigned=3696(0.0625)=+231.0°C
σq=0.0625/√12=0.0180°C; fN=1/2=0.500 Hz
Only the sign-extension move separates the plausible cold result from the +231°C field bug. Sampling and quantisation remain separate limits after decoding succeeds.
4. Try one real input
TryMove the raw 12-bit code across the sign boundary and predict the signed temperature.
ObserveAt 0x800, the signed result jumps from the largest positive count to the most negative count. The unsigned path never makes that correction.
ExplainTwo's complement wraps the negative half of the code space; multiplying before sign extension turns valid negative evidence into a large positive error.
This ledger assumes a correctly isolated, right-justified 12-bit field with 0.0625°C per LSB.
- Register
- Byte order, field alignment, configuration bits, sign convention, and update timing come from the datasheet.
- Sensor
- Accuracy, offset, noise, response time, self-heating, and calibration exceed quantisation alone.
- Sampling
- The stated 1 Hz poll is illustrative; the real thermal bandwidth and anti-alias path must be known.
Correct, not complete: this decoder does not validate the register transaction or certify temperature accuracy.
5. Use the result in the design
Keep raw bytes and the extracted field in logs, test both sides of 0x800, apply sign extension before scaling, and compare the result with a reference temperature.
6. Record the evidence state
Record sensor part and mode, register address, byte order, bit width and alignment, raw bytes, extracted hex code, signed count, scale, poll rate, timestamp, and reference reading.
7. Check yourself
Why subtract 4096 from 0xE70?
What should 0xFFF decode to?
Does perfect sign extension prove accurate temperature?
The arithmetic reproduces the chapter's 0xE70, 12-bit, 0.0625°C/LSB case and keeps its 1 Hz sampling assumption explicit.
- Register
- Byte order, field alignment, configuration bits, sign convention, and update timing come from the datasheet.
- Sensor
- Accuracy, offset, noise, response time, self-heating, and calibration exceed quantisation alone.
- Sampling
- The stated 1 Hz poll is illustrative; the real thermal bandwidth and anti-alias path must be known.
Correct, not complete: this decoder does not validate the register transaction or certify temperature accuracy.
Eddie guides