Control Systems and Feedback Loops

Author: Joe H., Inflow Engineer

We’ve talked a good deal about some of the processes that engineers use to design systems at a high level, but today we’re going to dive down into some of the implementation details and talk about feedback loops and control systems. We’ll look at what control systems are first, then look at feedback, and see how to use it to regulate the behavior of a system. Finally, we’ll talk about one of my favorite control systems, the PID controller, and how you can use it in a non-engineering setting.

A control system is the mechanism that governs how your system behaves. The thermostat in your house is a control system, and so is a light switch for that matter. Almost anything with moving parts is going to have some sort of control system. Generally speaking, a control system falls into one of two categories, open loop or closed loop. A thermostat is a closed loop system, and a light switch is an open loop system, so let’s use them to explore the difference between the two categories.

An open loop control system is one where the controller does not monitor the output system, such as the light switch we mentioned above. If you read my earlier post on black boxing, you should remember that one way to look at a system is to ignore how the system functions, and focus instead on the inputs and outputs of the system. In the case of a light, you have inputs of electricity, the light switch in an “on” position, and an output of light. The light switch doesn’t care how much light the bulb is generating; in fact, it doesn’t look at the system output at all, it just responds to the inputs a certain way and assumes that the system will function as designed. The lightbulb could be dead, or missing completely, and the control system would not change its behavior at all.

On the other hand, a thermostat monitors the temperature of the air and uses that to adjust the behavior of the air conditioning/heating system it controls. The output of the system, the temperature, is monitored and compared to the desired temperature, and the behavior of the system is adjusted as needed. This makes the thermostat a closed loop controller, one that takes the output of a system, compares it to a desired value, and then modifies the behavior of the system to get a more desirable output.

Looking at these two types of control systems, it should be clear that the difference is the use of feedback in the closed loop controller. Strictly speaking, feedback is any part of the output of a system which is passed back into the system. Feedback can actually be undesirable, such as when a microphone gets too close to a speaker. The microphone amplifies whatever sound it detects, and then the speaker outputs the sound, which is picked up by the microphone and amplified again, and so on in a feedback loop. In order to use feedback to control a system, we need to carefully control what part of the output gets passed back in, as well as what the system does when it gets that input. In our thermostat example, we’re not just pumping air back into the system, we’re measuring the temperature of the air. In other words, we’re only looking at part of the output, and we’re creating a buffer between that input and the output of the system by comparing the actual output with a theoretical desired output. With a good set of metrics, it’s fairly easy to figure out what parts of the output you need to measure for a closed loop system (for instance, we really don’t care about the chemical composition of the air in our thermostat example, even though it’s part of our output), but the comparison process can get a bit tricky.

One of the more common ways to handle the comparison of actual outputs with ideal outputs is with a PID, or Proportional-Integral-Derivative controller. A PID controller takes the output value of a system and subtracts it from the desired output value to create what is known as an error value. Using that error value, the controller then uses three types of mathematical operations to generate a new input value of the system, bringing the actual output closer to the desired output and reducing the error value. Note that we’ll need a separate PID controller for each input value we want to adjust.

As you may have guessed, the three operations performed by a PID controller are proportional scaling of the error value, integration of the error value over time, and derivation of the error value with respect to time. This allows a PID controller to correct the behavior of the system based on present error values, past error values, and predicted future error values. The results of each of these operations are added together to create the new input for the system being controlled. In order to understand exactly how a PID controller works, let’s look at each operation in a little more detail. We’ll keep the math to a minimum, since there’s a bit of calculus involved behind the scenes.

The first operation, proportional (P) scaling (or gain), adjusts for the present error value in the system. Since the error value is the desired output value minus the actual output value, when the output is lower than it should be, the error rate is positive. This increases the input value generated by the controller, causing the actual output value to increase as well. When the actual output value is larger than the desired output, the error rate is negative, and the controller reduces the input value, preventing a feedback loop.

The second operation, integration (I) of error over time, accounts for previous error values in the system. For those of you without a calculus background, an integral is used to calculate the area under a curve. This allows you to take a continuous series of measurements and add them together to get a single value. In a PID controller, we look at the output of the system as a function of time, and subtract that from the ideal output of the system as a function of time to get the error rate as a function of time. If the actual output value is lower than desired most of the time, the result of integrating the error rate function will be positive; conversely, an output value which is predominately greater than desired produces a negative result. In other words, the more often your output is low or high, the more the controller will reduce or increase the input value.

