Skip to content

robotics-iitrpr/Self_Balancing_Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Self-Balancing Bot

Defying gravity, one PID loop at a time

Arduino IMU Control Status


๐ŸŽฏ What's This All About?

image

Meet the Self-Balancing Bot - a two-wheeled marvel that refuses to fall over! This isn't just another robot; it's a testament to the beautiful dance between physics, mathematics, and engineering. Using the magic of PID control and the precision of a BNO055 IMU, this little warrior constantly fights gravity and wins.

๐Ÿง  The Brain Behind the Balance

Our bot thinks fast and acts faster:

  • ๐ŸŽ›๏ธ PID Controller: The secret sauce that keeps things upright
  • ๐Ÿ“ก BNO055 IMU: 9-axis absolute orientation sensor providing real-time feedback
  • ๐Ÿ”ง Arduino Nano: The compact powerhouse processing it all
  • ๐ŸŽฏ Closed-Loop System: Continuous feedback for perfect balance

โš™๏ธ Technical Specifications

Component Specification
Microcontroller Arduino Nano
IMU Sensor BNO055 9-DOF Absolute Orientation
Control Algorithm PID (Proportional-Integral-Derivative)
Communication I2C (IMU โ†” Arduino)
Balance Range adjust what your bot physics sypports !

๐Ÿ”ง How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   BNO055    โ”‚โ”€โ”€โ”€โ–ถโ”‚ Arduino Nano โ”‚โ”€โ”€โ”€โ–ถโ”‚   Motors    โ”‚
โ”‚ IMU Sensor  โ”‚    โ”‚ PID Control  โ”‚    โ”‚  & Wheels   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ–ฒ                   โ”‚                    โ”‚
       โ”‚                   โ–ผ                    โ”‚
       โ”‚            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ Tilt Angle   โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚  Feedback    โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Control Loop Dance ๐Ÿ’ƒ

  1. Sense: BNO055 measures the bot's tilt angle and angular velocity
  2. Think: Arduino calculates the error using PID algorithm
  3. Act: Motors adjust wheel speed to counteract the tilt
  4. Repeat: Loop runs continuously at high frequency
  5. Balance: Bot maintains upright position like a digital tightrope walker

๐Ÿš€ Features

  • ๐ŸŽช Dynamic Balance: Recovers from disturbances automatically
  • ๐Ÿ”„ Real-time Processing: Sub-10ms response time
  • ๐Ÿ“Š Sensor Fusion: BNO055's built-in Kalman filter for smooth data
  • ๐ŸŽ›๏ธ Tunable Parameters: Adjustable PID gains for optimal performance on your own bot
  • ๐Ÿ”ง Compact Design: Nano form factor for minimal footprint

๐Ÿ“‹ Bill of Materials (BOM)

Qty Component Purpose
1 Arduino Nano Main controller
1 BNO055 IMU Module Orientation sensing
2 n20 Geared Motors Propulsion
2 n20 Wheels Ground contact
1 Motor Driver (TB6612FNG) Motor control
1 liPo Power source
1 Chassis/Frame Mechanical structure
- Jumper Wires & Headers Connections

๐Ÿ”Œ Wiring Diagram

Arduino Nano          BNO055 IMU
    VIN    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  VCC
    GND    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  GND
     A4    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  SDA
     A5    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  SCL

Arduino Nano        Motor Driver
     D3     โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  ENA
     D4     โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  IN1
     D5     โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  IN2
     D6     โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  ENB
     D7     โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  IN3
     D8     โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  IN4

๐ŸŽ›๏ธ PID Tuning Guide

The art of balance lies in the PID parameters:

  • Kp (Proportional): Start with 20-50, higher = more aggressive
  • Ki (Integral): Usually small, 0.1-1.0, eliminates steady-state error
  • Kd (Derivative): Start with 0.5-2.0, adds damping

Tuning Process:

  1. Set Ki and Kd to 0
  2. Increase Kp until oscillation begins
  3. Add Kd to reduce oscillation
  4. Add small Ki to eliminate offset

๐Ÿ”ฎ Future Enhancements

  • AI Powered: Reinforcement Learning (NO magical PID!)
  • Advanced Sensors: Camera for line following
  • Machine Learning: Adaptive PID parameters
  • LED Indicators: Visual status feedback

๐Ÿ› ๏ธ Getting Started

1. Hardware Assembly

  • Mount Arduino Nano and BNO055 on chassis
  • Connect motors to H-bridge driver
  • Wire according to pinout diagram above
  • Install push button on pin 11 for initial calibration

2. Software Setup

  • Install Adafruit BNO055 library in Arduino IDE
  • Upload the provided code to Arduino Nano
  • Open Serial Monitor (115200 baud) for debugging

3. Initial Calibration

  • Power on the bot in upright position
  • Wait for BNO055 auto-calibration (few seconds)
  • Press calibration button to set balance point
  • Observe angle readouts in Serial Monitor

4. Fine Tuning (if needed)

  • Adjust the three PID parameter sets in code
  • Modify motorMax, motorMin values for your motors
  • Change startAngle for different safety thresholds
  • Test in safe environment with crash protection!

5. Let It Balance! ๐ŸŽ‰

  • Place bot upright and watch the magic
  • Gently push to test recovery response
  • Monitor serial output for performance analysis

๐Ÿค Contributing

Found a bug? Have an improvement? Contributions are welcome! Whether it's:

  • Code optimizations
  • Documentation improvements
  • Hardware modifications
  • PID tuning suggestions

๐Ÿ“œ License

This project is open source - feel free to learn, modify, and share!


"In a world full of things that fall down, be the bot that stands up!" ๐Ÿค–โš–๏ธ

Made with โšก Arduino, ๐Ÿงฎ Math, and โค๏ธ Engineering

About

A self balancing 2-wheeled bot based of a PID control using a feedback from BNO055 IMU module data, using a buck for power distribution and Arduino Nano for the Processing purposes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages