Professional Documents
Culture Documents
Self-Balancing robot
Graduation Project Class 2023
Submitted to
Electrical Power Engineering Department
Supervised by
Prof. Abdel-Latif Elshafei
Cairo University
Faculty of Engineering
Electric Power Dept.
2
Presented By
Omar Abdullah Hassan Ahmed
Outline II
III
MCM
Int
• ••
• Overview.
IV • ••
• Problem Description.
V • ••
• Inverted Pendulum.
• ••
VI
• Project motivation. • ••
VII
•
VIII
I
Introduction II
MCM
III
•• •
• Overview.
IV •• •
• Problem Description.
V •• •
• Inverted Pendulum.
•• •
VI
• Project motivation. •• •
VII
VIII
Introduction
Overview
Robotics is the field of designing, constructing
and using robots to perform tasks which were
usually done by humans.
Robots are provided with sensors that are
meant to simulate human senses.
Problem Description.
• Self-balancing robot is an unstable nonlinear
system by nature.
• There are different control methods to
achieve stabilization
Spring 2023 7
Introduction
Inverted Pendulum
• The inverted pendulum is a common problem
found in control system references.
• Self-balancing robots have a lot in common with
the inverted pendulum.
However, there are few differences between the
self-balancing robot and the inverted pendulum.
Spring 2023 8
Introduction
Project Motivations
• Hands-on experience in implementing
control system theories.
• Designing protection schemes.
• Exposure to mechanical issues.
Spring 2023 9
II
Main Components
III
• Stepper Motors.
• DRV8825 Stepper Motor Drivers. IV
• Arduino NANO Microcontroller. V
• MPU 6050 Gyroscope and Accelerometer.
VI
• HC-05 Bluetooth Module.
• Lithium-ion batteries. VII
VI
Main Components
Stepper Motors
• Stepper motors are chosen for its superior torque at low
speeds, accuracy, output characteristics and simple
controllability.
• The stepper motor working principle is electro-magnetism.
• Micro-controllers can be programmed to allow for micro-
stepping.
• Stepper motors are divided into uni-polar and bi-polar
stepper motors.
• We used a NEMA 17 bi-polar version.
Spring 2023 11
Main Components
MPU-6050
• The MPU-6050 is a micro-electrical-mechanical
system, also known as MEMS.
• MEMS accelerometer measures the linear acceleration
of the object they are attached to.
• MEMS gyroscope measures the angular motion of the
object they are attached to.
Spring 2023 12
Main Components
Arduino NANO
• Arduino boards are microcontroller boards that are
developed based on ATmega microcontrollers.
• The main reason behind choosing the NANO type is its
small size.
• Many educational materials can be found for programming
the Arduino NANO.
Spring 2023 13
Main Components
Spring 2023 14
Main Components
Spring 2023 15
Main Components
lithium-ion battery
• The rechargeable lithium-ion battery is made of
one or more compartments called cells.
• Each cell has a capacity of 4 volts.
• Lithium-ion batteries allowed for free motion
only constrained by range of Bluetooth.
• We used a 3 series cell setup providing a 11.4V
output can last for 1.5 hrs.
Spring 2023 16
Components interfacing M
III
• Stepper Motors Test. •
• Acquiring Gyroscope Readings. IV
•
• MPU as a Level Meter. V •
• MPU with Stepper motor. VI •
• Bluetooth Module With Stepper motor. •
VII
VIII
Components interfacing
Spring 2023 18
Components interfacing
Spring 2023 19
Components interfacing
Spring 2023 20
Components interfacing
Spring 2023 21
Components interfacing
Spring 2023 22
Mechanical Structure E
• System Requirements For Materials.
IV
• System Estimation. •
• Structure Fabrication. V •
• Connection Elements. VI
• Wheels
VII
VIII
Mechanical Structure
Structure Requirements
• Light Weight
Spring 2023 24
Mechanical Structure
Structure Requirements
• Light Weight
• Weight Distribution
Spring 2023 25
Mechanical Structure
Structure Requirements
• Light Weight
• Weight Distribution
• Robustness
Spring 2023 26
Mechanical Structure
Structure Requirements
• Light Weight
• Weight Distribution
• Robustness
• Formability
Spring 2023 27
Mechanical Structure
Structure Requirements
• Light Weight
• Weight Distribution
• Robustness
• Formability
• Cost
Spring 2023 28
Mechanical Structure
Casing Materials
Advantages Disadvantages
Casing Materials
Advantages Disadvantages
Can support more weights than plastic and Harder to Moulid without heavy machinery (laser
Acrylic
plywood while still being light weight. cutting).
Spring 2023 30
Mechanical Structure
Structure Fabrication
Manufacturing
Advantages Disadvantages
methods for casing:
a. Laser can cut through practically all a. Not fit for complex multidimensional
Laser cutting:
materials. geometry.
b. Works with high accuracy and precision b. Produce harmful fumes during production.
Spring 2023 31
Mechanical Structure
System Estimation
Torque limits
Tmax = mg*l*sin(θmax)
Tmax = 1.5*9.8*0.08*sin(5⁰) = 0.2315 Nm
• Tmax is the maximum torque produced by the motor.
• m is the total mass of the robot.
• g is the constant of gravity.
• l is the height of the center of mass.
• θ is the maximum recovery angle.
Spring 2023 32
Mechanical Structure
System Estimation
Torque limits
Tmax = mg*l*sin(θmax)
Tmax = 1.5*9.8*0.08*sin(5⁰) = 0.2315 Nm
Spring 2023 33
Mechanical Structure
System Estimation
Dimensions
• Every rack has dimensions of 175mm
175mm X 115mm.
• Every rack has depth of 6mm.
Spring 2023 34
Mechanical Structure
Spring 2023 35
Mechanical Structure
Spring 2023 36
Mechanical Structure
Spring 2023 37
Mechanical Structure
Spring 2023 38
Mechanical Structure
Spring 2023 39
Mechanical Structure
Connection Elements
Stepper motor L-channel
we used a metal L-channel to connect and
stabilize the stepper motors with the full
structure.
Spring 2023 40
Mechanical Structure
Connection Elements
We used M5 x 100mm 304 Stainless
Steel Fully Threaded Rod Bar for
supporting the rack.
Spring 2023 41
Mechanical Structure
Wheels
Wheel specifications that satisfy our need:
• We choose
Light Weight two tyre wheels each 85mm in diameter
• Stability
and 35mm in thickness.
• Highweight
The frictionofsurface
each wheel is 50gm and the coupler is
• Good
20 gm.coupling with the shaft
Spring 2023 42
Electrical Circuit Design
• Circuit Schematic Diagram.
• PCB Design
V
VI
VII
VIII
Electrical Circuit Design
Schematic Diagram
After becoming familiar with the hardware, now its time to combine all the
elements in one big circuit that house all the electronic components.
All elements were tested first to see if they
can work together in one configuration.
Spring 2023 44
Electrical Circuit Design
Schematic Diagram
A schematic design was made on EasyEDA software to implement a PCB
The Schematic diagram can be divided into 3 sections included:
• Input Protection elements.
• Stepper Motor Driving components.
• The gyroscope and Bluetooth components.
Spring 2023 45
Electrical Circuit Design
Schematic Diagram
The Input protection elements include:
• 2200uf input Filter capacitor.
• 3 Amps overcurrent DC fuse.
• 12V to 5V Voltage regulator.
• Diode for input reverse polarity protection.
• A voltage divider resistors to for undervoltage protection.
Spring 2023 46
Electrical Circuit Design
Schematic Diagram
Stepper Motor Driving components are:
• The Arduino NANO microcontroller.
• Two DRV8825 motor drivers (1 per motor).
• One 100uF filter capacitor per driver.
• Two 4 pins output sockets (from the PCB to
the Motors).
Spring 2023 47
Electrical Circuit Design
Schematic Diagram
• Each driver is connected individually with the microcontroller to
have sperate control action for each motor.
Spring 2023 48
Electrical Circuit Design
Schematic Diagram
The Gyroscope and Bluetooth components:
• The Arduino NANO microcontroller.
• MPU-6050 Gyroscope and Accelerometer.
• HC-05 Bluetooth Module.
Spring 2023 49
Electrical Circuit Design
Schematic Diagram
The Bluetooth module can send and receiving data
from any Bluetooth capable device (Android/iOS,
laptops,…etc.).
Spring 2023 50
Electrical Circuit Design
Schematic Diagram
Spring 2023 51
Electrical Circuit Design
PCB Design
PCB Specification
• Designed on EasyEDA Software.
• Board Type: Double sided PCB 1.6mm.
• PCB Material : we choose FR4.
• Solder mask : Green.
• Board dimensions: 135 x 75 mm.
• Board area: 101.25 cm^2.
• Copper trace width: 1.5 mm.
• Clearance : 0.5 mm.
Electrical Circuit Design
PCB Design
Spring 2023 53
Electrical Circuit Design
PCB Design
Spring 2023 54
Bluetooth controller
• Alternative Control Techniques.
• Mobile application iterations.
• Final Application Version.
VI
VII
VIII
Bluetooth controller
Control methods
Physical connection
Spring 2023 56
Bluetooth controller
Control methods
Non-chuck controller
• This Method removes the need for a
physical connection with the Robot.
Spring 2023 57
Bluetooth controller
Control methods
Mobile Application
• By far the best and the most customizable mean of communication
with the Bluetooth module as any Bluetooth capable device can easily
connect to the robot provided it has the application.
Spring 2023 58
Bluetooth controller
Control methods
Mobile Application
• A great example is the MIT App
Invertor website by the
Massachusetts Institute of
Technology
Spring 2023 59
Bluetooth controller
Application Versions
We made multiple versions of the mobile application throughout the entire
project and here are some of them for example:
Spring 2023 60
Bluetooth controller
Application Versions
Final Version Features:
• More robust directional control keypad.
• An emergency stop button.
• Variable speed control levels.
• Battery voltage indicator.
Spring 2023 61
PID Controller
• Working Principles.
• PID Tuning Techniques.
• Trial and Error
• Mechanical Model.
VII
VIII
Spring 2023 62
PID Controller
Working Principle
• A PID (Proportional-Integral-Derivative) controller is a widely
used control algorithm for self-balancing robots.
• The controller then uses this error signal to adjust the motor commands
and maintain the robot's balance state.
Spring 2023 63
PID Controller
𝒕
𝒅𝒆(𝒕)
𝑻𝒉𝒆 𝒐𝒖𝒕𝒑𝒖𝒕 𝒄𝒐𝒏𝒕𝒓𝒐𝒍 𝒔𝒊𝒈𝒏𝒂𝒍 = 𝒖 𝒕 = 𝑲𝒑 𝒆 𝒕 + 𝑲𝒊 න 𝒆 𝒕 𝒅 𝒕 + 𝑲𝒅
𝟎 𝒅𝒕
Spring 2023 64
PID Controller
PID Design
• There are two main position for the
robot: balanced and tilted.
Spring 2023 65
PID Controller
Here is a table that shows the system response to certain Gain changes
Parameter Rise Time Overshoot Settling Time Steady-State Stability
error
Spring 2023 66
PID Controller
• The optimal gains will depend on your robot's mass, motor torque, sampling rate, …etc.
• If the robot is oscillating too much, reduce the gains. If the response is slow, increase the gains.
Spring 2023 67
PID Controller
Spring 2023 68
PID Controller
Mechanical Model
• This the
Build model
physical
can model
help ofidentify
the robota
using mechanical
starting Gain values
components
for the actual
such
as the chassis,
system or approach
wheels,
themotors,
true Gain
and
sensors.
values.
Spring 2023 69
PID Controller
Mechanical Model
Spring 2023 70
How to Balance a Balancing Robot.
• Weight and torque limitations
• Height Limitations
• Wheels Limitations
• Center of gravity calculations
VIII
Spring 2023 71
How to Balance a Balancing Robot.
Spring 2023 72
How to Balance a Balancing Robot.
Height Limitations
• The robot’s body length has an impact on the robot’s stabilization, if
the length was so too tall the robot may have a violent reaction to the
control action, and it may be unsuitable in the torque calculations.
Spring 2023 73
How to Balance a Balancing Robot.
Wheels Limitations
• There are multiple types of wheels, but in our robot’s structure off-
road wheels where the most suitable to make the robot balance
properly on Rough environments.
• The material of the wheels can affect their grip and traction on
different surfaces.
Spring 2023 74
How to Balance a Balancing Robot.
Center of Gravity
• The center of gravity is the point at which the weight of an object is
concentrated.
Spring 2023 75
How to Balance a Balancing Robot.
Center of Gravity
• It is important to position the heavy components of the robot as close to the
top of the robot as possible to left up the CoG as it reduces the angular
acceleration needed to react.
Spring 2023 76
Conclusion
• The project aims to build a self-balancing robot that uses the concept
of inverted pendulum theory to maintain balance for a two-wheeled
robot.
• The project gives a clear understanding of mechanical structure
design, component selection, and interfacing with Arduino, electrical
circuit design.
• Implementation of a mobile application and using MATLAB and
Simulink to model the mechanical system.
• The project effectively uses a PID controller to design and tune a
control algorithm for the self-balancing robot.
Spring 2023 77
Any Questions ?
Spring 2023 78
Thank You!
Spring 2023 79