<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2009-04-20:105601</id>
  <title>Busy hands | Disquiet mind</title>
  <subtitle>Craft and Tech Notebook</subtitle>
  <author>
    <name>chebe</name>
  </author>
  <link rel="alternate" type="text/html" href="https://chebe.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://chebe.dreamwidth.org/data/atom"/>
  <updated>2025-03-19T14:40:57Z</updated>
  <dw:journal username="chebe" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2009-04-20:105601:160808</id>
    <link rel="alternate" type="text/html" href="https://chebe.dreamwidth.org/160808.html"/>
    <link rel="self" type="text/xml" href="https://chebe.dreamwidth.org/data/atom/?itemid=160808"/>
    <title>MPU-6050 Arduino libraries code archaeology</title>
    <published>2025-03-19T12:36:48Z</published>
    <updated>2025-03-19T14:40:57Z</updated>
    <category term="code"/>
    <category term="arduino"/>
    <category term="accelerometer"/>
    <category term="maths"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">Compare and contrast getting normalized accelerometer values, where the raw value is -13248.00. (A.k.a. Please, make it make sense.)&lt;br /&gt;&lt;br /&gt;Library 1; jarzebski's Arduino-MPU6050 - &lt;a href="https://github.com/jarzebski/Arduino-MPU6050/"&gt;https://github.com/jarzebski/Arduino-MPU6050/&lt;/a&gt;&lt;br /&gt;Library 2; Adafruit's Adafruit_MPU6050 - &lt;a href="https://github.com/adafruit/Adafruit_MPU6050"&gt;https://github.com/adafruit/Adafruit_MPU6050&lt;/a&gt;&lt;br /&gt;Library 3; i2cdevlib/ElectronicCats' mpu6050 - &lt;a href="https://github.com/ElectronicCats/mpu6050"&gt;https://github.com/ElectronicCats/mpu6050&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Library 1;&lt;/h3&gt;&lt;br /&gt;&lt;span class="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___1" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://chebe.dreamwidth.org/160808.html#cutid1"&gt;code&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___1" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Formula for normalized acceleration value at MPU6050_RANGE_2G;&lt;br /&gt;raw * rangePerDigit  * gravityConst&lt;br /&gt;(raw * (1.0/16384)) * gravityConst&lt;br /&gt;== (raw / 16384) * gravityConst&lt;br /&gt;(-13248.00 * .000061) * 9.80665 = -7.92502845&lt;br /&gt;== (-13248.00 / 16384) * 9.80665 = -7.92959589&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Library 2;&lt;/h3&gt;&lt;br /&gt;&lt;span class="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___2" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://chebe.dreamwidth.org/160808.html#cutid2"&gt;code&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___2" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Formula for normalized acceleration value at MPU6050_RANGE_2_G;&lt;br /&gt;(raw / accel_scale) * gravityConst&lt;br /&gt;(-13248.00 / 16384) * 9.80665 = -7.92959589&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Library 3;&lt;/h3&gt;&lt;br /&gt;&lt;span class="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___3" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://chebe.dreamwidth.org/160808.html#cutid3"&gt;code&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___3" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;No normalized functions in MPU6050.cpp. Can use MotionApps files, but they go through Quaternions.&lt;br /&gt;&lt;span class="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___4" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://chebe.dreamwidth.org/160808.html#cutid4"&gt;code&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___4" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Formula for normalized acceleration value at MPU6050_ACCEL_FS_2;&lt;br /&gt;// jarzebski way;&lt;br /&gt;raw * accelerationResolution * gravityConst&lt;br /&gt;-13248.00 * 0.000122 * 9.80665 = -15.850057&lt;br /&gt;&lt;br /&gt;// adafruit way;&lt;br /&gt;// (raw * (1.0/16384)) * gravityConst&lt;br /&gt;// (raw * (2.0/16384)) * gravityConst&lt;br /&gt;(-13248.00 / (2.0*16384)) * 9.80665 = -15.85919&lt;br /&gt;((-13248.00*2.0) / 16384) * 9.80665 = -15.85919&lt;br /&gt;&lt;br /&gt;Result is twice that of the others. &lt;code&gt;accelerationResolution&lt;/code&gt; itself seems to be twice the others, so half it? Not sure if this is a mistake, or I'm missing something about MPU6050_ACCEL_FS_2 vs MPU6050_RANGE_2_G.&lt;br /&gt;raw * (accelerationResolution/2) * gravityConst&lt;br /&gt;-13248.00 * (accelerationResolution/2) * 9.80665 = -7.9250&lt;br /&gt;&lt;br /&gt;&lt;code&gt;accelerationResolution&lt;/code&gt; and &lt;code&gt;get_acce_resolution()&lt;/code&gt; only exist in the ElectronicCats version, they're not accessible in the &lt;a href="https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050"&gt;i2cdevlibs&lt;/a&gt; version. That version seems to &lt;strong&gt;really&lt;/strong&gt; want you to use the Quaternion path. But you can always use the range values from the other versions yourself on the raw values.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=chebe&amp;ditemid=160808" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
