This is one of my first serious projects that I started in order to challenge myself and apply the knowledge I learnt from my classes. I spent a long time really thinking hard about what kind of creation would showcase my skills the best and I allowed things I already own like the Arduino, Motor shield and some DC motors to have a part in deciding what I would make because otherwise these things would just be sitting in my 'Junk drawer' forever.
Eventually I decided to create a self balancing robot. It needs to balance because it only has 2 wheels on either side and it does this by taking reading from the MPU-6050 which has an accelerometer and 3 axis gyroscope, feeding these readings through PID control with an Arduino and then driving the motors with the Adafruit motor shield and its library.
However to make this project an actual challenge, instead of just using a given I2C library for communicating with the gyroscope board I taught myself the I2C communication protocol and wrote my own functions for initializing and retrieving data from the board.
These are pages from my book where I was learning I2C. My first milestone was reached when I first made successful communication with the MPU-6050 which is shown in this video.
All of the code I used can be found on my GitHub which is linked in attachments. After this I decided it is a good time to get the frame 3D printed so I can assemble the robot and start writing/tweaking the PID control to get the best balance so the following images are of the 3D printing process and then the final frame without the wheels.
Now that the frame was completed all that was left was to put on the motors attached to wheels on the sides and write the PID control (which was harder than I though it would be). This is because of unexpected problems that came up such as gyroscope drift when using the gyro reading to calculate the angle of inclination and also from the horizontal acceleration interfering with the accelerometers angle reading and so to solve this and get an accurate angle I put both of the readings through a 'complimentary filter' type equation where the accelerometer angle reading is summed into the final angle whereas the gyroscopes contribution to the final angle is constantly being 'refreshed' so that the long term changes due to gyroscope drift are minimized.
After much coding here is what the final robot looks like balancing in this video.
I hope you enjoyed looking at my project, I am very happy with how it turned out.
Comments
Please log in or sign up to comment.