This project demonstrates the design and implementation of a real-time closed-loop control system that autonomously balances a steel ball on a two-axis tilting platform. The system combines mechanical design, sensor integration, and control theory to create a responsive mechatronic system capable of dynamic stabilization.
Technical Approach:
The platform uses a 7-inch resistive touchscreen overlay as a continuous position sensor, providing millimeter-level resolution of the ball's X-Y coordinates. Two MG996R servo motors actuate the platform via custom linkage arms, enabling independent control of both horizontal axes. A Raspberry Pi 4 serves as the central controller, processing touchscreen data via a dedicated STP-RAP45U2U-S USB controller that handles analog-to-digital conversion and coordinate filtering.
Control Implementation:
The control architecture employs dual PID controllers—one per axis—operating at 100 Hz to minimize positional error and achieve stable balancing. The system was modeled as a two-degree-of-freedom dynamic surface, with the ball treated as a point mass and the servos as first-order actuators. Initial controller tuning was performed in MATLAB Simulink, and then refined through iterative physical testing to account for real-world dynamics such as friction and servo response characteristics.
Software & Hardware Integration:
The control loop was implemented in Python using the pigpio library for precise PWM servo control and the evdev library for touchscreen input processing. The software continuously reads the ball position, computes the normalized error relative to the platform center, updates the PID controllers with appropriate integral windup protection, and converts control outputs into servo pulse widths between 1000 and 2000 microseconds. The platform autonomously returns to neutral position when no touch input is detected, demonstrating robust disturbance rejection.