UPDATE: There was a small mistake in the Arduino code. My apologies for the mistake. The way I used the complementary filter for combining Accelerometer & Gyroscope data was not right. I have updated the Arduino code & now its correct. The new code is available on the same link in the descriptions below..
This is a simple GUI made in Processing to test the MPU 6050. The GUI shows 3 readings for rotation about a single axis- accelerometer, gyroscope & combined acceleromete-gyroscope data. I used a complementary filter to combine the accelerometer & gyroscope data. I made the GUI to visualize the individual accelerometer & gyroscope readings & how accurately the complementary filter combines the two. This only shows the angle of rotation about a single axis, it can be easily extended to all 3 axes.
For the arduino code I modified the sample code available on Arduino site for MPU 6050 which just shows the raw accelerometer & gyroscope readings. I referred to the data sheet of MPU 6050 to convert the raw values to meaningful readings. Angle value can be obtained directly from accelerometer reading. The gyroscope data needs to be integrated to find out the angle. Then I used the "complementary filter" to combine the two data & find the angle which is supposedly free from large errors. Complementary Filter is a simple filter for combining data; The instantaneous changes in angle are mostly provided by gyroscope which is highly accurate but on the long run the gyroscope reading drifts so the accelerometer data is used to minimize the error since accelerometer data doesn't change with time, Simple! There are many articles available online about complementart filter & other filters.
I have written the processing code without using any GUI libraries so its a bit lengthy but its very easy. The program graphically shows the angle in 3 separate readings. There are two buttons on the UI which just start & stop the code so that I can verify that the code is running correctly. Note that THE BUTTONS DON'T WORK when serial communication is going on i.e when the IMU is connected.
The Arduino code- https://onedrive.live.com/redir?resid...
The Processing Code- https://onedrive.live.com/redir?resid...
Note that you can not just directly open the GUI window using this code since it uses serial communicaction. It will show "COM port not found" error. To directly open the GUI window some lines of code need to be commented out ( Use the second code given below). This code can only be used to open GUI window if the MPU 6050 is connected to the PC.
The processing code 2 ( This is exactly the same processing code except for the fact that I have commented out (Disabled) certain lines of code ( related to serial communication ) so that you can open the GUI window & run the animation.
https://onedrive.live.com/redir?resid...
En esta página del sitio puede ver el video en línea Testing MPU 6050 using Processing de Duración hora minuto segunda en buena calidad , que subió el usuario Pravat 07 noviembre 2015, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 11,745 veces y le gustó 64 a los espectadores. Disfruta viendo!