Friday, June 27, 2014

Real time 2D visualization on Matlab for GY-521 MPU-6050 IMU



Watch the demo video:








Circuit used





I used "GY-521 which has "MPU-6050" sensor which contains an accelerometer and a gyro on one chip. 


Connections:

VCC on GY-521 ---->  to 3.3v pin on Arduino
GND on GY-521 ---->  to GND  pin on Arduino
SCL  on GY-521 ---->  to PinA5 on Arduino
SDA on GY-521 ---->   to PinA4 on Arduino


Codes

I used 2 codes. The first one should be uploaded to the Arduino board. It is responsible for detecting one of the 3 angles of the sensor, and sending its value to the computer via USB. 

The other code is a Matlab code responsible for receiving the angle from the Arduino and visualizing it on a 2D object.


Arduino Code, Matlab code, and Libraries needed:

https://drive.google.com/folderview?id=0Bx4uoJmyE27YOHBqUzVsLU9XTVE&usp=sharing

Move "I2Cdev" & "MPU6050" folders to 

Documents > Arduino > libraries 




13 comments:

  1. so how to save datas retrieved into a file

    ReplyDelete
  2. Good day. I have a question I hope you can answer me. I want to connect two MPU6050 a single arduino. What you need to add the arduino sketch for the two readings? What do I need to add to the MATLAB code to create a graph of the second module? I tried to duplicate the variables but it has not worked for me. I await your response. Thank you.

    ReplyDelete
    Replies
    1. hi, may I know do you know about it already?

      Delete
  3. good work..
    I am using mega2560 instead of UNO. So where should i connect MPU 6050 SCL and SDA pins??can I connect to mega scl and sda pins?

    ReplyDelete
    Replies
    1. if you search on google about "mega2560 scl sda(i2c) pins". You will find out...

      Delete
  4. Thank you! There were some problems with x64 Windows, but on x32 is OK

    ReplyDelete
  5. Did you had any troubles? I ask it because normally the mpu requires level shifters when used with the uno...

    ReplyDelete
  6. hi sir,
    you said that frist code should uploaded int arduino board. i tried to upload through arduino software. is it correct ? which sorftware can use to upload into arduino board .? help me pleasem .

    ReplyDelete
  7. hi sir,
    you said that frist code should uploaded int arduino board. i tried to upload through arduino software. is it correct ? which sorftware can use to upload into arduino board .? help me pleasem .

    ReplyDelete
  8. hi sir,
    you said that frist code should uploaded int arduino board. i tried to upload through arduino software. is it correct ? which sorftware can use to upload into arduino board .? help me pleasem .

    ReplyDelete
  9. dear sir, regarding i2c communication, can't we connect SDA,SCL of MPU 6050 to that of arduino? is it necessary to connect SDA of mpu 6050 to pin A4 of ardiuino and SCL to A5?

    ReplyDelete
  10. dear sir, regarding i2c communication, can't we connect SDA,SCL of MPU 6050 to that of arduino? is it necessary to connect SDA of mpu 6050 to pin A4 of ardiuino and SCL to A5?

    ReplyDelete
  11. can you hepl me!


    Error using serial/fopen (line 72)
    Open failed: Port: COM2 is not available. No ports are available.
    Use INSTRFIND to determine if other instrument objects are connected to
    the requested device.

    Error in real_time_2D_animation_MPU6050 (line 5)
    fopen(arduin); % initiate arduino communication

    ReplyDelete