How do PID Controllers work?
Let’s say we want to keep a ball perfectly in the centre of a table.
If it’s far away, we’re obviously going to want to push it towards the centre. The further away it is, the faster we want to push it towards the centre. So we apply a force **Proportional** to the distance from the centre.
This is cool, but what if there’s wind? Then we’ll be pushing against the wind, and our ball will end up slightly off centre because of that wind. We can look at how far off the centre we have been in the past, **Integrate** that distance from the centre over the entire past, then add a new force pushing based off of the integral. This lets us add a force to push against any constants like the wind.
Finally, we have one last issue. Pushing the ball towards the centre is good and all, but sometimes we’ll push the ball so hard that we overshoot, start pushing back, overshoot again, etc… You end up wiggling the ball back and forth instead of keeping it in the centre. We can add a new force to slow down the ball if it looks like it’ll overshoot, based off of the velocity, or the **Derivative** of the position to prevent overshooting.
This happens to be useful in a lot of different situations, not just for keeping balls centred.
This is a very broad subject so I will answer a bit vaguely (i.e. no complex planes, damping factors, natural frequencies, etc)…
Let’s assume we are managing the throttle of a self-propelled train car following a caboose. We want the sell-propelled car to maintain a distance of 100′ behind the caboose (the 100′ distance is what we call the set point)…
Proportional (present error)–
We look at the current distance between how far we are from the caboose and the 100′ where we want to be. If we’re really far away, then we probably want to hit the gas hard to catch up–the farther away we are the harder we want to hit the gas. The opposite is true if we are close to the train.
Differential (future error)–
We look at how quickly we are approaching (or receeding) the set point (100′ from the caboose). If we are approaching the set point really quickly then we want to decrease the gas a bit even if we are relatively far from the set point–if we didn’t do this, then we might overshoot where we are trying to aim for. If we’re not approaching quickly enough or are actually going away from the set point then we will want to add gas to get to the set point quicker.
Integration (past error)–
We are summing our error continuously. We want zero error. If our error over time is not zero, then we want to adjust our gas depending upon how long our error has been present. If we’ve been falling behind for a long time, then we will add a little extra gas to help get rid of the error that hasn’t been taken care of already. This factor help eliminate any steady state error.
A PID multiplies a coefficient to each of the error terms in the hopes of making a system arrive at its set point as quickly as possible with as little overshoot as possible.