MPL115A1- Barometer Coefficient reading

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPL115A1- Barometer Coefficient reading

Jump to solution
913 Views
ttahut
Contributor III

Hello,

I'm having trouble figuring out the example in the data sheet for reading and calculating the c12 coefficient.  The data sheet indicates there are 13 fractional bits, plus a sign bit, and it has 9 decimal points of pad built in.  In the example reading and calculation it shows a raw reading of the MSB and LSB of the coefficient as follows:

c12 coefficient MSB = 0x38

c12 coefficient LSB = 0xCC c12 coefficient = 0x38CC = 0.00086665

First, the 0x38CC value is 14 bits.  Even if you assume the 14th bit is actually the sign bit, then the value calculated should be negative.

From the description of 'dec point zero pad', I assume that means that each fractional bit actually has the resolution of 1/(2**(9 + 13))= 1/4194304.

If you take the straight 0x38cc= 14540, then c12= 14540/4194304 = 0.003466 (not quite the value in the example).

If you take 0x38cc and assume the 14th bit is the sign bit, then after the 2's compliment you get 0x733= 1843 for the absolute value.  This yields

c12= 1843/4194304 = 0.0004394 (about half of the example value- but the wrong sign).  So- what am I missing?  Or is the example incorrect?

Thanks in advance for your help.

Tom

Labels (1)
1 Solution
619 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Tom,

Your assumption is basically correct, but you need to take into consideration that the last two bits of the c12_LSB are zero as shown on page 5 of the data sheet:

c12 MSB byte = c12[13:6] = [b13 , b12 , b11 , b10 , b9 , b8 , b7 , b6]

c12 LSB byte = c12[5:0] & “00” = [b5 , b4 , b3 , b2 , b1 , b0 , 0 , 0]

and the c12 coefficient is formatted as follows:

c12 = b13 0 . 000 000 000 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0

So you are right that each fractional bit has the value of 1 / 2^(9+13), but the 16-bit c12 value needs to be first right shifted by 2 (or divided by 4) to obtain 13 fractional bits. 

Considering our example, the 16-bit c12 = 0x38CC.

Then b12 .. b0 = 0b011 1000 1100 11 = 3635

and c12 = 3635 / 2^22 = 0.00086665

I hope it helps.


Regards,

Tomas

View solution in original post

1 Reply
620 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Tom,

Your assumption is basically correct, but you need to take into consideration that the last two bits of the c12_LSB are zero as shown on page 5 of the data sheet:

c12 MSB byte = c12[13:6] = [b13 , b12 , b11 , b10 , b9 , b8 , b7 , b6]

c12 LSB byte = c12[5:0] & “00” = [b5 , b4 , b3 , b2 , b1 , b0 , 0 , 0]

and the c12 coefficient is formatted as follows:

c12 = b13 0 . 000 000 000 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0

So you are right that each fractional bit has the value of 1 / 2^(9+13), but the 16-bit c12 value needs to be first right shifted by 2 (or divided by 4) to obtain 13 fractional bits. 

Considering our example, the 16-bit c12 = 0x38CC.

Then b12 .. b0 = 0b011 1000 1100 11 = 3635

and c12 = 3635 / 2^22 = 0.00086665

I hope it helps.


Regards,

Tomas