The math behind PID can be summed up in the equation below:
Where
is equal to the output given to the actuator, which in this case is a motor.
is the error in the system, which is
On the left, you can see the four terms of the equation separately, which will better help you see what components of PID are contributing, and in what ways.
. The P term reacts proportionally to error, the farther desired is from actual, the stronger it will be.
, The I term reacts to the integral of error, it will be persistent component that builds to approach the setpoint, but can very easily get out of hand, so keep in mind to cap it appropriately.
, The D term reacts to the derivative of error, so in appropriate quantities will act as a dampening factor.
Finally,
is whatever equation you put in the box below, and is meant to be a fluid way to react to eccentricities in the system itself.