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.
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.
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.