PID Equations

   The PID equations are the core of most control systems.   They consist of three different ways of computing  a control command from the error between an input reference value and the actual value that the system is achieving.

    The Proportional equation creates a correction signal which is proportional to the error.

    The Derivative equation creates a correction which is proportional to the rate of change of the error signal.

    The Integral equation creates a correction signal which is proportional to the error signal multiplied by the time the error exists.

Intuitive PID

    Before going into these equations further,  let's try to get a feel for what these equations really do.  I'm going to use the example of steering a car since it is something we all think we understand.  

    Imagine you are driving down the road trying to steer so as to stay in the center of your lane.  We'll assume your cars steering works perfectly and the steering wheel is straight up when the car is going straight and it takes no force on the wheel for you to hold it straight up.  So when the car is going down the center of the lane, it should take "zero" input from you to keep going straight.

    So,  let's say you reach down to tune the radio, and when you look back the car has drifted two feet to the right of center.  Your first reaction will be to turn the steering wheel a bit to the left to turn the car back toward the center.  You'll probably turn the wheel farther than if the car had drifted over only one foot; and not as far as if it had drifted over 4 feet.   This is the proportional part.  All it means is that the farther you are away from your reference, the more you will turn the wheel to make your correction.

    Now, having been distracted for another second, you look up to see that the car has turned toward the left such that it is moving rapidly toward the center of the lane.  You realize that if this goes on for much longer, the car will go over onto the left side of the lane.  So, you turn the steering wheel to the right to reduce the rate at which the car is moving left.  If the car is moving left VERY rapidly, you move the wheel right a lot.  If it is moving left slowly, you move the wheel right just a bit.  This is the Derivative part.  It seems very similar to the proportional gain except that it reacts to the speed at which you are moving sideways rather than the distance that the car is displaced sideways.

    So, the proportional term says to turn toward the center, and the derivative term says to turn away from the center (as you approach it, or toward the center if you are moving farther away).  If both of these terms are used, there will be a balance such that a large offset will cause a large wheel turn toward the center which will be balanced out by a large rate toward the center causing a large wheel turn to away from the center..  The two equations will tend to cancel each other out; but the amount that they differ will direct the car to the left or right in such a way as to push the equations toward balance.    Hence, as the car approaches the center, the rate will become smaller and smaller until the car is in the center with zero rate.  This is pretty much the way you steer your car when things are running smoothly.

    What's the integral term good for then?  Integral terms are good for when there are biases in the system.  Maybe your car has one low tire, or a bent suspension, and is pulling to the right.  Or for our simple case, let's just say the steering wheel is installed so that the car goes straight forward when the wheel is turned left 20 degrees.  So, if you try to steer your car straight ahead by placing the steering wheel at zero (straight up), the car will turn right.  You'll soon figure out that you have to hold the wheel 20 degrees left, but let's speculate on how you come to that conclusion.  You'll probably start holding the wheel straight up (zero degrees) and observe that the car is moving right.  You'll probably turn the car a bit to the left and notice that it is still turning right, so you'll add a bit more to the left.  You'll keep adding more turn to the left until you see that it isn't turning right anymore.  At this point you'll have figured out that you have to add 20 degrees left to all your steering calculations and you'll just do that from now on.  You may even rotate your hands on the wheel so that your hands are steering straight when the wheel is 20 degrees left.  But, the thing to note is that you kept adding more correction over time until the problem went away.  This is exactly what an integrator does.

    So let's look a little more at each of these terms:  (and, no, they are not in the  P - I - D order, but it makes more sense to do Proportional then Derivative then Integral)

  Return to the Control law menu to select the next subject