MPL3115A2 question:

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

MPL3115A2 question:

Jump to solution
1,891 Views
rheal
Contributor I
So the 20 bit altitude value consists of 2 bytes with a 2-s complement signed number,   and 4 bits in the third byte representing fractions of a metre as an unsigned number.So if I go to Death Valley and the first two bytes are -30 metres  and the fractional bits in the 3rd byte amount to 0.6 metres,   does that make the total result to be -30.6 metres or -29.4 metres ?
0 Kudos
1 Solution
1,621 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello,

The fractional component needs to be added to the integer component, so the result would be -29.4 meters.

Let’s consider another example:

OUT_P_MSB = 0xFF

OUT_P_CSB = 0xFF

OUT_P_LSB = 0xF0

The integer component is -1, the fractional component 0.9375 ((0xF0 >> 4) * 0.0625) and the resulting altitude -1 + 0.9375 = -0.0625 meters. 

You can find a simple example code for the MPL3115A2 working in the Altimeter mode in this document.

I hope it helps.

Regards,

Tomas

View solution in original post

0 Kudos
1 Reply
1,622 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello,

The fractional component needs to be added to the integer component, so the result would be -29.4 meters.

Let’s consider another example:

OUT_P_MSB = 0xFF

OUT_P_CSB = 0xFF

OUT_P_LSB = 0xF0

The integer component is -1, the fractional component 0.9375 ((0xF0 >> 4) * 0.0625) and the resulting altitude -1 + 0.9375 = -0.0625 meters. 

You can find a simple example code for the MPL3115A2 working in the Altimeter mode in this document.

I hope it helps.

Regards,

Tomas

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-266768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMPL3115A2%20question%3A%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-266768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3ESo%20the%2020%20bit%20altitude%20value%20consists%20of%202%20bytes%20with%20a%202-s%20complement%20signed%20number%2C%26nbsp%3B%26nbsp%3B%20and%204%20bits%20in%20the%20third%20byte%20representing%20fractions%20of%20a%20metre%20as%20an%20unsigned%20number.%3C%2FTD%3E%3CTD%3ESo%20if%20I%20go%20to%20Death%20Valley%20and%20the%20first%20two%20bytes%20are%20-30%20metres%26nbsp%3B%20and%20the%20fractional%20bits%20in%20the%203rd%20byte%20amount%20to%200.6%20metres%2C%26nbsp%3B%26nbsp%3B%20does%20that%20make%20the%20total%20result%20to%20be%20-30.6%20metres%20or%20-29.4%20metres%20%3F%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-266769%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MPL3115A2%20question%3A%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-266769%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EThe%20fractional%20component%20needs%20to%20be%20added%20to%20the%20integer%20component%2C%20so%20the%20result%20would%20be%20-29.4%20meters.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3ELet%E2%80%99s%20consider%20another%20example%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EOUT_P_MSB%20%3D%200xFF%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EOUT_P_CSB%20%3D%200xFF%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EOUT_P_LSB%20%3D%200xF0%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EThe%20integer%20component%20is%20-1%2C%20the%20fractional%20component%200.9375%20((0xF0%20%26gt%3B%26gt%3B%204)%20*%200.0625)%20and%20the%20resulting%20altitude%20-1%20%2B%200.9375%20%3D%20-0.0625%20meters.%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EYou%20can%20find%20a%20simple%20example%20code%20for%20the%20MPL3115A2%20working%20in%20the%20Altimeter%20mode%20in%20%3CA%20_jive_internal%3D%22true%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fdocs%2FDOC-95378%22%20target%3D%22_blank%22%3Ethis%3C%2FA%3E%20document.%20%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20hope%20it%20helps.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETomas%3C%2FP%3E%3C%2FLINGO-BODY%3E