Miyagi Say, “Balance Good, Everything Good”

This video is Proof of Concept for my very own self balancing robot. It uses an mpu-6050 for position sensing and uses a pair of DC motors to perform the balancing.

How balance is realised

How balance is realised

The algorithm was realised using two c++ classes that I wrote:-

1. MPU6050 Class that extracts raw values from the MPU6050 and scales the data down into deg/sec (gyro) and deg(accelerometer). This class is an improvement on my MPU 6050 post (also includes the sensor filter algorithm)and  encapsulates the relevant parts of arduino.cc user Krodal’s MPU 6050 program. You can create an instance of an MPU6050 sensor and it’s data can be extracted by using very simple code. The source code for the class can be downloaded here.

Upper Graph magenta line shows the filtered value of PITCH angle of the sensor. Lower Grpah green line shows the motor impulse needed to correct this PITCH and bring the sensor upright

Upper graph magenta line shows the filtered value of PITCH angle of the sensor. Lower graph green line shows the motor impulse needed to correct this PITCH and bring the sensor upright

1. DCMotorPair class to control the DC motors. Further information in my earlier post, including a detailed explanation on how to control a pair of DC motors using an Arduino. Or you can jump directly to the source code here.

The sensor data is extracted from the mpu-6050 and DC motor control is achieved with an Arduino UNO. Circuit diagram made with Fritzing (which keeps getting better and better) is shown below. Zoom in for a closer look.

Circuit DIagram

Circuit DIagram

Advertisements

12 thoughts on “Miyagi Say, “Balance Good, Everything Good”

  1. Love your work. I have been trying to do balancing robot for awhile but getting confuse with kalman filters, PID, and MPU6050 etc.
    Your github got so many files. Which files should I extract and use.

    Thanks again.

  2. Hi Miyagi,

    sorry to ask you again. I got your setup done and tested according to your video. But the balance was shaky like yours in the beginning of your video.
    You said after “I adjust the filter coefficients to get better result”. What do you mean and what do you adjust”.

    Do i need to play with this values?
    1) float kD = 0.1;
    float kP = 0.8;
    float kI = 0.1;
    2) int botSpeed = map((int)abs(moImpulse), 0,80, 80,255);

    I am almost there but yet so far.

    Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s