Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/milind220/ball-balance
A PID algorithm controlled ball balance that returns a ball to a set point when it's pushed around. My first real robotics project!
https://github.com/milind220/ball-balance
arduino ball-balancing-pid ball-balancing-platform control-theory cpp pid-control robotics
Last synced: 14 days ago
JSON representation
A PID algorithm controlled ball balance that returns a ball to a set point when it's pushed around. My first real robotics project!
- Host: GitHub
- URL: https://github.com/milind220/ball-balance
- Owner: Milind220
- License: gpl-3.0
- Created: 2021-10-27T16:49:47.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-29T09:10:31.000Z (about 3 years ago)
- Last Synced: 2024-11-09T05:37:58.613Z (2 months ago)
- Topics: arduino, ball-balancing-pid, ball-balancing-platform, control-theory, cpp, pid-control, robotics
- Language: C++
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PID Algorithm Ball Balance
This is a project that I made to better understand and apply the concept of PID control algorithms. The basic idea of this project is that a ball or a toy car is placed on the see-saw part of the balance, which actively tries to keep the object in the center. If the ball/toy car is externally disturbed, the balance/see-saw tilts in the opposite direction to negate the movement of the object.
In my project, the control algorithm I used was a simple PID (proportional-integral-derivative) control.
You can find complete videos of the project [here](https://drive.google.com/drive/folders/1BQwBAJkQs052C5EKD3FMkhIT8mthKC8j?usp=sharing)
## How it works
An ultrasonic distance sensor (HC-SR04) mounted on one end of the see-saw measures the error (the distance between the set point, and the position of the object). It does this ~ 50 times/second, and feeds these readings into an Arduino Uno mounted on the base. The loop function in the Arduino contains the PID algorithm. With every run through the loop, it generates a total 'feedback value' based on the P, I and D gain values set. This is then mapped to a range of values which in turn control a servo motor (MG-996R) attached to the see-saw/balance.
This completes the closed loop control system.## Gain Values
I set the gain values through trial and error. To begin with, I set the I and D gain values to 0, and tuned the P value until the balance returned the ball/toy car to the set point with only slight oscillation.
I then zeroed the P value as well, and tuned the D gain in isolation until the balance was effectively able to negate the velocity of the moving car/ball. At this point, with some additional minor tuning, the P-D controller was already very effective at returning the object to the set point and stopping its motion there.
For the I gain, I experimented with very small values and limited its max value to prevent oscillation. I also set a limitation that ensures that I gain is only considered when the object is within a very short distance of the set point.
P gain: 5.3
I gain: 0.07
D gain: 1800