![Page 1: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/1.jpg)
2 Wheel Self-Balancing RobotEric Wang
![Page 2: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/2.jpg)
Segway
![Page 3: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/3.jpg)
Handle (Boston Dynamics)
![Page 4: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/4.jpg)
Development Board: WiPy 2.0● ESP32 dual core microcontroller● Wifi● MicroPython
![Page 5: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/5.jpg)
Sensors: MPU9250● Accelerometer● Gyroscope● Magnetometer
![Page 6: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/6.jpg)
Motor Controller: DRV88332 H-Bridges - can drive 2 DC motors or
1 stepper motor
![Page 7: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/7.jpg)
Circuit Diagram
Esp 32
![Page 8: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/8.jpg)
Move motors in direction of tilt
1. Determine tilt angle2. Balance by correcting tilt angle
Balancing
![Page 9: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/9.jpg)
Determining Tilt Angle With Gyroscope
● Gyroscope has noise and θ will drift over long periods of time
![Page 10: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/10.jpg)
θ
Determining Tilt Angle With Accelerometer
Inaccurate when other forces are present
g
+y
+zaccel yaccel z
Accelerometer coord system
θ
![Page 11: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/11.jpg)
Complementary Filter
● Combines accelerometer and gyroscope data to give a good estimate for angle
![Page 12: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/12.jpg)
ModifiedComplementary Filter
Change the weight of accelerometer data based on how close it is to 1g
![Page 13: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/13.jpg)
PID ControllerControl loop feedback mechanism
Proportional, integral, and derivative terms
![Page 14: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/14.jpg)
PID constants1. Make Kp, Ki, and Kd equal to zero.2. Adjust Kp. Too little Kp will make the robot fall over, because there's not enough
correction. Too much Kp will make the robot go back and forth wildly. A good enough Kp will make the robot go slightly back and forth (or oscillate a little).
3. Once the Kp is set, adjust Kd. A good Kd value will lessen the oscillations until the robot is almost steady. Also, the right amount of Kd will keep the robot standing, even if pushed.
4. Lastly, set the Ki. The robot will oscillate when turned on, even if the Kp and Kd are set, but will stabilize in time. The correct Ki value will shorten the time it takes for the robot to stabilize.
https://maker.pro/projects/arduino/build-arduino-self-balancing-robot
![Page 15: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/15.jpg)
Placement of Parts● Heaviest part on top
○ Reduces angular acceleration due to gravity - slower fall
○ PID controller can make adjustments before robot has tilted too far
![Page 16: 2 Wheel Self-Balancing Robot - EECS at UC Berkeleyboser/courses/49/lectures/balancing_robot.pdf2 Wheel Self-Balancing Robot Eric Wang. Segway. Handle (Boston Dynamics) Development](https://reader036.vdocuments.net/reader036/viewer/2022062603/5f11f9e79691214761683280/html5/thumbnails/16.jpg)
Demo Video