The basic concept isn't too bad. A PID controller consists of three main parts:
- A Proportional part: The controller checks where the ball is and where it should be. The larger the difference (called error here), the further it tilts the table. If the error is zero (the ball is where it should be), the table is level. Mathematically, it multiplies the error by a constant value and applies it to the output (the tilt angle). This makes the applied action proportional to the error.
That alone isn't sufficient to stabilize the system however. If the ball is rolling towards the center, it probably won't stop there, but roll through it. The ball could also sit still very close, but not exactly at the center. The tilt applied wouldn't be enough to correct that error. That's where the I and D parts come in:
-
The Integral part integrates (sums up) the accumulated errors of the past, multiplies it by another constant and applies it to the output. So even if the ball rests very near the center, the sum over that small error quickly builds up over time and an appropriate tilt is generated.
-
Finally, the Derivative considers how fast the error changes (its derivative). If the error changes very quickly, the controller applies a large correction to the output to quickly damp out that error. This would help to avoid overshooting the center for example or the ball starting to oscillate around the center.
Figuring out the math and how it applies to your physical system is a bit more tricky however, especially when you consider things like stability and damping. But the concept I described should give you a good idea of how they work in principle.
This is such a good example and description of PID loops. I'm a process engineer and spend a lot of time trying to explain PIDs to semi skilled plant operators, and fail miserably (I'm a terrible teacher), I am stealing and the video to help me lmao
Car cruise control was the example that really helped me first get the concepts, since it is something that I had a lot of actual experience, and it is easy to see the effect of the control on the system.
this video also does an excellent job of explaining it.
Controls can be esoteric and unintuitive so seeing it in action and explained so well helped.