Ball balancing robot

Introduction

This robot is a 3RPS parallel manipulator platform. The platform has 3 degrees of freedom with a spherical joint, allowing the platform to be angled in any direction. The project takes heavy inspiration from the ball balancer project by Aaed Musa. The project was started in late summer of 2023, with the intention of bringing it to the Aarhus Maker Faire as an exhibition for the Open Space Aarhus stand.

The finished robot at Aarhus maker faire.

Mechanics

The mechanical linkage of each of the three arms consists of two different links: Link A, which connects to the shaft of the stepper motor and has a pin joint connection with Link B, which further connects to the platform with a ball joint. The original intention was that both joints would be CNC-machined out of aluminum, with the CNC-machining done on a Pocket NC 5-axis mill. However, Link B was too long for the travel of this machine, and as such, the design of Link B was changed to consist of a piece of carbon fiber pipe, with machined endcaps for the two joints. Other parts, such as the platform, main body, and casing, were 3D-printed.

Left: Link A. Right: Link B.

Electronics

The electronics consist of three 1.8-degree stepper motors, driven by a BigTreeTech TMC2209 stepper driver and a Teensy 4 microcontroller controlling it all. To provide the controller with feedback on the ball’s location, a glass 4-wire resistive touch interface is used. Two step-down converters are employed to reduce the 12V DC input to 5V and 3.3V for use by the different components.

PCB

To connect all the electronics together, a custom PCB was designed. The PCB has 4 layers in a signal-ground-power-signal stackup. In addition to accommodating the various components, the PCB features connectors for the stepper motors, the touch interface, and a few potential buttons. Screw terminals are also provided for power input. This design allows the electronics to maintain a clean appearance while remaining easily disassembled.

The finished PCB.

Software

The software uses the excellent library by Aaed Musa for the inverse kinematics. To actually regulate the ball’s position, the robot uses a PID algorithm. This algorithm consists of:

  • Error - The distance the ball is from the setpoint of the PID algorithm.
  • Proportional Term (P) = kp * Error - An output that is proportional to the error.
  • Integral Term (I) = ki * ∫error - An output that accumulates the error over time.
  • Derivative Term (D) = kd * (d/dt) * error - An output that is essentially the speed at which the position of the ball changes.
  • Output = P + I + D - The output is essentially the most effective way to get the ball back to the center.

Using the PID algorithm, the robot is constantly trying to move the ball back to the setpoint for where the ball should be. The PID algorithm is tuned by adjusting the constants kp, ki, and kd, thus changing the magnitude of each output of the PID algorithm. In total, the controller is running 2 PID algorithms, one for the X and one for the Y direction.

To be done

A small list of things still to be done:

New touch interface

Sadly, the touch interface broke a few days before the Aarhus Maker Faire, so the robot only got to play as an advertising stand with an Open Space Aarhus logo on top. The current plan is to purchase an interface, preferably bigger, to allow more area of movement for the ball.

Rewrite software

During the integration hell part of the project, I had to make significant changes to the code to get it to work, resulting in a messy code base. I would like to get this rewritten and cleaned up.