BaBot: Build Your Own Ball-Balancing Robot

by Johan Link in Circuits > Robots

96 Views, 4 Favorites, 0 Comments

BaBot: Build Your Own Ball-Balancing Robot

DSC_0029.jpg
main-ezgif.com-optimize.gif

Bring control theory to life with BaBot, a compact, open-source robot that balances a ball in real-time using infrared (IR) sensors and an ATmega32U4 microcontroller. Whether you're a student, educator, or hobbyist, BaBot offers an engaging way to explore PID control, sensor integration, and robotics.

BaBot began as a high school project in 2018, initially using a computer and overhead camera for ball tracking. After several iterations, including a Raspberry Pi version with a camera beneath a transparent plate, I developed a more efficient design. The current version utilizes IR sensors and an ATmega32U4 microcontroller, resulting in a more compact, affordable, and user-friendly robot.

Supplies

box.png

Components:

  1. 1x Acrylic Sheet (for the platform) 2mm PMMA
  2. 16x IR Phototransistors
  3. 16x Wide-angle IR LEDs
  4. 1x Custom PCB (available via PCBWay)
  5. 1x ATmega32U4 Microcontroller
  6. 1x CD74HC4067 16-Channel Analog/Digital Multiplexer
  7. 1x 5V 10A DC Power Supply
  8. 3x MG90 Micro Servos

Tools:

  1. Laser Cutter (for acrylic parts)
  2. 3D Printer

Software:

  1. Arduino IDE 2.0

Order Your PCBs

DSC_0003.jpg
DSC_0020.jpg

To make things easier and more reliable, I highly recommend ordering the PCBs pre-assembled, especially since they contain a number of SMD components.

👉 You can order the assembled PCBs directly from PCBWay.

Alternatively, if you'd like the most seamless experience, you can purchase the complete BaBot kit (with all components included) from ba-bot.com. That way, you skip the hassle of sourcing individual parts and can focus entirely on building and enjoying your robot.

3D Print the Parts

DSC_0014.jpg
DSC_0016.jpg

All the structural parts of BaBot can be 3D printed. Make sure to use a printer that offers high precision, particularly for the parts that interface directly with the servos. All the parts can be found on Thingiverse.

Downloads

Assemble the Arms and Servos

assemblyfinal-ezgif.com-optimize.gif
DSC_0015.jpg

Once your 3D printed parts are ready, start by assembling the three arms and attaching them to the MG90S servos.

Assemble the Base

DSC_0033.jpg
DSC_0019.jpg
DSC_0017.jpg

Next, mount the servo arms onto the base. This structure serves as the foundation of BaBot, supporting the electronics and handling the balancing mechanism.

Mount the Top Plate

DSC_0021.jpg
DSC_0020.jpg

Now attach the top acrylic plate to the second PCB.

Upload the Code

DSC_0023.jpg

Use the Arduino IDE to upload the firmware to the ATmega32U4 microcontroller on the PCB. The code is open-source and available on the GitHub page. The code is already commented to help you understand how it works, and more detailed explanations will be added to ba-bot.com once the project is fully finalized.

How It Works

BaBot.gif

When you place a ball on BaBot's transparent plate, a sequence of events unfolds:​

  1. Infrared Detection: Beneath the plate lies a secondary printed circuit board embedded with numerous infrared (IR) LEDs and IR phototransistors. These IR LEDs emit light upward, which reflects off the bottom of the ball and is captured by the phototransistors. This setup allows BaBot to accurately determine the ball's position on the plate in real-time.​


  1. Data Processing: The position data collected by the secondary PCB is transmitted to the main PCB, which houses an ATmega32U4 microcontroller, similar to the one found in the Arduino Leonardo. This microcontroller processes the data using a PID (Proportional-Integral-Derivative) algorithm. The PID algorithm calculates the difference between the ball's current position and the desired target position (typically the center of the plate).​


  1. Calculating Plate Tilt: To correct the ball's position, BaBot must tilt the plate appropriately. This involves solving inverse kinematics equations to determine the precise angles needed for each of the three servo motors to achieve the desired tilt.​


  1. Actuating Movement: The calculated angles are sent to the servo motors, each connected to articulated arms ending in metallic balls. These balls serve as joints and are magnetically attached to the underside of the plate, allowing smooth and responsive movement.​


  1. Continuous Feedback Loop: After adjusting the plate's orientation, the system re-measures the ball's position, and the process repeats. This feedback loop operates approximately 30 times per second, ensuring the ball remains balanced on the plate.​


This seamless integration of sensors, control algorithms, and mechanical components enables BaBot to perform real-time ball balancing, offering an engaging demonstration of robotics and control systems in action.

Where to Get Your BaBot ?

DSC_0029.jpg

BaBot offers a hands-on experience in building and understanding a real-time control system. Its open-source design encourages experimentation and learning, making it an excellent project for both beginners and experienced makers.​

For those interested in exploring BaBot further or obtaining a kit, more information is available at ba-bot.com​

Whether you're a teacher seeking an engaging classroom project, a student eager to delve into robotics, or simply someone who appreciates innovative gadgets, BaBot is designed to captivate and educate.​

No prior experience is necessary, just a curious mind and the enthusiasm to build something remarkable.​