Close
0%
0%

MirrorBallBot

A ball-balancing robot that sees through a mirror

Similar projects worth following
I've always been fascinated by balancing things, like the inverted pendulum I built from an inkjet printer (https://youtu.be/NdbODkTNvp4), or myself on a unicycle (yes, that was quite a few years ago...).

Eventually, I decided to build a robot able to balance a ball on a platform, preferring a computer-vision-based system over a resistive panel.

Despite using a PiCamera V3 Wide, I quickly realized that a large distance between the camera and the platform was still necessary to achieve a reasonably wide Field of View. I wanted a large platform, not a large robot... so I had to think differently.

Well, now that I'm in my fifties and my eyesight is no longer what it used to be, I noticed that I could see myself more sharply in a mirror because the apparent distance from my eyes was doubled.

That insight is now literally reflected in the robot: a mirror virtually increases the camera distance, resulting in about a 60% larger FoV without increasing the robot size.

In the introduction I've explained the reason for the mirror, one of the key innovations of the project and the inspiration behind its name.

Another key innovation of this robot is the "finger-follower" feature: the finger position is tracked on the robot's touchscreen, and the ball follows it in real time. By watching the display, the ball continuously "lands" underneath the finger.

This feature was already in my mind during the early stages of the project, when I was considering using a large touchscreen display. By pure coincidence, ELECROW proposed a sponsorship and sent me a 7-inch DSI touchscreen display. The robot also works without a display, but the display is what really makes it enjoyable and complete.

Besides the real-time camera image, with overlayed ball detection, the GUI exposes several additional features:

  • A set of predefined geometrical paths, where the robot tilts the platform to force the ball along specific trajectories. One of these is the "free-path", where the user defines the path on the fly by moving a finger on the touchscreen.
  • Automatic ball color calibration. This is one of the robot's most elaborate functions. The platform image, including the background, is analyzed for dominant colors and contour shapes to estimate the ball color and automatically define an optimized color range, reducing background noise as much as possible.

The main characteristics of this robot are also explained in the below YouTube video:

In the video, several features aren't mentioned, like the PID calibration page, the sensorless homing,  the custom I2C protocol, and many others.

  • PID parameters are adjustable via sliders, with immediate real-time effect. This makes tuning highly intuitive, since cause and effect are instantly visible. The Integral term is generally unnecessary when the platform is properly levelled, but it also becomes an educational feature when intentionally tilting the whole robot, where the Ki term helps compensate for the bias.
  • Sensorless homing parameter adjustment (StallGuard sensitivity). The robot uses TMC2209 silent stepper drivers, whose StallGuard feature automatically detects the platform home position. From there, the motors move a predefined number of steps to reach the balancing position, where the motor arms are approximately horizontal, allowing about 40 degrees of platform tilt.


Custom I2C protocol (Python ↔ MicroPython, with pre-encoded parts in C)

This is another key area of the project, worth mentioning here despite being covered in detail across about 10 pages of documentation.

A Raspberry Pi 4B acts as the brain of the robot and sends commands via I2C to three RP2040-Zero boards controlling the stepper drivers.

I wanted to use RP2040-Zero boards because I really like the PIO features, here used to generate precise quantities of motor steps at the intended speed. However, I could not find a suitable MicroPython library to use the RP2040 as an I2C receiver, so I implemented code originally suggested by danjperron on a Raspberry Pi forum.

At a high level, the Raspberry Pi sends 2-byte packets containing speed and step-count information, encapsulated in a custom protocol using STX, escape characters, checksum validation, and ETX markers at at 200KHz.

The RP2040 first validates the received packet and then decodes the data fields into speed, direction, and number of steps.

Since the I2C communication runs on core1 of the RP2040, while core0 handles the remaining tasks, the two cores exchange information through the mem16 shared-memory area.

