<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>SensorsのトピックMPL115A fixed point question</title>
    <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214595#M136</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I am trying to make sense of the coefficients I receive from the pressure sensor MPL115A. &amp;nbsp;I can successfully access the IIC bus and get the data, but the algorithm provided in the AN3785 does not appear to work (at least for me). &amp;nbsp;Closer inspection of the comments raises some questions. &amp;nbsp;For example, the coeff C11 is described as a signed number with no int bits and 10 frac bits. &amp;nbsp;There are 11 pad zeros. &amp;nbsp;So I think the number looks like this:&lt;BR /&gt;&lt;BR /&gt;S0.00000000000 F10 F9 F8 F7 F6 F5 F4 F3 F2 F1 F0&lt;BR /&gt;&lt;BR /&gt;To me the representation of this number is s(0,21), but the comment says s(16,27).&lt;BR /&gt;&lt;BR /&gt;When I extract the data from the sensor, C11 is given as 0x0340. &amp;nbsp;This is a 2's compliment number and only the first 11 bits are used (the 10 frac bits and the sign bit). &amp;nbsp;So if I convert this to a real number (not something I would do in the processor, but just to see if I am understanding this correctly), &amp;nbsp;I get&lt;BR /&gt;&lt;BR /&gt;S0.00000000000 0000 0011 010x xxxx&lt;BR /&gt;&lt;BR /&gt;this gives 2^-17+ 2^-18 + 2^-20 = 0.00001239776611328125&lt;BR /&gt;&lt;BR /&gt;this is the extent of my understanding, and I wonder if someone could confirm I have done this correctly. &amp;nbsp;In addition, as the algorithm in AN3785 keeps everything in fixed point, I cannot see where lt1 (a 32-bit value) can be assigned C11 and this be correctly justified. &amp;nbsp;When I assign 0x0340 to the long I get&lt;BR /&gt;&lt;BR /&gt;lt1 &amp;nbsp; &amp;nbsp;0x00000340&lt;BR /&gt;= 0000 0000 0000 0000 0000 0011 010x xxxx&lt;BR /&gt;&lt;BR /&gt;so you can see I am not correctly aligned as per the bit-width specifications. &amp;nbsp;The following is the code snippet. &amp;nbsp;The comments make no sense to me, so any clarification you could prrovide would be most helpful&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;//******* STEP 1 c11x1= c11 * Padc&lt;BR /&gt;&amp;nbsp;lt1 = (S32)sic11; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// s(16,27) &amp;nbsp; &amp;nbsp;s(N,F+zeropad) goes from s(11,10)+11ZeroPad = s(11,22) =&amp;gt; Left Justified = s(16,27)&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;-Bill&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2026 21:47:47 GMT</pubDate>
    <dc:creator>BillTheBiker</dc:creator>
    <dc:date>2026-02-03T21:47:47Z</dc:date>
    <item>
      <title>MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214595#M136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I am trying to make sense of the coefficients I receive from the pressure sensor MPL115A. &amp;nbsp;I can successfully access the IIC bus and get the data, but the algorithm provided in the AN3785 does not appear to work (at least for me). &amp;nbsp;Closer inspection of the comments raises some questions. &amp;nbsp;For example, the coeff C11 is described as a signed number with no int bits and 10 frac bits. &amp;nbsp;There are 11 pad zeros. &amp;nbsp;So I think the number looks like this:&lt;BR /&gt;&lt;BR /&gt;S0.00000000000 F10 F9 F8 F7 F6 F5 F4 F3 F2 F1 F0&lt;BR /&gt;&lt;BR /&gt;To me the representation of this number is s(0,21), but the comment says s(16,27).&lt;BR /&gt;&lt;BR /&gt;When I extract the data from the sensor, C11 is given as 0x0340. &amp;nbsp;This is a 2's compliment number and only the first 11 bits are used (the 10 frac bits and the sign bit). &amp;nbsp;So if I convert this to a real number (not something I would do in the processor, but just to see if I am understanding this correctly), &amp;nbsp;I get&lt;BR /&gt;&lt;BR /&gt;S0.00000000000 0000 0011 010x xxxx&lt;BR /&gt;&lt;BR /&gt;this gives 2^-17+ 2^-18 + 2^-20 = 0.00001239776611328125&lt;BR /&gt;&lt;BR /&gt;this is the extent of my understanding, and I wonder if someone could confirm I have done this correctly. &amp;nbsp;In addition, as the algorithm in AN3785 keeps everything in fixed point, I cannot see where lt1 (a 32-bit value) can be assigned C11 and this be correctly justified. &amp;nbsp;When I assign 0x0340 to the long I get&lt;BR /&gt;&lt;BR /&gt;lt1 &amp;nbsp; &amp;nbsp;0x00000340&lt;BR /&gt;= 0000 0000 0000 0000 0000 0011 010x xxxx&lt;BR /&gt;&lt;BR /&gt;so you can see I am not correctly aligned as per the bit-width specifications. &amp;nbsp;The following is the code snippet. &amp;nbsp;The comments make no sense to me, so any clarification you could prrovide would be most helpful&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;//******* STEP 1 c11x1= c11 * Padc&lt;BR /&gt;&amp;nbsp;lt1 = (S32)sic11; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// s(16,27) &amp;nbsp; &amp;nbsp;s(N,F+zeropad) goes from s(11,10)+11ZeroPad = s(11,22) =&amp;gt; Left Justified = s(16,27)&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;-Bill&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2026 21:47:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214595#M136</guid>
      <dc:creator>BillTheBiker</dc:creator>
      <dc:date>2026-02-03T21:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214596#M137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anyone other then "Billthe Biker" tried to use the MPL115A eval boards. My board&amp;nbsp;is&amp;nbsp;an i2c version and I can talk to it but it doesn't want to read any data out. It just hangs and locks up the computer.&lt;/P&gt;&lt;P&gt;Anyone have any idea? I read Bill's posting about the problems with the math and I am concerned if I get thru the hardware issues then I will be faced with math issues. Did I buy a pig here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reading the manual shows a number of issues which one has to wonder if Freescale has made it work. Any replies would be appreciated. (I hope there are more the what Bill has received)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Dec 2009 04:33:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214596#M137</guid>
      <dc:creator>lrf</dc:creator>
      <dc:date>2009-12-30T04:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214597#M138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I have the I2C version and can read the data from it using both a PIC micro and a NIOS soft CPU, what&amp;nbsp;I can't do is get the coeficients to work &lt;IMG alt="Smiley Sad" class="emoticon emoticon-smileysad" id="smileysad" src="https://community.nxp.com/i/smilies/16x16_smiley-sad.png" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I use (you will&amp;nbsp;need your own I2C start/stop/read/write functions)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;void Measure_ambient_presure(void) { unsigned char x; unsigned char MPL115A2_data[16]; printf(";Read MPL115A2\r"); i2c_start();           // I2C Bus Start condition i2c_write(MPL115A2_I2C_address);     // I2C bus Device address i2c_write(MPL115A2_start_both_conversion_command); // Command to Convert both Pressure and Temperature i2c_write(0x01); i2c_stop();           // I2C Bus Stop condition delay_ms(5);          // wait for A-D conversion to take place i2c_start();           // I2C Bus Start condition i2c_write(MPL115A2_I2C_address);     // I2C bus Device address i2c_write(0x00);         // address in MPL115A2 i2c_start();          // I2C Bus Start condition (a restart) i2c_write(MPL115A2_I2C_address|0x01);    // address in MPL115A2 + read bit MPL115A2_data[0]  = i2c_read(1);     // read with ACK MPL115A2_data[1]  = i2c_read(1);     // read with ACK MPL115A2_data[2]  = i2c_read(1);     // read with ACK MPL115A2_data[3]  = i2c_read(1);     // read with ACK MPL115A2_data[4]  = i2c_read(1);     // read with ACK MPL115A2_data[5]  = i2c_read(1);     // read with ACK MPL115A2_data[6]  = i2c_read(1);     // read with ACK MPL115A2_data[7]  = i2c_read(1);     // read with ACK MPL115A2_data[8]  = i2c_read(1);     // read with ACK MPL115A2_data[9]  = i2c_read(1);     // read with ACK MPL115A2_data[10] = i2c_read(1);     // read with ACK MPL115A2_data[11] = i2c_read(1);     // read with ACK MPL115A2_data[12] = i2c_read(1);     // read with ACK MPL115A2_data[13] = i2c_read(1);     // read with ACK MPL115A2_data[14] = i2c_read(1);     // read with ACK MPL115A2_data[15] = i2c_read(0);     // read with noACK i2c_stop();           // I2C Bus Stop condition  printf(";MPL115A2 Data= "); for (x=0;x&amp;lt;16;x++)  {  printf("%02X ",MPL115A2_data[x]);  } printf("\r"); }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Here is some sample data&amp;nbsp;I get from it.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;;MPL115A2 Data= 64 C0 75 80 3D 9B B9 4A C7 46 32 BC 02 20 FD 60&lt;BR /&gt;;MPL115A2 Data= 65 00 76 80 3D 9B B9 4A C7 46 32 BC 02 20 FD 60&lt;BR /&gt;;MPL115A2 Data= 65 40 76 80 3D 9B B9 4A C7 46 32 BC 02 20 FD 60&lt;BR /&gt;;MPL115A2 Data= 65 00 76 C0 3D 9B B9 4A C7 46 32 BC 02 20 FD 60&lt;BR /&gt;;MPL115A2 Data= 65 80 75 C0 3D 9B B9 4A C7 46 32 BC 02 20 FD 60&lt;BR /&gt;;MPL115A2 Data= 65 00 75 40 3D 9B B9 4A C7 46 32 BC 02 20 FD 60&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards, Mark Leman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 12:57:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214597#M138</guid>
      <dc:creator>markleman</dc:creator>
      <dc:date>2020-11-02T12:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214598#M139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bill,&lt;/P&gt;&lt;P&gt;Did you ever resolve this?&lt;/P&gt;&lt;P&gt;Regards, Mark Leman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Apr 2010 23:05:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214598#M139</guid>
      <dc:creator>markleman</dc:creator>
      <dc:date>2010-04-15T23:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214599#M140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;markleman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying unsuccessfully for two days to start a new pressure and temp conversion with no avail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In AN3785, under the 'Write Mode' header, it shows the commands&amp;nbsp;and gives examples of how to write the 'start both conversions'&amp;nbsp;byte string&amp;nbsp;which shows as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Start bit&lt;/P&gt;&lt;P&gt;Slave address (0x60)&lt;/P&gt;&lt;P&gt;Ack&lt;/P&gt;&lt;P&gt;Start both conversions (0x12)&lt;/P&gt;&lt;P&gt;Ack&lt;/P&gt;&lt;P&gt;Stop bit&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But&amp;nbsp;under the 'I2C Simplified' heading it show to&amp;nbsp;write an additional byte of 0x01 after the&amp;nbsp;0x12 byte and you also have it your code. I added it and now it works, Do you know what is the 0x01 for? It's not documented anywhere in the sheet except in the 'I2C Simplified' header unless I'm not seeing it somewhere else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Robert&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Apr 2010 06:30:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214599#M140</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2010-04-29T06:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214600#M141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also use MPL115A but in SPI, I can read Temperature, pressure and coeffcicient whihout problem&lt;/P&gt;&lt;P&gt;but I'm not sure how to convert 10bit data receive in KPa or Celsuis degree&lt;/P&gt;&lt;P&gt;For example :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get MSB pressure 0x5B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LSB&amp;nbsp; pressure 0xC0&lt;/P&gt;&lt;P&gt;I do this : 0x5BC0 &amp;gt;&amp;gt;6 then&amp;nbsp; Pka = (65/1023)*Padc + 50&lt;/P&gt;&lt;P&gt;but I obtain 73KPa and I'm not at 2500 meters&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do you get the correct result ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jun 2010 16:20:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214600#M141</guid>
      <dc:creator>sofie</dc:creator>
      <dc:date>2010-06-09T16:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214601#M142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Getting to the pressure is a multistep process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First you need to read the pressureADC and the temperatureADC.&amp;nbsp; Both of these are 2 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pressureADC= (pressureMSB&amp;lt;&amp;lt;8+pressureLSB)&amp;gt;&amp;gt;6;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;temperatureADC=(tempMSB&amp;lt;&amp;lt;8+tempLSB)&amp;gt;&amp;gt;6;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next you need to use those 2 ADC values along with all the coefficients to calculate the pressure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pressure= AO+(B1+C11*pressureADC+C12*temperatureADC)*pressureADC+(B2+C22*temperatureADC)*temperatureADC)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;finally you make another correction&lt;/P&gt;&lt;P&gt;pressureC=(65/1023*pressure)+50;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That finally gives you a temperature compensated pressure in mBar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The hardest thing I found was getting the coefficients to be read in correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jun 2010 23:20:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214601#M142</guid>
      <dc:creator>PJH</dc:creator>
      <dc:date>2010-06-23T23:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214602#M143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just managed to read something from the sensor. First of all, the coeffs C11 and C22 are all zero. Coeffs are like this (coeff1 coeff2 ... coeff12):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3E 98 B3 D2 C2 24 38 E0 00 00 00 00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And when I calculate the real pressure (pressure adc = 5C80, temp adc = 7F40) it says 918 hPa which cannot be correct since I'm at 25 m above sea level and pressure at sea level should be 1008 hPa. &amp;nbsp;It's very weird that C11 and C22 are all zero. Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Sep 2010 18:47:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214602#M143</guid>
      <dc:creator>pmatil</dc:creator>
      <dc:date>2010-09-24T18:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214603#M144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The coefficients are not all the same size,but are packed into a 12 bytes (96 bits) in registers x04 to x0F. The coeffs are really floating point numbers but the decimal point is in a different place in each number and some are negative etc.&amp;nbsp; So since I was unable to get the sample code to work due possibly to the byte endian nature of the data I wrote a function that can convert the bytes to the doubles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First here is the code to download the coeffs.&amp;nbsp; Obviously the implementation of the I2C is left to the reader.&lt;FONT face="courier new,courier"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;void CMPL115A:&lt;IMG alt=":smileyvery-happy:" class="emoticon emoticon-smileyvery-happy" id="smileyvery-happy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-very-happy.gif" title="Smiley Very Happy" /&gt;ownloadCoeffs()&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int err=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int resultL,resultH;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;BYTE data;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;iA0=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;iB1=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;iB2=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;iC11=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;iC12=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;iC22=0;&lt;BR /&gt;&lt;BR /&gt;// Get A0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;err=m_I2C.ModuleReadByte(BAROMETER,0x05,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(err==ERROR_SUCCESS) // Then we probably have a device connected. so assume rest of calls will succeed.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultL=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x04,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultH=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;iA0=(resultH&amp;lt;&amp;lt;8)+(resultL&amp;amp;0x00FF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;dA0=ConvertCoeffToDouble(iA0,16,12,3,0);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Get B1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x07,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultL=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x06,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultH=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;iB1=(resultH&amp;lt;&amp;lt;8)+(resultL&amp;amp;0x00FF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;dB1=ConvertCoeffToDouble(iB1,16,2,13,0);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Get B2&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x09,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultL=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x08,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultH=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;iB2=(resultH&amp;lt;&amp;lt;8)+(resultL&amp;amp;0x00FF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;dB2=ConvertCoeffToDouble(iB2,16,1,14,0);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Get C12&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x0B,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultL=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x0A,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultH=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;iC12=(resultH&amp;lt;&amp;lt;8)+(resultL&amp;amp;0x00FF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;dC12=ConvertCoeffToDouble(iC12,14,0,13,9);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Get C11&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x0D,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultL=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x0C,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultH=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;iC11=(resultH&amp;lt;&amp;lt;8)+(resultL&amp;amp;0x00FF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;dC11=ConvertCoeffToDouble(iC11,11,0,10,11);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Get C22&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x0F,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultL=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_I2C.ModuleReadByte(BAROMETER,0x0E,&amp;amp;data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;resultH=INT8(data);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;iC22=(resultH&amp;lt;&amp;lt;8)+(resultL&amp;amp;0x00FF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;dC22=ConvertCoeffToDouble(iC22,11,0,10,15);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_InitSuccess=true;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_InitSuccess=false;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;and the here is the ConvertCoeffToDouble which takes the 2byte word and then parameters which describe the number of bits, integer bits, fractional bits and padbits. There may be more efficient ways to do this, but since it only has to be done once when the device is initialized it is not critical to optimize.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;double ConvertCoeffToDouble(INT16 coeff,short bitCount,short iBits, short fracBits, short padBits)&lt;BR /&gt;{&lt;BR /&gt;// Utility function to convert the coeff's into floating point parameters.&lt;BR /&gt;// See Freescale App note AN3785 for details of how the parameters are stored.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;double result=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;bool s=false;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;bool bit;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int fb=0;&lt;BR /&gt;&lt;BR /&gt;// We start working our way through the bits from high to low.&lt;BR /&gt;// The incoming data is a 16bit integer which we have to shorten since the lower LSB's are empty if &amp;lt;16 bits. (see pg 15 of AN3785).&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (bitCount&amp;lt;16)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{// Make coeff the appropriate size&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;coeff=coeff&amp;gt;&amp;gt;(16-bitCount);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&lt;BR /&gt;// Sanity check that the parameters passed into the function make sense. We can't have more or less bits than the amount of data.&lt;BR /&gt;// Add 1 to account for sign bit.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if((iBits+fracBits+1)!=bitCount)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;TRACE(_T("Error in parameters!!\n"));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;//Sanity check that if we are padding the decimal point that we can't also have integer bits.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if((padBits&amp;gt;0)&amp;amp;&amp;amp;(iBits&amp;gt;0))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;TRACE(_T("Error in parameters. iBits and padBits not consistent!!\n"));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int b=bitCount;b&amp;gt;0;b--)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;bit=bool((int(pow(2.0,b-1))&amp;amp; coeff)&amp;gt;&amp;gt;(b-1)); // Get each bit in turn as a 1 or a 0.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (b==bitCount) // if this is the first bit (sign bit check if it is set)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;s=bit;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(s)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;coeff=~coeff+1; //Calculate 2's complement; //(See App note AN3785 middle of Pg15 for explanation.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else // process the bits in turn.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(iBits&amp;gt;0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{ // we have an integer bit;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(bit)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;result+=pow(2.0,iBits-1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;iBits--;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else // we have a fractional bit&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fb++;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(bit)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;result+= (1/pow(2.0,fb+padBits));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;fracBits--;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(s)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;result*=-1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;TRACE(_T("Result=%f\n"),result);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return result;&lt;BR /&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Only after you have converted all the coefficients to the correct&amp;nbsp; sign, significant digits etc, does the thing start to make sense and read correctly.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Peter&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Sep 2010 19:36:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214603#M144</guid>
      <dc:creator>PJH</dc:creator>
      <dc:date>2010-09-24T19:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214604#M145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks PJH but I believe I have converted them correctly. Or have I? At the moment the result Pcomp is 1067 which cannot be right since it should be in between 0 and 1023. Converted coeffs are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a0 = 2003&lt;/P&gt;&lt;P&gt;b1 = -2.3118&lt;/P&gt;&lt;P&gt;b2 = -0.15836&lt;/P&gt;&lt;P&gt;c12 = 1.456E-10&lt;/P&gt;&lt;P&gt;c11 = 0&lt;/P&gt;&lt;P&gt;c12 = 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Padc = 370&lt;/P&gt;&lt;P&gt;Tadc = 509&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Sep 2010 12:34:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214604#M145</guid>
      <dc:creator>pmatil</dc:creator>
      <dc:date>2010-09-27T12:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214605#M146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume you mean C22 for your last coefficient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On one of my systems I got&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A0=2156.625000&lt;BR /&gt;B1=-2.528809&lt;BR /&gt;B2=-1.034241&lt;BR /&gt;C12=0.000876&lt;BR /&gt;C11=0.000000&lt;BR /&gt;C22=0.000000&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;pressureADC 420&lt;BR /&gt;tempADC 419&lt;BR /&gt;&lt;BR /&gt;result 101.802 kPa.&amp;nbsp; So that comes out at 1018.02 mBar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the&amp;nbsp; values it seems that the one which is likely to be wrong is C12. Your number is much smaller than what I get.&amp;nbsp; If you put my numbers into your calculation function do you get the same result as I did?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also check the decimial point position in B2 your number is a factor of 10 smaller than mine.&lt;/P&gt;&lt;P&gt;Don't forget too that you have to scale the pComp value.&amp;nbsp; The output is 0-1023 which is for a scale of 50kPa to 115kPa. So range is 65kPa in 1023 steps. Final pressure = (65/1023*pComp)+50&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Sep 2010 20:00:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214605#M146</guid>
      <dc:creator>PJH</dc:creator>
      <dc:date>2010-09-27T20:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214606#M147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I meant C22. I calculated the pressure using your values and got the same result as you. And I think I finally realized what I did wrong. I looked at the first post of this thread and converted the coeffs following that as an example. So C12 is S0.0000000001110001110000 -&amp;gt; 2^-10 + 2^-11 + 2^-12 + 2^-16 + 2^-17 + 2^-18 = 0.0017281. But the sign bit is 1 (0x38E0). Should I invert the 13 fractional bits and add 1 to get the real result? And for the B2 it's probably the same error. Thanks for your help PJH!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Sep 2010 18:46:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214606#M147</guid>
      <dc:creator>pmatil</dc:creator>
      <dc:date>2010-09-28T18:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214607#M148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can anyone tell me how to convert the uiTADC number to c or F? I'm getting around a 523. What is the conversion factor?&lt;/P&gt;&lt;P&gt;Thansk&lt;/P&gt;&lt;P&gt;Ringo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2010 09:40:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214607#M148</guid>
      <dc:creator>ringo42</dc:creator>
      <dc:date>2010-10-07T09:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214608#M149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What kind of accuracy/repeatability is anyone getting? Mine is bouncing all over the place.&lt;/P&gt;&lt;P&gt;Alt feet: 149&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;Alt feet:&amp;nbsp; 97&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;Alt feet:&amp;nbsp; 97&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;Alt feet:&amp;nbsp; 45&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 45&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;Alt feet:&amp;nbsp; 97&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 97&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 97&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 97&lt;BR /&gt;Alt feet:&amp;nbsp; 45&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;Alt feet: 109&lt;BR /&gt;Alt feet:&amp;nbsp; 97&lt;BR /&gt;Alt feet:&amp;nbsp; 57&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2010 10:04:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214608#M149</guid>
      <dc:creator>ringo42</dc:creator>
      <dc:date>2010-10-07T10:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214609#M150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ringo,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Here are answers to your 2 questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The temperature ADC does not have a direct conversion to an actual temperature. You could always try and vary the ambient temperature of the sensor and see what the ADC value is over a range of temperatures. Then you might be able to figure out a conversion factor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. The final pressure reading is noisy and thus any conversion of that value to an altitude will also be noisy.&amp;nbsp; Typically the pressure varies quite slowly so the best approach is to take multiple readings and have a running average of the last measurements so that noise is averaged out.&amp;nbsp; For our application we take measurements every second and average over the last 100 seconds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2010 19:21:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214609#M150</guid>
      <dc:creator>PJH</dc:creator>
      <dc:date>2010-10-07T19:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214610#M151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a problem with the MPL115A2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The coef data are:&lt;/P&gt;&lt;P&gt;3a 4d ba cc bf a6 31 78 00 00 00 00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Padc = 990&lt;/P&gt;&lt;P&gt;Tadc = 523&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I calculate:&lt;/P&gt;&lt;P&gt;a0 = 1865.63&lt;/P&gt;&lt;P&gt;b1 = -2.16&lt;/P&gt;&lt;P&gt;b2 = -1.01&lt;/P&gt;&lt;P&gt;c12 = 0.00075&lt;/P&gt;&lt;P&gt;c11 = 0&lt;/P&gt;&lt;P&gt;c22 = 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pcomp = -411 (negative!!!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thank !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nicola (Italy)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Oct 2010 00:15:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214610#M151</guid>
      <dc:creator>Mommmo</dc:creator>
      <dc:date>2010-10-09T00:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214611#M152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've the same problem as other users of the MPL115A2 programming...&lt;/P&gt;&lt;P&gt;I can read the data from the registers, however, to get the real pressure and temperature is a long way to go from there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ok, here's my problems and wishing someone can help me, the following are the data I read from the registers $00 to $0f&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5a c0 75 c0 39 e3 b9 7a ca 7b 32 cc 00 00 00 00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please, anyone can help me to decipher the mystery of the above data - I know the first four bytes are the Padc and Tadc value, then the a0-msb, a0-lsb, b1.....c22 etc, however, I don't know how to convert these No. into floating point notation - actually I can't find any 'Freescale' document mention about it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 16:55:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214611#M152</guid>
      <dc:creator>MPL115A2</dc:creator>
      <dc:date>2010-10-12T16:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214612#M153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It has been a long time since I worked with this component but I can tell you it works fine once you get the math correct. I found that the equations given in the manual are in correct. Unfortunately I don't remember exactly what the issue was so I went back thru my code looking for differences. The following is the only difference I can find:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The manual says:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT size="2"&gt;siPcomp = ((S16)lt3&amp;gt;&amp;gt;13);&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT size="2"&gt;Change this to this:&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;siPcomp = ((S16)(lt3&amp;gt;&amp;gt;13));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hope this helps&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 18:31:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214612#M153</guid>
      <dc:creator>lrf</dc:creator>
      <dc:date>2010-10-12T18:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214613#M154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;irf,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'It has been a long time since I worked with this component but I can tell you it works fine once you get the math correct...'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is I can't get the math correct, I need your help, would you please explain how to convert the coef' value into floating point number in plain english, not c programming notation.&lt;/P&gt;&lt;P&gt;eg, the numbers I read from the registers of $00 - $0f are:&lt;/P&gt;&lt;P&gt;5a c0 75 c0 39 e3 b9 7a ca 7b 32 cc 00 00 00 00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks your help.&lt;/P&gt;&lt;P&gt;cw.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 05:52:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214613#M154</guid>
      <dc:creator>MPL115A2</dc:creator>
      <dc:date>2010-10-13T05:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: MPL115A fixed point question</title>
      <link>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214614#M155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just don't know why the hell 'Freescale' made this device so confused with all the coeficients compensation calculation and not do it internally!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 10:16:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MPL115A-fixed-point-question/m-p/214614#M155</guid>
      <dc:creator>MPL115A2</dc:creator>
      <dc:date>2010-10-13T10:16:50Z</dc:date>
    </item>
  </channel>
</rss>

