<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Thingy 52: raw magnetometer data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81895/thingy-52-raw-magnetometer-data</link><description>I recently purchased a Thingy 52 with the goal of processing the the raw magnetometer, accelerometer and gyroscope data using a sensor fusion algorithm to determine orientation. One of my first goals is to determine the hard-iron offsets for the magnetometer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 24 Nov 2021 14:35:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81895/thingy-52-raw-magnetometer-data" /><item><title>RE: Thingy 52: raw magnetometer data</title><link>https://devzone.nordicsemi.com/thread/340577?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 14:35:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82c89440-c8e4-46da-b377-129d5eeaaadb</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;The MPU9250 motion sensor actually does do&lt;a href="https://github.com/NordicSemiconductor/Nordic-Thingy52-FW/blob/6ada0a9aed640141ab9f9e91b5f9f5ec0ed237e7/libs/eMD6/core/mpl/compass_vec_cal.h#L28"&gt; it&amp;#39;s own calibration&lt;/a&gt; which is the factory calibration and I wouldn&amp;#39;t suggest changing this. Because if this was not done, then you would get a lot of noise and the data that you obtain would be really distorted. The factory calibration is custom for every sensor.&lt;/p&gt;
&lt;p&gt;But, there are some internal compensations that are done and you could try changing the &lt;a href="https://github.com/NordicSemiconductor/Nordic-Thingy52-FW/blob/126120108879d5bf5d202c9d5cab65e4e9041f58/source/drivers/drv_motion.c#:~:text=/*%20Set%20the%20default,inv_set_compass_bias(COMPASS_BIAS%2C%201)%3B"&gt;COMPASS_BIAS&lt;/a&gt; values mentioned in the FW. There is also another option of &lt;a href="https://github.com/NordicSemiconductor/Nordic-Thingy52-FW/blob/126120108879d5bf5d202c9d5cab65e4e9041f58/source/drivers/drv_motion.c#:~:text=/*%20NOTE%3A%20If%20using,*/"&gt;creating your own library&amp;nbsp;&lt;/a&gt;&amp;nbsp;but that can be extremely complicated and I would suggest changing the COMPASS_BIAS values.&amp;nbsp;&lt;/p&gt;
[quote user="Peter Murphy"]By setting the magnetometer compensation interval and/or setting the motion processing unit frequency, I’ve reset some part of the MPU9250’s magnetometer calibration algorithm.[/quote]
&lt;p&gt;I am not sure of this, but as mentioned earlier, the MPU9250 does have an internal calibration being done which has nothing to do with the Thingy FW. And, the values that you set are run-time so each time you boot, it starts with the values that you have given.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, I would like to mention that the &lt;a href="https://invensense.tdk.com/products/motion-tracking/9-axis/mpu-9250/"&gt;MPU9250 is End Of Life&lt;/a&gt; and is not recommended for new designs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy 52: raw magnetometer data</title><link>https://devzone.nordicsemi.com/thread/340428?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 21:00:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb54671b-7a16-478d-98bd-b3bd9e93db39</guid><dc:creator>Peter Murphy</dc:creator><description>&lt;p&gt;&lt;span style="font-weight:400;"&gt;Hi Priyanka,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Thank you for the response.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;My testing suggests the raw magnetometer data made available through the &lt;/span&gt;&lt;i&gt;&lt;span style="font-weight:400;"&gt;Thingy 52&amp;rsquo;s BLE Service &amp;rarr; Motion service &amp;rarr; Raw data characteristic&lt;/span&gt;&lt;/i&gt;&lt;span style="font-weight:400;"&gt; (see &lt;/span&gt;&lt;a href="https://nordicsemiconductor.github.io/Nordic-Thingy52-FW/documentation/firmware_architecture.html#arch_config"&gt;&lt;span style="font-weight:400;"&gt;Thingy configuration service&lt;/span&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;) is actually the calibrated magnetometer data.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;I&amp;rsquo;ve attached a figure showing the magnetometer data read off the Thingy 52 using the above-referenced &amp;ldquo;Raw data characteristic&amp;rdquo;.&amp;nbsp; For this dataset I set the magnetometer compensation interval to 500ms and the motion processing unit frequency to 10Hz and then start sending read requests to the Thingy 52 over the BLE link using Matlab&amp;rsquo;s &lt;/span&gt;&lt;a href="https://www.mathworks.com/help/matlab/ref/ble.html"&gt;&lt;span style="font-weight:400;"&gt;ble&lt;/span&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt; service. The rate at which I can read the data is approximately 10Hz but most of the time the magnetometer values for the x, y and z directions is [0,0,0].&amp;nbsp; I have an if statement in my code which only saves the magnetometer values when the x, y and z values are not all zeros.&amp;nbsp; That&amp;rsquo;s what is plotted in the attached figure.&amp;nbsp; In addition, while reading the magnetometer data off the Thingy 52 I rotate the Thingy 52 around the x, y and z axes at 10 second intervals.&amp;nbsp; That is, for the first 10 seconds I rotate the Thingy 52 around its x axis, from 10 seconds to 20 seconds I rotate the Thingy 52 around its y axis, from 20 seconds to 30 seconds I rotate the Thingy 52 around its z axis.&amp;nbsp; I then repeat the process for time 30s to 60s.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;What you&amp;rsquo;ll notice is that at time 28 seconds all three magnetometer values abruptly change.&amp;nbsp; I&amp;rsquo;ve done this experiment many times and I consistently see this behavior.&amp;nbsp; In addition, my calculations reveal the data before 28 seconds is uncalibrated and the data after 28 seconds is the magnetometer data with hard-iron offset (biases) removed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Another experiment I&amp;rsquo;ve done is to set the magnetometer compensation interval to 500ms and the motion processing unit frequency to 10Hz and then spin the magnetometer around its x axis for 60 seconds.&amp;nbsp; In this case, the abrupt change never occurs.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;My working theory is the following:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li style="font-weight:400;"&gt;&lt;span style="font-weight:400;"&gt;By setting the magnetometer compensation interval and/or setting the motion processing unit frequency, I&amp;rsquo;ve reset some part of the MPU9250&amp;rsquo;s magnetometer calibration algorithm.&lt;/span&gt;&lt;/li&gt;
&lt;li style="font-weight:400;"&gt;&lt;span style="font-weight:400;"&gt;By rotating the magnetometer around its x, y and z axis sequentially the MPU9250&amp;rsquo;s internal magnetometer calibration algorithm is able to collect the data it needs to perform calibration.&lt;/span&gt;&lt;/li&gt;
&lt;li style="font-weight:400;"&gt;&lt;span style="font-weight:400;"&gt;At time 28 seconds the internal magnetic calibration algorithm is happy with what it has calculated and applies the results to the magnetometer data.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/mag_5F00_data_5F00_nov_5F00_23_5F00_2021.png" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy 52: raw magnetometer data</title><link>https://devzone.nordicsemi.com/thread/340401?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 15:31:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b7543d0-69f2-46e7-9fda-43f7c3489ee6</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;The &amp;quot;raw data characteristics&amp;quot; generally refers to raw data which is not calibrated in any way. As for the &amp;quot;compass compensation interval&amp;quot; mentioned in the product specification, I guess this is a feature of the sensor and is only relevant if you do compass functionality.&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>