Thanks to the PIO feature, despite the relatively limited execution speed of the MicroPython interpreter, the RP2040 boards operate very reliably. In practice, this reliability allowed me to design the communication as almost entirely mono-directional: the Raspberry Pi sends commands to the RP2040 boards and simply trusts the job gets done.


Here below the block diagram:

From the diagram you might have noticed the "Sync"...

Read more »

  • Added a Quick Start Guide

    Andrea Favero • 09/12/2026 at 11:46 • 0 comments

    2026/09/12

    Because the complete manual (MirrorBallBot_ReferenceManual) is almost 170 pages, it could intimidate at first glance, so I derived a shorther version (MirrorBallBot_QuickStartGuide) that only focuses on making the robot. The Reference Manual remains available.

    The Quick Start Guide is suggested for most makers: It's concise, action-oriented, and will get you from zero to a working robot with minimal friction.  The Reference Manual is suggested when you want to understand *why* something works, encounter an issue not covered in the Quick Start Guide, or are curious about the design process, custom I2C protocol, PID controller theory, etc.

    Recommendation: Start with the Quick Start Guide. Follow the steps, and refer to the Reference Manual only when you need more detail.

  • Added a fully 3D printable version

    Andrea Favero • 08/27/2026 at 19:59 • 0 comments

    Fully 3D printable version is available


    I've recently develloped a fully 3D printable version, for interested makers who aren't well equipped for wood working.

    This version has a smaller footprint, it wights ca 3Kg, and it works well.

    Despite being ca 1Kg lighter thatn the wooden version, it doesn't move around when it's functioning.

    On the 3D printing aspects:

    • STL (amd STEP) files are available at https://github.com/AndreaFavero71/mirrorballbot/tree/main/3d_models/fully_3d_printable
    • The bottom base has been spli into two parts, fitting on a 210x210mm printing plate (like for the Ender3 I have.)
    • Like per the original wooden base version, wires are fully hidden in between the two base's layers.
    • This moedel requires ca 600 grams of additional filament, and considerably printing time.
    • All the parts can be printed without support; 30% infill is suggested for proper screws' bosses connection to the parts.

View all 2 project logs

  • 1
    How to make MirrorBallBot

    This robot has been designed to be open-source, that makes the thinking process a bit more outside-in. This also means I wrote extensive documentation, covering several aspects of the robot.

    Because the complete manual (MirrorBallBot_ReferenceManual) is almost 170 pages, it could intimidate at first glance, so I derived a shorther version (MirrorBallBot_QuickStartGuide) that only focuses on making the robot. The Reference Manual remains available.

    The Quick Start Guide is suggested for most makers: It's concise, action-oriented, and will get you from zero to a working robot with minimal friction. 
    The Reference Manual is suggested when you want to understand *why* something works, encounter an issue not covered in the Quick Start Guide, or are curious about the design process, custom I2C protocol, PID controller theory, etc.

    Recommendation: Start with the Quick Start Guide. Follow the steps, and refer to the Reference Manual only when you need more detail.

    Just for reference, the ReferenceManual is organized in almost 40 chapters and divided in into 4 main sections:

    • Section 1: Introduction.
    • Section 2: Make the robot.
    • Section 3: Use the robot.
    • Section 4: Useful (or interesting) info.
    • Introduction:
      • Overview
      • Key innovations
      • Robot architecture
      • Blocks diagram
      • Safety and expectations management
    • Make the robot:
      • BOM
      • Wooden or 3D printed base version
      • Make the MirrorBallBot PCB
      • Make the wood base
      • Setup the Raspberry Pi 4B+ and the RP2040-Zero
      • First tests
      • Assemble the robot
    • Use the robot:
      • GUI
      • Calibrations
    • Info (my preferred part 😊, yet not strictly needed to build the robot):
      • Inspiration
      • Design process
      • Main innovations and main characteristics
      • Custom I2C protocol
      • PID balance Controller
      • Configuartion parameters
      • Troubleshooting
      • Q&A.

     The documents can be downloaded from this GitHub folder: 

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates