Preferably PID functions on an Arduino uno or any other examples. I have been researching but many of the the websites really do not explain it.
P.S is there an algorithm for a PID? Thanks
I, also, didn't get the idea behind PID from just reading Wikipedia. After some videos/tutorials, I believe the best way to explain it is:
What is PID
PID is an algorithm. It involves three factors which can be adjusted to tune a signal.
It is often used in servo's (and things like thermostates, basic signal controllers)
The servo will be used in the practical examples.
A servo has: - a current position (signal) - the position you want the servo to be in (goal signal) - a speed (PID output signal)
The PID output signal/algorithm makes sure that the servo reaches it's goal.
PID is an algorithm that can adjust a signal towards an setpoint. Or correct it for that matter. It regulates how much you have to adjust the signal, without getting serious overshoot, or oscillation around the setpoint.
P stands for proportional.
Which means that the further the servo is from it's setpoint, the more speed we want to/can give it. So that we're faster towards the set point. This also means that we slow down as we near the set point. Of course you can multiply each of these rules with a factor, to achieve a better balance.
I stands for integrating.
It basically comes down to the fact that it constantly keeps adding to the signal, depending on how long there is a difference between the current point and set point. This is so that if P is still a little slow, it adds some speed over time.
D stands for differentiating
It's less commonly used. (Wikipedia) The D factor reacts on the speed of the change in value. Or speed of change in setpoint (Dutch wikipedia is not 100%, comment if neccesary :) )
These factors / the algorithm provides a smooth regulation of various systems, hence that's why it is so adjustable.
It can be used for balancing quadcopters or making your house comfortably warm (without sudden changes, or too slow changes)
How would you balance a quadcopter? If it shifts to one side, you don't want to fully reverse the throttle. It'll make it wobble, since you get a lot of overshoot. Controlling things can be hard, PID is an known working algorithm for those cases. But you have to adjust the factors right to adjust it to your specific system. (They all react differently, or have to react differently).
How a PID controller works depends on the particular implementation.
There is a algorithm/library for PID on the Arduino: http://playground.arduino.cc/Code/PIDLibrary and an excellent explanation of the all of functions within it at http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
Over on stackoverflow and electronics, there are some good questions and explanations that might help: