In this post I complete all the functions of a PID controller by adding the D to the PI controller in the previous post. If you have not followed all of the posts related to modeling the car and the cruise control, you will be lost at this point and you need to go back to “Understanding why cars reach a maximum speed” and read the posts up to this one. Tonight I introduce the inverse function to the integral, the derivative. But first I need to talk about the spread sheet associated with this post. It is a little more complex.

Tonight’s spread sheet is again modified from the previous ones. Not only did I add the derivative columns, columns K and L, but I also added a lot more flexibility so you can play with the model. The color code is green items have to do with the car model, the yellow items are the controller gains, and the cyan items have to do with an upset we can do once the car has reached steady-state speed. This is the real reason we have cruise control in our cars. The cruise prevents us from loosing speed going up hills and gaining speed going down hills. These upsets take affect after 100 seconds in the model. As before the spread sheet PIDv4A can be downloaded, and this one is complicated enough that I also have a set of Instructions in pdf format that can be also be downloaded.

The integral function looked backwards looking at how long and how much error there was up to the sampling point and by doing that it acted as a memory. I jokingly last time referred to it as the memory in our big toe. The derivative function looks at how fast things are changing. Because of that it is a quick function. I thought about calling this post: “The Derivative – a boot in the butt”, because that is what the derivative in a controller does. It basically gooses the car quickly when extra power is required. However, it is not really forward looking because it still needs a change in feedback. The derivative function is not often used in controllers. All of the motor drives I tuned only had PI controllers and we will see why as we look at the graphs.

The first graph is a controller with no derivative gain. It is tuned a little “hot” and has a little overshoot.

The next graph shows the upset we are applying to the car once it reaches steady-state. The car is requiring 10 units of force to climb the hill for 20 seconds, it then travels for 20 seconds along the flat top of the hill and then goes down the hill for 20 seconds getting 10 units of force help by gravity.

The next graph shows the same controller and car combination as before, receiving this upset This is the graph we will be look at for the rest of this post. This graph shows the effect of each of the three parts of the PID controller as well as the total change in the output.

Now that we have a base-line we can see what happens as we increase the derivative gain.

The next plot is with the same values for P and I gain but the D gain has been increased to 5. The most noticeable thing is the fast rise and fall of the total output. However, because the derivative happens so fast, the change in the error is negligible.

A derivative gain of 10 causes very noticeable ringing in the output value. We are getting very close to oscillation. A derivative gain of 15 did not go into oscillation but the ringing was more severe. Notice there is a little change in the error, but not very much.

The final plot shows a derivative gain of 20. All hell has broken loose. I would not want to be driving that car because the engine would be making some really strange sounds and the gas pedal would be acting like a fan. Note that this was oscillating before we even got to the upset. This shows one of the dangers of using derivative control. The other problem is it often amplifies noise in the feedback because it is sensitive to changes. As I said, it is very seldom used in industrial controls.

A couple of things should you decide to download the spread sheet and play with the controller. One time when I increased the D gain to 20 and caused the oscillations I locked up my computer. It is not really a problem with the spread sheet except the spread sheet is fairly large and is calculation intensive. My computer seems to be having a problem with the graphics card and that is something I am not looking forward to tackling so I am kind of getting used to lock-ups, but I wanted to make you aware that if you have a weaker computer you may have some problems, especially if you throw the loop into oscillations.

I have several people that have e-mailed me that are constructing some computer controlled machinery. More than likely they will be running into a PI or a PID control loop. The implementation of the loop may or may not be exactly like this. Often the P gain is exactly the same as this but the I gain is often P gain divided by something called reset time and the reset time is adjustable. As always, read the manual.

This completes the controller. Future posts will show how these functions are implemented using Op-amps and then there will be a short and easy math one that shows some other uses for these Calculus functions and some typical types of curves. Do not worry this will not be math intensive, it is designed to get the concepts and the use for the math. I will leave it for others if you want to learn the whole math thing. Mostly it is all done with computers and microprocessors any more.

For now, think of the integral being concerned with how long and how much. The derivative is concerned with how fast. (How is that for good-ole-boy math?)

If you have any questions or concerns or suggestions, please e-mail me, I really would like to hear from you.

Gary

“Piddling with the PID Controller” by Create-and-Make.com is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

If you found this post interesting, please consider subscribing using one of the methods on the home page or the e-mail subscription service at the bottom of each page. If you know others that would enjoy this information, please share this post or the site address.

## Leave a Reply