0% found this document useful (0 votes)
125 views

2 Wheel Self-Balancing Robot: Eric Wang

This document describes the design and implementation of a 2-wheel self-balancing robot. It uses an ESP32 microcontroller, MPU9250 sensors (accelerometer, gyroscope, magnetometer), and DRV8833 motor controller. It balances using a modified complementary filter to estimate tilt angle from the sensors and a PID controller to drive the motors accordingly to correct tilt. The PID constants must be tuned for the robot to balance stably with minimal oscillation. Heavier components are placed higher to reduce the effects of gravity and allow the controller more time to respond.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

2 Wheel Self-Balancing Robot: Eric Wang

This document describes the design and implementation of a 2-wheel self-balancing robot. It uses an ESP32 microcontroller, MPU9250 sensors (accelerometer, gyroscope, magnetometer), and DRV8833 motor controller. It balances using a modified complementary filter to estimate tilt angle from the sensors and a PID controller to drive the motors accordingly to correct tilt. The PID constants must be tuned for the robot to balance stably with minimal oscillation. Heavier components are placed higher to reduce the effects of gravity and allow the controller more time to respond.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

2 Wheel Self-Balancing

Robot
Eric Wang
Segway
Handle (Boston Dynamics)
Development Board: WiPy 2.0
● ESP32 dual core microcontroller
● Wifi
● MicroPython
Sensors: MPU9250
● Accelerometer
● Gyroscope
● Magnetometer
Motor Controller: DRV8833
2 H-Bridges - can drive 2 DC motors or

1 stepper motor
Circuit Diagram

Esp 32
Balancing
Move motors in direction of tilt

1. Determine tilt angle


2. Balance by correcting tilt angle
Determining Tilt Angle With Gyroscope

● Gyroscope has noise and θ will drift over long periods of time
Determining Tilt Angle With Accelerometer
Accelerometer coord system
accel z
accel y +z
θ
+y

Inaccurate when other forces are present


Complementary Filter
● Combines accelerometer
and gyroscope data to give
a good estimate for angle
Modified
Complementary Filter
Change the weight of
accelerometer data based on
how close it is to 1g
PID Controller
Control loop feedback mechanism

Proportional, integral, and derivative


terms
PID constants
1. 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
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
Demo Video

You might also like