<?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>There is a problem with the calculation of angles.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68117/there-is-a-problem-with-the-calculation-of-angles</link><description>Hello 
 I am trying to get the angle of the sensor using the value of mpu6050. 
 I used a formula to obtain an angle using sensor values. However, if I calculate this expression and print it out, the value will only be zero. 
 
 
 Can I know the problem</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Nov 2020 09:41:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68117/there-is-a-problem-with-the-calculation-of-angles" /><item><title>RE: There is a problem with the calculation of angles.</title><link>https://devzone.nordicsemi.com/thread/278946?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 09:41:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4fd98e9-e37d-4913-bdc9-dac546e4dbb5</guid><dc:creator>schosdas</dc:creator><description>&lt;p&gt;I don&amp;#39;t know the reason yet, but I&amp;#39;ve divided the formula little by little and it&amp;#39;s printed out properly.&lt;/p&gt;
&lt;p&gt;I think the angle value is being calculated slightly wrong, but I&amp;#39;ll try this part more.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    double accel_x = accel_values.x;
    double accel_y = accel_values.y;
    double accel_z = accel_values.z;
    
    double test1 = sqrt(pow(accel_x,2) + pow(accel_z, 2)); //OK
    double test2 = atan(accel_y / test1); //OK
    double test3 = test2 * RADIAN_TO_DEGREE; //OK
    printf(&amp;quot;Angle_X : %lf\n&amp;quot;, test3); 

    double test4 = sqrt(pow(accel_y,2) + pow(accel_z, 2)); //OK
    double test5 = atan(-accel_x / test4); //OK
    double test6 = test5 * RADIAN_TO_DEGREE; //OK
    printf(&amp;quot;Angle_Y : %lf\n&amp;quot;, test6); &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: There is a problem with the calculation of angles.</title><link>https://devzone.nordicsemi.com/thread/278935?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 08:59:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c10762bc-186f-4a72-847f-645cc3c9ea22</guid><dc:creator>Eugene Yu</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I would recommend you to debug out with breakpoints to figure out the actual reason.&lt;/p&gt;
&lt;p&gt;Without details, difficult to answer your question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>