A self-balancing ball system using PID #Python #OpenCV #PID @MicrochipMakes
Johan Link describes on Instructables a system that balances a ball on a plate:
This system holds a ball in balance on a plate. A webcam films the system and a python program analyzes the images to find the position of the ball. The python program calculates the tilting of the tray to prevent the ball from falling.
A proportional-integral-derivative (PID) regulator is used to compensate the movements of the ball. The position and speed of the ball are measured by the camera and these measurements are used by the PID regulator in the Python program.
The base is moved using a Microchip ATmega 32u4 microcontroller while the computer vision portion is on a laptop with connected USB camera. The computer uses a Python program and OpenCV to track the orange ball similar to this tutorial.
The code is available on GitHub here. It’s under a CC by SA 4.0 license.
See the video above for a demonstration and the Instructable here.