The final operation, the derivative (D) with respect to time, estimates what the error rate is going to be in the future. A derivative computes the change of the output of a function compared to change in the input of the function. Since the PID controller is looking at a continuous series of measurements over time, the derivative operation measures how the error value is changing with respect to time at any given moment. When the actual output value of the system is getting closer to the desired output value, the error rate decreases and the derivative operation gives a negative value; if the actual output value is getting further away from the desired output value, the operation gives a positive value. The larger the rate of change in either direction, the greater the magnitude of the derivative output. If the actual output value isn’t changing at all compared to the desired output value, the derivative is zero. Put simply, the derivative operation makes a large correction when the output value is moving away from the desired value quickly, causing the actual output of the system to converge with the desired output of the system more quickly than it would otherwise. It also reduces the amount of adjustment the PID controller makes as the actual and desired output values converge, preventing the controller from over-correcting.

Each of these operations responds to changes in output differently, and since different systems behave differently, a PID controller uses a multiplier for each operation to control how much influence each one has over the whole system. If needed, the multiplier for one or two of the operations can even be set to zero. We’ll talk about how to figure out what multiplier to use next week, but for now it’s important to notice that the PID control has no insight into how the system its controlling actually works. The system is treated as a black box, which allows the PID controller to be used for a wide variety of applications, although there are systems where PID controllers aren’t the best choice, it’s a great example of how powerful the concept of black boxing a system can be once you start to really apply it.

Now let’s look at how the ideas behind a PID controller can be used in non-engineering settings. First and foremost, you need to look at your process as a black box system. You need to be able to identify exactly what you want your process or system to produce, and also identify the key input for generating that output. For example, if you run an organization which generates policy papers, you could look at the number of papers as the output, and the number of employee man-hours as the input. Let’s assume that you want to produce 10 papers a week of a given minimum length. The first month your firm spends 10 man-hours on producing papers, and generates 2 papers; our output value is lower than desired. We could run exact calculations, which is what you would do with an autonomous system, but since we’re estimating, we remember that when the actual output value is lower than the desired value, both the proportional and integral operations are positive. Moreover, the result of the derivative operation gives a small negative value when the actual output moves slowly towards the desired output. That gives us two large positive values and one small negative value, so we increase the number of man-hours. Let’s go with 20 hours. If that results in 7 papers, then once again the proportional and integral operations are positive, but smaller than before. The result of the derivative operation is a slightly larger negative value than before, since the actual output moved towards the desired output more quickly, so for our next input value, let’s jump to 26 hours. For the sake of the example, we’ll assume that 26 man-hours results in 11 papers. Now we’ve overshot our goals, so the proportional value will be a small negative number. The result of the integral operation will be just a little lower than before, but still positive, since we’ve been undershooting our goal for most of the process. The result of the derivative will be about the same as it was before, since the change from 7 to 11 is close to the change from 2 to 7. We take that all into account and use 24 man-hours as our next input, and get 10 papers.

This was an extremely simple example, but hopefully it illustrated how applying the concepts of PID controllers to a process can allow you to fine tune it much more accurately then simply guessing at the input values. In the example we used, someone with a bit of real world experience could probably give an accurate off the cuff estimate without having to do as much work, but if you have a more complex process, this can be an incredibly powerful method of managing it without having to understand all the intricacies of the process. Because you’re not just looking at the present value of your process output, but also at how the process has behaved in the past and will likely behave in the future, you can make much more accurate judgements about how many resources to apply. In my next post, we’ll look at fine tuning this type of control system, and talk about process optimization in general.

If you want to brush up on your higher math skills, you can check out for a quick primer, or for a full, free, online introductory calculus course.

-Joe H., Inflow Engineer


At Inflow we solve complex terror and criminal issues for the United States Government and their partners, by providing high quality and innovative solutions at the right price through the cultivation of a corporate culture dedicated to being #1 in employee and customer engagement. We Make it Matter, by putting people first! If you are interested in working for Inflow or partnering with us on future projects, contact us here