Skip to content

Ball Balancing PID System: control of a 2 axis platform for ball stabilization w/ visual servoing.

License

Notifications You must be signed in to change notification settings

giusenso/Ball-Balancing-PID-System

Repository files navigation

Ball Balancing PID Systems

Table of contents

Project description

The Ball Balancing PID System is a cheap multidisciplinary project I developed in 2018 during my BSc in Automation Engineering. This system holds a ball in balance on a 2-axis tiltable plate. A webcam is placed above the system, connected to a computer running a real time computer vision algorithm for ball detection. A feedback control law is computed by means of 2 PID controllers. Finally, a microcontroller actuates a pair a of servo motors, stabilizing the ball over the plate.

The project is designed to be modular; there are 4 main stand-alone modules:

  1. Computer Vision Module: acquires and preprocess ball position using OpenCV libs.

  2. PID Module: filters and computes the control input through a digital PI-D.

  3. Serial Communication Module: it provides communication beetwen PC and microcontroller.

  4. Actuation Module: embedded software running on microcontroller. It uses interrupts to detects incoming packets and drives servo motors.

Hardware

  • microcontroller: ATmega2560
  • Servos: DS3218MG 5V-6.8V
  • USB camera: 640x480
  • Battery pack: 6V, 2850mAh

Technologies

  • OS: Ubuntu 16.04
  • Language: C/C++
  • Compilers: gcc 5.4.0, avr-gcc 4.9.2
  • Additional libs: OpenCV 3.4.1

Software Workflow

General overview:

PC side detailed workflow:

Control System

Double PID control scheme:

How to use it

Compile and run with one of this flag:

  • Standard mode: better performance but minimal GUI
"./run -s"
  • Setting mode: set pid gains and computer vision parameters
./run -settings
  • Debug mode: start debug mode: a better GUI and print utilities, little bit slower than standard mode
./run -debug
  • Manual mode: platform can be controlled directly from terminal.
./run -manual

note: one and only one flag can be used