**Introduction**

The Celtic Engineer is a weekly newsletter produced by Celtic Engineering Solutions. We hope you enjoy it. If you have any suggestions for topics, would like to give feedback or want your email added to the distribution list please send an email to [email protected].

**Political Intelligence Department. Not!**

Granted, it would be a very small department, but this is an engineering newsletter. So, the PID I want to talk about is the Proportional-Integral-Derivative controller. A controller is quite simply a device that controls something, a parameter of a system. There are many types of controllers, but they fall into two broad categories: those with feedback and open loop controllers.

The controller can be thought of as a plant. It has an input and an output. The plant performs an operation on the input to produce the output. One example of a controller, that we are all acquainted with, is a thermostat. If we designed one that was open loop, its input would be the desired temperature. There would be some equation that operated on that number and the output would be connected to the gas feed rate to our furnace. No information about how well the job was going (i.e., the temperature) would be returned to the controller. If we wanted it to be hotter we just turned up the input. The same way you adjust the gas on your kitchen stove.

While that is a poor controller, it is a controller and you can use it to get a room to the desired temperature. If you just turn it on and dial in a random input value, the room will reach some indeterminate temperature. As long as the system does not change, for example the outside temperature remains constant, the room will maintain a constant temperature. If you adjust the controller you can get the room temperature to a desired value. In that case you are providing the feedback to the controller to allow it to reach a target temperature. You are part of the feedback loop.

**Negative feedback**

I grew up being told that if I didn’t have something positive to say I should just keep quiet. But not all negative feedback is bad. In the thermostat example, the input is the desired temperature, say 70 degrees Fahrenheit. The negative feedback is minus one times the actual room temperature. If the room is at 68 (or 64 in the case of my work area), the difference between the desired room temperature and the actual room temperature is -2 degrees. That is called the error function. If the error function is zero, the thermostat turns off the furnace.

**Types of controllers**

A thermostat is a controller that has a binary (on/off) output. A PID controller is one that provides an analog output. If your car has a speed controller on it, then you have used a controller with an analog output. In fact, there is a good chance it is a PID controller.

The P is for proportional. The output is proportional to the error or the difference between the desired setpoint and the actual operating point. The “I” is the integral of the error and D is the derivative of the error. Not all controllers use all three options. You can use any one, any two or all three. The combination used most often is the PI controller.

How are they used? The error is run into three separate plants. An output from each of the three plants is summed together and the output is used to drive the actuator, in our second example the accelerator of the car.

**Why do we need all three?**

Imagine you are on a flat road and you turn on the speed controller. It looks at the difference between your desired speed and your actual speed and applies an imaginary foot to your accelerator. At some point your speed with be really close to the setpoint and the speed of the car will be constant.

Why do I say close to the setpoint and not at the setpoint? Because a controller with proportional only control will never get to zero error. The residual error is called steady state error. It is the error that exists when things in the system become stable, they stop changing.

If the car then goes up a hill (a very flat and infinitely long hill) the controller will eventually reach steady state, a new operating point). The error will likely be larger than it was when the car was on the flat level road.

You can make the error smaller by increasing the gain, but higher gain systems are less stable. Sounds like a tradeoff, now where have I heard that before. Oh yes, we are engineers.

**Whatever are we to do?**

The integral term will keep increasing the output as long as there is an error. It is summing the error, or integrating it. As long as there is an error it will keep increasing the output. If the speed of the car is below the setpoint, it will keep pushing down further on the accelerator. It will drive the error to zero. That is why the most often used controller is a PI controller.

The derivative term is used to react to changes in the error. A small change in the error will provide a small output of the derivative term. While a large, read fast, change will garner a large output from the derivative term. It is used, but not often.

PID controllers are the workhorse of the controller world. There are many more exotic controllers but none used as much as the PID controller. Finding the correct values to use in each of the three plants is called tuning the loop. It is lots of fun. I cut my teeth on PID controllers while working on level and flow controllers in a chemical plant. Getting it wrong can mean a tank overflows or worse, is run dry which leaves a pump running with no fluid to pump, a condition called cavitation. There are many online simulators available. I would encourage you to try and tune a PID controller using a simulator and see how you do.

**Final thoughts**

This newsletter is sponsored by Celtic Engineering Solutions LLC, a design engineering firm based out of West Jordan, Utah, which can be found on the web at: www.celticengineeringsolutions.com. You can find the newsletter on the company blog, LinkedIn or by subscribing. Send your emails to The Celtic Engineer at: [email protected].