PID math demystified, part 4



In the first three blog posts (see Part 1, Part 2, and Part 3) we covered the basics of PID math. We started with the basic proportional-only controller and worked in the integral and derivative components. Well before get too far, let’s review the proportional-only controller:

u(t) = Kpe(t)


Kpe(t) is the proportional component, the P in PID. e(t), usually called “error,” is simply the difference between the setpoint and the process variable. Kp gain is a factor that is multiplied by the error to give you the new output—the new valve position. It’s that simple. The error at that instant of the scan is calculated and the new output is calculated.

The pseudo code that we discussed was:

Error = Setpoint – ProcessValue
Output = K * Error

With this code the output changes immediately after the error changes. I like to use a cruise control on a car as an example. As soon as the car starts to slow down as it starts to climb a hill, the change in error (speed) immediately causes the output to change.

But what if you know that the speed is about to slow down? What if you can see the hill coming? That’s where feed forward comes in. The first step is detecting a condition that will affect the process value. This can be an upstream flow rate that affects a level controller, a pressure change that affects a flow controller or any number of variables. The important thing is that the feed forward signal has to have a predictable affect on the controlled variable.

The math behind it is conceptually pretty simple. The feed forward signal is multiplied by a gain and then added directly to the output:

Error = Setpoint – ProcessValue
Output = K * Error + FeedForward * Kf

That way as long as the feed forward signal doesn’t change, the controller is not affected. But, a change in the feed forward signal immediately makes a proportional type shift in the output.

The math does get more complicated when the time that it takes for the signal to affect the process value has to be considered. In that case a lead or lag calculation must be done to slow down or speed up the feed forward signal. But that’s a topic for the next post.


Nuri , Newfoundland and Labrador, Libya, 06/15/14 06:52 AM:

Andres , Non-US/Not Applicable, Argentina, 07/11/14 11:40 AM:

very interesting and didactil explanation , please keep posting!
FRANCIS , NH, United States, 07/11/14 04:07 PM:

You omitted the output-bias term from the proportional controller equation. It sets the value of the output when the error is zero. It is also called "Manual Reset."
MOISES , Non-US/Not Applicable, Venezuela, 07/21/14 06:46 PM:

very important to people looking for understand control
Anonymous , 08/08/14 01:39 PM:

Scott, thank you for your posts on PID controls. You really explained the concept. Once you grasp the concept you never forget. It makes relearning the math trivial.


Big Data and bigger solutions; Tablet technologies; SCADA developments
Automation Engineer; Wood Group
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
click me