The transfer function for this cruise control problem is the following,
and the block diagram of an typical unity feedback system is shown below.
The design criteria for this problem are:
To see the original problem setup, see Cruise Control Modeling page.
Recall from the PID tutorial page, the transfer function of a PID controller is
Let's first take a look at the proportional control.
The first thing to do in this problem is to find a closed-loop transfer function with a proportional control (Kp) added. By reducing the block diagram, the closed-loop transfer function with a proportional controller becomes:
Recall from the PID tutorial page, a proportional controller (Kp) decreases the rise time. This is what we need, if you refer to the Cruise Control Modeling page.For now, let Kp equal 100 and see what happens to the response. Create an new m-file and enter the following commands.
Kp=100; m=1000; b=50; u=10; num=; den=[m b]; cruise=tf(num,den); sys_cl=feedback(Kp*cruise,1); t=0:0.1:20; step(u*sys_cl,t) axis([0 20 0 10])Running this m-file in the MATLAB command window should give you the following step response.
As you can see from the plot, neither the steady-state error nor the rise time do not satisfy our design criteria. You can increase the proportional gain (Kp) to improve the system output. Change the existing m-file so that Kp equal 10000 and rerun it in the MATLAB command window. You should see the following plot.
The steady-state error has dropped to near zero and the rise time has decreased to less than 0.5 second. However, this response is unrealistic because a real cruise control system generally can not change the speed of the vehicle from 0 to 10 m/s in less than 0.5 second.
The solution to this problem is to choose a proportional gain (Kp) that will give a reasonable rise time, and add an integral controller to eliminate the steady-state error.
The closed-loop transfer function of this cruise control system with a PI controller is:
Recall from the PID tutorial page, an addition of an integral controller to the system eliminates the steady-state error. For now, let Kp equal 600 and Ki equal 1 and see what happens to the response. Change your m-file to the following.
m=1000; b=50; num=; den=[m b]; cruise=tf(num,den); Kp = 600; Ki = 1; contr=tf([Kp Ki],[1 0]); sys_cl=feedback(contr*cruise,1); u=10; t=0:0.1:20; step(u*sys_cl,t) axis([0 20 0 10])
Now adjust both the proportional gain (Kp) and the integral gain (Ki) to obtain the desired response. When you adjust the integral gain (Ki), we suggest you to start with a small value since a large (Ki) can destabilize the response.
When Kp equal 800 and Ki equal 40, the step response will look like the following:
As you can see, this step response meets all design criteria.
For this particular example, no implementation of a derivative controller was needed to obtain a required output. However, you might want to see how to work with a PID control for the future reference. The closed-loop transfer function for this cruise control system with a PID controller is.
Let Kp equal 1, Ki equal 1, and Kd equal 1 and enter the following commands into an new m-file.
Kp=1; Ki=1; Kd=1; m=1000; b=50; u=10; cruise=tf(num,den); contr=tf([Kd Kp Ki],[1 0]); sys_cl=feedback(contr*cruise,1); t=0:0.1:20; step(u*sys_cl,t) axis([0 20 0 10])
Running this m-file should give you the step response of the system with PID controller. Adjust all of Kp, Kd, and Ki until you obtain satisfactory results. We will leave this as an exercise for you to work on.
Suggestion: Usually choosing appropriate gains require trial and error processes. The best way to attack this tedious process is to adjust one variable (Kp, Kd, or Ki) at a time and observe how changing one variable influences the system output. The characteristics of Kp, Kd, and Ki are summarized in the PID Tutorial page.