A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

Putting the memory from our right foot into the controller.

Adding a Memory Component to our Cruse Control

Adding a Memory Component to our Cruse Control

In the post “Controlling the speed of our Rocket car – Proportional Control“, we had a very hard time ever getting the car up to speed.  At the very end of the post I explained why.  With proportional only control if the speed of the car equals the set-point speed, the speed limit, we would remove our foot from the gas pedal.  That is not how we drive our cars.  There is a memory component somehow  stuck in our right foot.  Tonight we are going to add that component and learn a math term called the integral.   Don’t worry it will be painless, we actually have already done one when we created the car model but I did not tell you that was what I was doing.

The integral symbol.

The integral symbol.

The integral as taught in school represents “the area under the curve”.  Area = Height X Width.  In our controller the height is the amount of speed error at any moment and the width is the time in seconds.  This means the integral in our use will represent “How much and how long”… Hey, that is memory!   Now, the question is how will we calculate it?

The spreadsheet implementation of a PI Controller.

The spreadsheet implementation of a PI Controller.

I have added a couple of columns to the spreadsheet.  As before, you can download this spreadsheet, PIDv3.xls and it will be very helpful if you do download it.  Column I which I call “Integ error” is calculated by taking the average value of the error of the previous sampling time and the error at the present sampling time (the how much) and multiplying it by 0.1 seconds, our sampling period.  This is added to the previous integral error value to give a running total.   Guess what?  This is exactly the same way we calculated speed from acceleration.   Speed is the integral of acceleration but I did not call it that when we did it.  Column J, named integ out is calculated by taking the integ error value and multiplying it by the Integral gain.  Column K, total calc out, is simply the sum of the proportional out + the integ out columns.  The output is then ran through a limiter to limit the value to 100% as we did in the previous post.

Proportional gain of 1

Proportional gain of 1

So what does this do for us?    The picture to the left shows what happens if we only have proportional control and proportional gain is set to one.  We never did get anywhere near the set-point speed of 55 MPH.

 

 

Proportional gain of 1 and an integral gain of 0.1

Proportional gain of 1 and an integral gain of 0.1

In the picture to the right I again have a Proportional gain of 1, but I have added an integral gain of 0.1.  WE REACHED THE SET-POINT SPEED OF 55!   It took us a long time, about 55 seconds, to get there, but we made it!  Can we do better?

 

 

Proportional and Integral gain both set to 1.

Proportional and Integral gain both set to 1.

In the plot to the left we have the same proportional gain of 1 but integral gain has been increased to 1 also.   We got to the set-point speed of 55 more quickly, but we blew past it and then over shoot the mark when correcting.  Hopefully, the state trooper is not behind us.   (The controller may be asked to take a sobriety test.)

The Proportional part primarily affects how fast the controller compensates for the error and the slope of the actual speed at the moment the set-point changed.  In this case, when the stop light turned green and we told the car to go.   The Integral part affects how fast the curve “closes in”.  The problem in this is the integral gain is too high for this proportional gain and the integration build up an excessive value.   This is called “integral wind-up and is especially a problem if the integral calculation is happening but there is no way the controller can change the real output.    Prevention of integral wind-up is the reason my real car turns off the cruise control when I step on the clutch.

Proportional gain of 2 and an integral gain of 0.2.

Proportional gain of 2 and an integral gain of 0.2.

The last picture in this post is tuned with the proportional gain at 2 and the integral gain at 0.2.   This settled in nicely and reached the speed in about 25 seconds.

The controller we have built is a Proportional Integral or PI Controller.  I have been naming the spreadsheets PID.  The D stands for a third part called derivative which is concerned with how fast things change.  It is normally not used but we will talk about it very soon.

Today on the way home from work I did a little experiment and you can probably repeat the same experiment.    I was driving with the cruise control on and set at the speed limit of 65 mph.   I then depressed the the “coast” button and allowed the car to slow down to about 60 mph and then released the coast button.   The car then continued to slow down to probably about 56 or 57 mph but then picked up power and accelerated to the new set-point speed of 60 mph.   I repeated this experiment a couple of more times and each time I got the same result.

What probably was happening is when I pressed the coast button the integrator was zeroed out to prevent integrator wind-up.   When the button was released the integrator had to see some error for a period of time to develop the memory.   In other words, it had to have a “how much” for a “how long” to be able to calculate an integral error value.

I hope this has been a little more enjoyable way to get introduced to Calculus and now see a use for learning it.

Gary

Creative Commons License
Putting the memory from our right foot into the Controller” by Create-and-Make.com is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

The picture of the Integral Sign is from http://en.wikipedia.org/wiki/File:WPint.svg and has been released to public domain by the author.

If you enjoyed this post and learned something please consider subscribing to this blog using one of the icons on the home page or the e-mail subscription form at the bottom of each page.


 

 

 

Print Friendly

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>