# PID controllers?

Hello, I was charged for programming homework by my mentor to find out what a PID controller is. I looked online, but all I get are confusing algorithms. I have not had a math class in a while and I have not programmed using labview in a while. So, needless to say, I don’t know what the PID articles mean.

I know P means proportional
I means integral
and D means derivative

Can someone please explain in simple terms how it works? Thanks!

Have you tried the FIRST wiki? When I learned about PIDs last year, I found that very helpful. try this link.

Essentially, what you need to know is that PID controllers make sure you move a motor (or robot, or something else) to the exact right spot using a sensor. It makes sure there is no over–or under–shoot by giving you real-time feedback. I don’t know if you are using the WPIlib for C++ or not, but if you are there is a really good class that implements a PID controller for you.

PID stands for “Proportional, Integral, Derivative”. A car’s cruise control is a good example of a system controlled by PID. You set it for a particular speed, and it controls the throttle to maintain that speed, uphill, downhill, whatever.

The first part of the algorithm is proportional to the “error”, the difference between your actual (whatever - speed for example) and the set point. If you set cruise control for 40 MPH, you only want a little throttle if you drop to 39 MPH, but you want more if you drop to 30 MPH. The error of 1 MPH is less than the error of 10 MPH, and the throttle application is proportional.

But let’s say the engine is powerful, and a little throttle at 39 MPH brings the car up to 41 MPH. You back off the throttle, but the whole process repeats, and you get sick from the speed changing so often… So you put in little less Proportional, but then a small speed error doesn’t have any effect - so what you do is integrate the error over time, literally adding up a whole bunch of small error every second, and eventually it gets larger and you can use that to correct the small error, so 39.5 MPH gets to 40 MPH.

In some systems, you can’t control the throttle so finely, so then you also use Derivative, which limits how fast you can change the throttle setting - kind of like just slowing things down a little “you can’t increase more than 1/2 inch per second”. This keeps the control algorithm from overcontrolling.

Many systems can get by with only P. I can be added in some cases, and only a few systems also need D to work properly.

Learn those algorithms, they are simple math (addition, subtraction and multiplication) just repeating many, many times. Once you get them, the concepts are understood for life.