# Of Feedbacks and PIDs

Let's look at a principle in control theory: feedback loop. It occurs when outputs are measured and fed as inputs to a control system/controller. The controller takes decisions based on these inputs and/or on the setpoints defined by the user and sends control commands back to the plant, closing the loop. Why would you need to get the information of the output? A control system is the brain of a device, to function correctly, our brain absorbs our surroundings too, right?

### Getting Surroundings Right

So, the basic idea of a control system is to figure out how to generate the appropriate actuated signal, the input, so that our system will produce the desired controlled variable, the output. We want the right measurements into the system to get the correct controlled variable, thus a correctly functioning device. But how can you achieve this? The feedback loop needs controlling, and that's where the proportional-integral-derivative controller (PID controller) comes into play (that's just one of many other feedback controller types, there are P controllers, PI, PD, etc.): It compares the setpoint to the measured output to see how far off these to measurements are (valid for any feedback controller). The difference between the two is the error term, and we want this term to be zero. There is a lot of math behind this; I will only go this far with it: our brain/controller not only calculates the error term but also applies a correction. In the case of a PID controller, it's based on, and this is also why it has such a long name, proportional, integral, and derivative terms (however, you can have controllers that are only proportional, only integral, etc.). Without the controller's corrections, we'd get an endless loop of the same thing and never get to zero.

### Getting to (Almost) Zero

Okay, so we want to get to zero in the error term. Therefore, we have to look at the different actions a PID operates to address the shortcomings and stability of the system. Let's go through the name quickly:

Proportional: pure proportional controllers can still be a bit sluggish or produce oscillations, which is why in PID controllers, these shortcomings are eliminated by introducing the derivative for stability. Also, purely proportional controllers do never achieve zero steady-state error in most cases.

Integral: is concerned with the effect of long-term steady-state errors and kills those (remember we want that zero) by applying increasingly more effort.

Derivative: it makes sure that the measured variable and the setpoint function in union. So, either it puts more pressure on (that's when the measured value moves away from the setpoint), or it makes sure the actuator is backed off early in the case the measured variable approaches the setpoint rapidly.

I'd like you to think of a cruise control: this is a typical use case for a PID. Why do you think that is? Well, it's a system that automatically controls the speed of a motor vehicle. This control system is a servomechanism (which in control engineering is an automatic device using sensor-data and negative feedback to correct the action of the mechanism) that takes over the throttle your car, meaning it maintains a steady speed, which is set by you (only if you're driving that is).

Hope this made things a bit clearer, if you are still a bit confused: I'd like to bullet point some helpful videos, that can probably sum this up much better than I can:

In this video, they talk about

__what control systems engineers do__(and it sounds fascinating).And this one starts wit:

__Let's talk about PID control__. Check it out!