<?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のトピックPatch for magnetometer chip dependent calibration problem caused by geometry of magnetometer measurements</title>
    <link>https://community.nxp.com/t5/Sensors/Patch-for-magnetometer-chip-dependent-calibration-problem-caused/m-p/730303#M4707</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear reader,&lt;BR /&gt;I noticed that the magnetometer calibration of the sensor fusion algorithm (version 7.10) gave inconsistent results after startup, when repeated a few times. I dug into the code and found the magnetometer calibration procedure is sensor chip dependent. For my sensor, the magnetometer buffer containing the measurements used for the calibration filled too quickly. This caused the geometry of magnetometer measurements to be constricted, resulting in an incorrect fit, with a good fix measure.&lt;/P&gt;&lt;P&gt;I propose the following patch, that makes the procedure sensor chip independent. &lt;BR /&gt;In &lt;EM&gt;magnetic.h&lt;/EM&gt;:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="number token"&gt;59&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; #define MESHDELTACOUNTS &lt;SPAN class="number token"&gt;50&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; magnetic buffer mesh spacing in counts (here 5uT)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;59&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; #define MESHDELTACOUNTS &lt;SPAN class="number token"&gt;5.0F&lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;//50 ///&amp;lt; magnetic buffer mesh spacing in uT‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;‍And in &lt;EM&gt;magnetic.c&lt;/EM&gt;:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="number token"&gt;230&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; MESHDELTACOUNTS&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;230&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;MESHDELTACOUNTS&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;pthisMag&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;fCountsPeruT&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;268&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; MESHDELTACOUNTS&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;268&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;MESHDELTACOUNTS&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;pthisMag&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;fCountsPeruT&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In addition, I noticed that in comments of the algorithm it was noted that the magnetic field strength should be between 22 and 67 uT, however in &lt;EM&gt;magnetic.h&lt;/EM&gt; the minimum and maximum were defined as 10 and 90 uT. I propose to change the following:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="number token"&gt;56&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; #define MINBFITUT &lt;SPAN class="number token"&gt;10.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; minimum acceptable geomagnetic field B (uT) for valid calibration&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;57&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; #define MAXBFITUT &lt;SPAN class="number token"&gt;90.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; maximum acceptable geomagnetic field B (uT) for valid calibration&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;56&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; #define MINBFITUT &lt;SPAN class="number token"&gt;22.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; minimum acceptable geomagnetic field B (uT) for valid calibration&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;57&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; #define MAXBFITUT &lt;SPAN class="number token"&gt;67.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; maximum acceptable geomagnetic field B (uT) for valid calibration‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;‍&lt;/P&gt;&lt;P&gt;Hopefully someone from NXP can confirm that these patches are correct.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Wouter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2026 22:33:44 GMT</pubDate>
    <dc:creator>woutervos</dc:creator>
    <dc:date>2026-02-03T22:33:44Z</dc:date>
    <item>
      <title>Patch for magnetometer chip dependent calibration problem caused by geometry of magnetometer measurements</title>
      <link>https://community.nxp.com/t5/Sensors/Patch-for-magnetometer-chip-dependent-calibration-problem-caused/m-p/730303#M4707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear reader,&lt;BR /&gt;I noticed that the magnetometer calibration of the sensor fusion algorithm (version 7.10) gave inconsistent results after startup, when repeated a few times. I dug into the code and found the magnetometer calibration procedure is sensor chip dependent. For my sensor, the magnetometer buffer containing the measurements used for the calibration filled too quickly. This caused the geometry of magnetometer measurements to be constricted, resulting in an incorrect fit, with a good fix measure.&lt;/P&gt;&lt;P&gt;I propose the following patch, that makes the procedure sensor chip independent. &lt;BR /&gt;In &lt;EM&gt;magnetic.h&lt;/EM&gt;:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="number token"&gt;59&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; #define MESHDELTACOUNTS &lt;SPAN class="number token"&gt;50&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; magnetic buffer mesh spacing in counts (here 5uT)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;59&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; #define MESHDELTACOUNTS &lt;SPAN class="number token"&gt;5.0F&lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;//50 ///&amp;lt; magnetic buffer mesh spacing in uT‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;‍And in &lt;EM&gt;magnetic.c&lt;/EM&gt;:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="number token"&gt;230&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; MESHDELTACOUNTS&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;230&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;MESHDELTACOUNTS&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;pthisMag&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;fCountsPeruT&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;268&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; MESHDELTACOUNTS&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;268&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idelta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;MESHDELTACOUNTS&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;pthisMag&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;fCountsPeruT&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In addition, I noticed that in comments of the algorithm it was noted that the magnetic field strength should be between 22 and 67 uT, however in &lt;EM&gt;magnetic.h&lt;/EM&gt; the minimum and maximum were defined as 10 and 90 uT. I propose to change the following:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="number token"&gt;56&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; #define MINBFITUT &lt;SPAN class="number token"&gt;10.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; minimum acceptable geomagnetic field B (uT) for valid calibration&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;57&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; #define MAXBFITUT &lt;SPAN class="number token"&gt;90.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; maximum acceptable geomagnetic field B (uT) for valid calibration&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;56&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; #define MINBFITUT &lt;SPAN class="number token"&gt;22.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; minimum acceptable geomagnetic field B (uT) for valid calibration&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;57&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; #define MAXBFITUT &lt;SPAN class="number token"&gt;67.0F&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;///&amp;lt; maximum acceptable geomagnetic field B (uT) for valid calibration‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;‍&lt;/P&gt;&lt;P&gt;Hopefully someone from NXP can confirm that these patches are correct.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Wouter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2026 22:33:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/Patch-for-magnetometer-chip-dependent-calibration-problem-caused/m-p/730303#M4707</guid>
      <dc:creator>woutervos</dc:creator>
      <dc:date>2026-02-03T22:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Patch for magnetometer chip dependent calibration problem caused by geometry of magnetometer measurements</title>
      <link>https://community.nxp.com/t5/Sensors/Patch-for-magnetometer-chip-dependent-calibration-problem-caused/m-p/730304#M4708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wouter,&lt;/P&gt;&lt;P&gt;I'm always pleased to see people digging into the code.&amp;nbsp; I'll add this to my list of things to review for future releases.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2017 16:49:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/Patch-for-magnetometer-chip-dependent-calibration-problem-caused/m-p/730304#M4708</guid>
      <dc:creator>michaelestanley</dc:creator>
      <dc:date>2017-10-30T16:49:07Z</dc:date>
    </item>
  </channel>
</rss>

