I'm in process of making a quadcopter. At this point I encountered a problem with MPU-6050 angle calculation.
When quadcopter is stationary with motors in off state and I'm tilting it, angle readings in all 3 axis is good, but when motors are in on state, readings starts to jump all over the place and can even differ from real value by 20 degrees.
I assume this effect is due to mechanical vibrations caused by motors. I include pictures of quadcopter
and MPU-6050 board mounting
also a graphs of angle readings of MPU-6050 in X axis using Kalman filter, complementary filter and MPU-6050 DMP (Kalman and complementary filter implementations as well as processing code for graphs is from Kristian Lauszus GitHub https://github.com/Lauszus , DMP used with Jeff Rowberg library from https://github.com/jrowberg).
Recently I connected second MPU to different microcontroller, so it would not be connected electrically with a quadcopter and mounted MPU on board with two sponges from both sides of MPU. Results were pretty much the same. So now I really know that noise (at least majority of noise) isn't related with electrical switching noise from motors.
Maybe someone had similar issues and could help me.
I have just started playing with MPU-6050. Once I have draft program ready that at least displays MPU values I will try to put it on my Tarantula X6 drone to see if result is same. Tarantula has similar brushed motors as you drone has.
Your values are from gyro?
What was result when you second MPU was not mounted on the board? I mean when it was close to drone but not mounted. Still same noise?
I managed to lessen vibrations influence. Firstly I made and glued some supports from copper clad on quadcopter legs, then desoldered MPU-6050 from PCB and soldered it again with flexible wires and mounted MPU-6050 on "Moon Gel Drum Dampeners" I found on ebay, it helped a lot. Now I get max 3 degree fluctuations in angle calculation on low PWM. Pictures of quadcopter and graphs during the same test as in original post with Kalman filter is below. I managed to stabilize quadcopter on one axis with 2 motors on. I used B. Beauregards Arduino PID library, here is a link to the video:
Nice to hear that you managed to increase accuracy. Even though quite complicated way :-)
Anyway I will try if Tarantula vibration causes same MPU-6050 noise . Tarantula does not have any kind of anti-vibration mounting. But maybe its body is not as stiff as you PCB.
Regarding MPU-6050. I am looking into datasheet and I am not able to figure out how DMP affects data from sensors. Or how can I enable it. They mention that there is an output register from DMP or it can push data into FIFO. But I do not see any DMP out register. And it is not clear if data written to FIFO are same sensor data or data processed by DMP.
Thanks for link to PID library. I am trying to add altitude hold mode to my drone. I ordered MPU-9250 board that has pressure sensor too. I am going to add electronics to transmitter, not to drone itself (easier). I am thinking that I will be controlling voltage on thorttle potentiometer by a PID logic depending on altitude/pressure sensor data.
PCB material (FR-4) is very flexible, in my case I use MPU-6050 module soldered just on one side, if I would solder just MPU-6050 IC directly on PCB, vibrations should have less influence to MPU because of smaller common area and better mounting.
As far as I know InvenseSensors for a long time didn't made info about DMP available for everyone, you needed to make a contract with them to acquire information how to use DMP. Jeff Rowberg arduino library is somewhat reverse engineered implementation of how to use DMP, you should look up his library source code, it has some useful commentary. However some time ago InvenseSensors published separate guide how to use DMP, I will upload files that I got.