https://github.com/qabasak/pid-balancer
A system that uses a PID controller to balance a ball on a tiltable platform. The system is built with an Arduino, ultrasonic sensor, and servo motor, with PID gain tuning via potentiometers. The control logic is designed and deployed using MATLAB Simulink.
https://github.com/qabasak/pid-balancer
arduino embedded-systems matlab pid-controller simulink
Last synced: about 1 month ago
JSON representation
A system that uses a PID controller to balance a ball on a tiltable platform. The system is built with an Arduino, ultrasonic sensor, and servo motor, with PID gain tuning via potentiometers. The control logic is designed and deployed using MATLAB Simulink.
- Host: GitHub
- URL: https://github.com/qabasak/pid-balancer
- Owner: QabasAK
- Created: 2025-06-13T20:23:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-20T23:59:12.000Z (about 1 year ago)
- Last Synced: 2025-06-21T00:30:13.733Z (about 1 year ago)
- Topics: arduino, embedded-systems, matlab, pid-controller, simulink
- Homepage:
- Size: 3.34 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Model-Based PID Ball Balancing System
This project implements a real-time PID control system to balance a ball at a fixed position on a tiltable platform. Developed using MATLAB Simulink for modeling and deployed on an Arduino Uno, the system demonstrates feedback control in embedded systems using sensors, actuators, and manual gain tuning.
### Hardware Components & Software Tools
Hardware components include Ardunio Uno for deployment, Servo Motor for platform tilting, Ultrasonic Distance Sensor for ball distance reading, Potentionmeters for Kp, Ki, Kd tuning. MATLAB Simulink for the design and simultaion, Serial Communication for data monitoring and External Model for dynamic parameter tuning.
### Simulink Ball Balancing System
An ultrasonic sensor reads the distance of the ball, and the signal is first scaled, filtered using a median filter, and limited to valid ranges. The processed value is then compared to a reference (25 cm) to compute the error.
This error feeds into a PID controller, where the proportional, integral, and derivative gains are dynamically set using potentiometers connected to the Arduino's analog pins.
The resulting control output adjusts a servo motor via Arduino pin 11 to maintain the ball at the desired central position. Display blocks are used throughout to monitor the system’s behavior in real time.
### Functionality Verification
Various figures of the PID control response were plotted, namely the immediate distance obtained from the ultrasonic sensor readings.
By placing the scope at the ultrasonic sensor’s output after filtering, the plot showcases the motion of the ball on the track.
The oscillations in the distance graph are due to a stopping edge placed near the ultrasonic sensor, which causes the ball to bounce slightly upon contact, preventing it from hitting the sensor directly.
The PID controller generates an output ranging from -90 to 90 degrees, which is used to set the position of the servo motor and adjust the platform accordingly.