CMU
UM


Example: Solution to the Cruise Control Problem Using PID control

P controller
PI controller

The state equations for this problem are:

The design criteria (for a 10 m/s final velocity) are:

Rise time < 5 sec
Overshoot < 10%
Steady state error < 2%

To see how this problem was originally set up, click here.

P controller

The first thing to do in this problem is to transform the state-space equations into transfer function form. Next, close the loop and add some proportional control to see if the response can be improved. Both of these steps can be done sequentially in Matlab. Create a new m-file with the following lines of code (or create a '.m' file located in the same directory as Matlab):

The number 10 that is multiplied by numc in the step command is used to make the reference signal 10 (the step command uses a unit reference as a default. If you look back to the cruise control modeling page, the original step response had a steady state value of 10m/sec for an applied force of 500N. This m-file should now represent that same desired steady-state value. Running your m-file should give you the following plot of the velocity response to the step change in the reference.

As you can see, the step response is not very good. The steady state error is more than 10%, and the rise time is still too slow. You can adjust the proportional gain to make the response better, but you will not be able to make the steady state value go to 10m/sec without getting rise times that are too fast. You must always keep in mind that you are designing a real system, and for a cruise control system to respond 0-10m/sec in less than half of a second is unrealistic. To illustrate this idea, adjust the k value to equal 10,000, and you should get the following velocity response:

The steady state error has been dropped to near zero, but the rise time on this step response is way too fast (about 0.2 seconds). The solution to this problem is to add some integral control to eliminate the steady state error. Adjust k until you get a reasonable rise time. For example, with k = 600, the response should now look like:

PI controller

Now, try PI control. Change your m-file to look like the following:

You should get the following velocity response plot:

We suggest starting with a ki value that is small, i. e. around 1, to get a feel for what the integral control is doing to the response. Remember, integral control makes the transient response worse, so adding too much initially can make the response unrecognizable. Now you can adjust the ki value to reduce the steady state error. With ki = 40 and k adjusted up a little more to 800, the response looks like the following:

As you can see, this step response meets all of the design criteria, and therefore no more iteration is needed. It is also noteworthy that no derivative control was needed in this example.

The system was originally critically damped, making the overshoot equal to zero. Had more integral control been needed to eliminate the steady state error, the transient response may have worsen to the point of needing derivative control.

It is easy to implement the derivative control in Matlab. Just change the num1 = [k ki]; line to num1 = [kd k ki];. However, this will make it necessary to adjust three variables simultaneously. The best way to do this would be to adjust one variable at a time starting with k, then kd, and then ki. You may have to go back and readjust, or tweak, the variables (gains) after they have all been set.


User Survey
Your anonymous answers to the following questions will help us to improve future versions of these tutorials.
How useful was this example?
Very useful Useful Somewhat useful Not very useful A waste of time
How was the level of the example?
Too simple About right Too difficult
How much time did you spend on it?
Less than 30 mins. 30 - 60 mins. More than 60 mins.
How much of the Matlab code did you run?
None Some Most

We would like to hear about suggestions you have for improvement, difficulties you had with the tutorials, errors that you found, or any other comments that you have. This feedback is anonymous.

If you would like to receive a response, send your comments or questions to ctm-feedback@umich.edu


PID Examples
Cruise Control | DC Motor | Bus Suspension | Inverted Pendulum

Cruise Control Examples
Modeling | PID | Root Locus | Frequency Response | State Space

Tutorials

Basics | Modeling | PID | Root Locus | Frequency Response | State Space | Examples

HOME INDEX COMMAND

8/22/96 JDP