I've just started experimenting with the MPL115A2 Digital Barometer.
Maybe I’m having a bad day – but I can’t understand how to convert the Coefficient integers / binary values into numbers.
The data sheet doesn’t seem to make sense. For example a0 is defined as
a0 Signed, Integer Bits = 12, Fractional Bits = 3 : Coeff a0 = S I11 I10 I9 I8 I7 I6 I5 I4 I3 I2 I1 I0 . F2 F1 F0
Later the data sheet uses the example a0 = 0x3ECE = 2009.75
Maskign out - bits I11 to I0 gives 2009 - but the last 3 bits (the fractional bits) are 0x06 - I can't see how that taken to be 0.75?
Are there any examples of how to take these Coefficients in binary/hex form and convert them into actual numbers?
Solved! Go to Solution.
Hi Ben,
As for the fractional part, F2 = 0.5, F1 = 0.25 and F0 = 0.125.
Considering our example, the fractional part is 0b110 = 1 x 0.5 + 1 x 0.25 + 0 x 0.125 = 0.75
You may find useful David's example project, have a look at MPL115A1.c file.
I hope it helps.
Best regards,
Tomas
Hi Ben,
As for the fractional part, F2 = 0.5, F1 = 0.25 and F0 = 0.125.
Considering our example, the fractional part is 0b110 = 1 x 0.5 + 1 x 0.25 + 0 x 0.125 = 0.75
You may find useful David's example project, have a look at MPL115A1.c file.
I hope it helps.
Best regards,
Tomas
That works for the first Co-effeicent a0 - but not the next one b1. In the data-sheet:
0xB3F9 = -2.37585
0xB3F9 = 1011 0011 1111 1001
There's one sign bit - 1 - so the number is negative
Two Integer bits - 01 - so the integer portion is 1 (not 2 according to the datasheet)
13 Fraction bits - 1 0011 1111 1001 - (this is 0.5 + 0.0625 + 0.03125 + 0.015625 0.007815 etc...) so the integer portion is 0.62414551 (not 0.37585 according to the datasheet).
Never mind got it - there's a later note in the data sheets that says:
NOTE: Negative coefficients are coded in 2’s complement notation.
Taking the bit inverse of all bits gives me the correct answer
Ah ha - thanks - that makes sense!