**Somehow i feel like this thread going to help people like me so i will try to share the things i found as much as possible. Please feel free to comment . I need all kinds of perspectives **
Ps: Since I am editing my topic constantly it is growing big but it has lots of information in it. As a non native English speaker it took my days . So please if there are some things against the forum rules let me know first. I will quickly fix it.
If i am to specify my objective for better understanding of the issue here it is ;
I am trying to make a rotation alert mechanism using mpu6050 inertial sensor . if there is certain amount of rotation occurs the led on the arduino turns on . Seems Very simple , very easy ...
However I am struggling for 2 weeks because i need certain degree of precision for my application .
I am using jeffs DMP code I can succesfully run "Teapot" example . And control 3D objects with mpu6050.
But i noticed something odd while i was debugging...
I saw that if i precisely rotate my mpu module 30 degrees and save that quaterion data ; and try to rotate 30 degree in the same direction again the two recordings were not mathing to each other.
I also noticed that when i only rotate arround y axis ; also x axis values are changing ....
Thats werent supposed to happen because in DMP code we are converting "quaternions" to "axis angle " values. So if i rotate arround x, it should just effect x values. Right? Am i missing something big here?
What do you think about it? What might be causing this ?
In here below are my belowed findings about this problem . I searched all internet. Every bit of information i stumble upon is here .And I am still digging .So please if you have any other informations about this share in this topic.
Edit 12 : This one outlines all the issues nicely , so make sure click the link and read all answers.
gyroscope - MPU-6050 - angle drift - Arduino Stack Exchange
T
Edit 11 : can we fuse magnetomer with dmp code ?
According to MPU-6050 6-axis accelerometer/gyroscope | I2C Device Library, " the DMP cannot produce fully fused 9-axis orientation data without some external computation done on the host processor. The DMP does not have the processing power necessry to do compute 9-axis fused data, even if the magnetometer is connected and properly configured as a slave device on the MPU-6050's AUX SDA/SCL lines." Hope you've already considered that!
Edit 10: Another question and another answer with use of magnetometer. Now how shall we calibrate magnetomer ....
The easiest way would be to add magnetometer support to this example. Algorithm is already there, you need to call method imu.getMotion9 and pass magnetometer values to it. Here is the tricky part - magnetometer axis are different from accelerometer and gyroscope, so you would need to rotate magnetometer values before passing them to match others. Take a look79 how they are placed relative to each other (page 38). Magnetometer calibration is another important step, there are different ways to do it, search for hard and soft iron calibration.
http://www.invensense.com/mems/gyro/documents/PS-MPU-9250A-01.pdfand there is a lot of stuff about calibrating magnetometer..
Yaw value keeps decreasing? - #5 by larssoltmann - Hardware - Emlid Community Forum
Edit 9:
Correct. By far the best fusion algorithm for Arduino is RTIMUlib. Highly recommended!
There are more recent forks of that deposition, so look around for improved versions.
Edit 8: maybe thats all i need is a referance for yaw?
absolute yaw angle is not defined for that sensor. In order to determine yaw, you need a magnetometer to act as a North reference.
Edit 7 : dmp vs complimentary filter ..
Qualitatively, however, I can say that for pitch (rotation about the X-axis) and roll (rotation about the Y-axis), the calculations are fairly close, but the complementary filter seems to consistently lag the DMP. The DMP algorithm is able to calculate yaw, which the complementary filter cannot. I suspect that when the algorithms differ, the DMP is more accurate, however it is possible that a better implementation of the complementary filter might be able to reduce some of the lag.
Edit 6: there is this code and this is not effecting from yaw values but after 75 degree it gets crosstalk
between roll and pitch values. Very good code tho.
Edit 5: yaw and pitch vales changing together might be inevitable without a filter algoritm?
Yes, you will see this kind of cross talk when you are not feeding the
Madgwick filter the sensor data properly. It expects the data in a NED
format.
Edit 4 :Might be hardware related..?
The MPU-6050 is outdated and the modules on Ebay could have a wrong capacitor making it even more noisier. Can you give a reference for those formulas ? Without reference I have a lot of doubts. Looking at the code, I even have doubts about the 4ms delay. Your loop is probably more slowed down by the full output buffer of Serial than by micros(). I strongly suggest to use a library and you might consider to buy a MPU-9250. Are you perhaps using a 5V Arduino without I2C level shifter ?
Edit 3: Offsets are more important than you think ...!!
Offsets are usually necesary to run DMP, if not its measures fluctuate. It is not a startup thing, it will not work if offsets are very different from what should be.
Faster way maybe is to read raw values from sensors, and change offsets iteratively until you get that raw measures from every gyro and Xaccel and Yaccel are 0, and Zaccel is 16384. Then use those offsets with DMP
Edit 2: Some information about limitations . Does not apply to my problem but good to know if you are shaking your mpu and wondering what went wrong
Bad Fast rotation effect for Arduimu, MPU6050, 9150, 9250 - Discussions - diydrones
Best AHRS algorithm available for a moving application - Discussions - diydrones
might be usefull if you have same problem as me . Simply they are saying that there is a threshold for measuring rotation over time. İf ypu were to cross it you will lose data and wont able to return zero values . thats 2000 degree per second. But in my case i move my mpu slowly and still i have my issues
Edit 1: i found this topic but not much of a use ...
Edit 0 : about multiplying with 180 to get real angles...
At the same time I discovered this problem, I also realized that converting from radians to degrees was unnecessary, as the gyro output was already in units of degrees (just scaled by a sensitivity factor). After that big face-palm, I revised my rate formula to the following: rollRate = (0.7 * rollRate) + (-0.3 * gx / 16.4);. You will notice the scale factor has changed from 131 to 16.4. That is because the gyro range is actually +/-2000 deg/s by default, not 250 deg/s. I
Edit -1 : can i filter dmp data with kalman ?
The DMP data from the MPU6050 is already filtered, and while I have not expirimented with the DMP data much myself I believe it is pretty clean. If there is a calibration process you can do to improve it, that is probably worth expirimenting with, but you should not filter the values a second time.