S15: Self-Balancing Robot
Contents
Grading Criteria
- How well is Software & Hardware Design described?
- How well can this report be used to reproduce this project?
- Code Quality
- Overall Report Quality:
- Software Block Diagrams
- Hardware Block Diagrams
- Schematic Quality
- Quality of technical challenges and solutions adopted.
Project Title
Two Wheel Self-Balancing Robot
Abstract
The project is to build a two wheeled self-balancing robot. The robot is similar to a Segway machine but it uses sensors to alert the user when its path is blocked. The robot is also manually controlled using an Android phone via Bluetooth.
Objectives & Introduction
The purpose of this project is to design a two wheeled self-balancing robot. There are two parts to the system: motor controller and geographic controller. Each control system is implemented into different boards.
The motor control board is responsible for calibrating each motor to perform self-balancing and directional movements. In order for the robot to perform self-balancing, the motor control must implement a self-balancing algorithm which uses the input of an accelerometer and gyroscope module. The geographic control board provides directional movement the robot must execute such as turn left, go forward, stop, etc. The direction is mostly indicated by the user using an android phone via Bluetooth communication. The sensors are used to override user control for obstacle avoidance.
Team Members & Responsibilities
- Marvin Flores
- Stepper motor driver
- Accelerometer and gyroscope module driver
- Robot chassis
- Self balancing algorithm implementation
- Almon Otanes
- Bluetooth Communication
- Android App Development
- Sensor Interface
Schedule
Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.
Week# | Date | Task | Actual |
---|---|---|---|
1 | 4/3 | Build the Chassis of the robot | Completed: Yes. Problems Encountered: The battery is too heavy. The chassis needed to be reassembled a second time to fix the weight distribution problem. |
2 | 4/10 | Interface stepper motor driver carrier. | Completed:Yes Problems Encountered: We could not use the existing PWM driver, so we had to write our own to interface the stepper motor driver carrier |
3 | 4/17 | Bluetooth Communication Sensor Interface |
Completed: Yes |
4 | 4/24 | Interface Accelerometer and Gyroscope module. Android controller app |
Completed:Yes Problems Encountered: Had issue regarding I2C slave addressing. |
5 | 5/1 | Implement algorithm for self balancing Implement communications between two SJ-One boards Optimize drivers. |
Completed: Yes Problems Encountered: PID tuning. |
5 | 5/8 | Optimize algorithm implementation. Optimize drivers. |
Completed: No Problems Encountered: PID tuning. |
6 | 5/15 | Test. | Completed: No Problems Encountered: PID tuning. |
Parts List & Cost
Give a simple list of the cost of your project broken down by components. Do not write long stories here.
Quantity | Desctiption | Price |
---|---|---|
2 | SJ-One development board | $80 ea |
2 | Stepper motor | $16.95 ea |
2 | Stepper motor driver carrier | $10.45 ea |
1 | MPU6050 Accelerometer + Gyroscope module | $4.47 |
1 | 9.2V battery pack | $16~ |
1 | Robot Chassis (standoffs, aluminum plates, screws, etc.) | $80~ |
1 | Bluetooth module | $27~ |
2 | Ultrasonic sensor module | $2~ ea |
_______ | ||
Estimated total | $350 |
Design & Implementation
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
Hardware Design
Discuss your hardware design here. Show detailed schematics, and the interface here.
A self-balancing robot is an inverted-pendulum example problem. The idea is to keep the robot upright by driving the wheels towards the leaning angle theta.
I.e. when the robot is tilting forward, the wheels should be driven forward with a specific acceleration to counter the tilting. This will keep the robot in an upright position at all times.
The problem with this is that it is a very unstable system and a control algorithm must be used to stabilize it. For this project, the group decided to use a PID algorithm because of its simplicity
compared to other control algorithms. It is also readily available which is a plus considering the time we have to finish this project.
Hardware Interface
In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.
MPU6050
3-axis accelerometer, 3-axis gyroscope MODULE
The group used this module because the 3-axis accelerometer alone can't handle the complexity of the self-balancing robot. This module outputs raw data which need to be filtered in order to obtain the correct angle measurement
The group used Kalman filter to obtain the angle measurement. The source code for Kalman filter was obtained online to save time implementing it. The code can be found here: https://github.com/TKJElectronics/KalmanFilter/blob/master/examples/MPU6050/MPU6050.ino
This module uses I2C protocol for communication. The group needed to write their own driver for the MPU6050 in able to interface the module to the SJ-ONE board.
Only 4 pins are used in this module: Vcc, Gnd, SCL, SDA where SCL is the clock signal and SDA is the data signal.
This module was used to control one bipolar stepper motor, so a total of two drv8825 driver carriers were used for this project.
This driver carrier simplifies the method of controlling the stepper motors — it only needs a step frequency and a direction signal to control a single bipolar stepper motor
The group wrote their own driver to produce a step frequency and direction signal. This implementation took a while to finish because the group needed to understand how the PWM Motor Control is implemented on LPC1758 mcu
This interface uses two PWM pins for step frequencies, and two regular I/O pins for direction signal.
Software Design
Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again?
Make a smooth transition to testing section and described what it took to test your project.
The testing of the balancing purely relied on the PID controller. This of course assumed that the accelerometer+gyroscope sensor provides accurate angle readings.
The PID controller has three constant parameters, which are needed to be tuned perfectly to be able to balance the robot.
The testing of this project was the hardest part of all. Since the system is an unstable system and a PID controller was used to stabilize it, the success
of the project depends on how well the PID controller is implemented. Unfortunately, the group failed to make the robot to balance because of lack of background
regarding PID controllers. The PID controller is very popular because of its simplicity but its implementation is tougher than it looks. The issues below will
surely help future students that want to build their own self-balancing robot.
My Issue #1
Stepper Motors. Stepper motors have high torque and can be controlled precisely (e.g. 1/4 revolution, 350 steps, etc) but writing own drivers for the stepping frequency is time consuming. The reader should avoid using stepper motors unless the reader has access to drivers or the reader has experience using stepper motors.
My Issue #2
Accelerometer + Gyroscope: Even though MPU6050 has a lot of examples online, most of them are written in Arduino. This means that the codes available online are not readily transferable to the SJ-One board. A thorough understanding of the module is needed to be able to implement it correctly. This module also has undocumented functionalities that can't be access easily; moreover, these hidden functionalities are only available in Arduino. This means that to implement it to the SJ-One board, one needs to convert an Arduino code into C code which will surely take a lot of time.
The group suggests that the reader should carefully choose a sensor module.
My Issue #3
PID controller: Besides how people view this as a very simple control algorithm, it is very hard to implement. The reader should research ahead of time about the PID controller.
PID controller constants: These three constants are needed to be tuned perfectly, thus the group suggests that these three parameters should be modifiable in real time. The group realized this too late that's why a lot of time was wasted just by changing the constants. Three 5k Ohms potentiometer connected to ADC pin was the perfect solution to this problem.
My Issue #4
Tuning: since this is the hardest part of the project, a lot of time should be devoted in tuning the controller. The group spent a total of 4 weeks just tuning the PID and still failed to make the robot balance. This problem is a combination of the PID controller and the stepper motor driver. These two should be working perfectly in order to make this project a success.
Conclusion
Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?
Project Video
Upload a video of your project and post the link here.
Project Source Code
References
Acknowledgement
Any acknowledgement that you may wish to provide can be included here.
References Used
List any references used in project.