Let's place a Step block in the model, connect it to the Target Goto (whose corresponding From block is connected to the Target speed controller input), and set its Final value to 100
km/h.
Run the simulation and open the Scope block. The speed graph should be like this one:
Quite an overshoot! The vehicle speed reaches almost 150 km/h when the controller closes the throttle. This is due to a too high integral gain, Ki, forcing the vehicle to go a lot faster than intended. Who wants a ride?
To calibrate the PI controller constants, Kp and Ki, we'll use this manual method of keeping Ki to zero and finding the Kp value to where the Throttle signal begins to oscillate.
Then we'll halve the found value and save it into Kp and tune Ki in order to reach the target speed with a minimum overshoot.
Prepare the model by setting Ki to zero with this MATLAB command: Ki = 0
.
We'll start with an insanely high proportional gain value, Kp = 5
. The result is shown in the following graphs:
No doubt Kp is too high (oscillations are strong); no one would accept a ride from us.
Let's try with Kp = 1.1
:
The preceding graph has been zoomed to show that there is only a small glitch due to the fact that the speed increased beyond the target speed in the middle of a sample period. But the rest of the graph shows no oscillations, so we're about to find the right value.
The next simulation is done with Kp = 0.8
:
This works very well. We can assume our Kp to be the half of 0.8. That's a fairly high value, but there aren't passengers in the car... yet!
Let's type the MATLAB command, Kp = 0.4
, and save the workspace.
Now we'll keep Kp as the untouched constant and calibrate Ki. The purpose is to use the integral component to actually reach the target speed, keeping the overshoot below 1 percent of the target speed.
We've already seen that Ki = 1
generates way too much overshoot, so we'll try much smaller values such as Ki = 0.01
:
The overshoot is above 5 percent of the target speed, so we need to choose a lower Ki. Let's try with Ki = 0.002
:
Got it! The overshoot is below 1 percent of the target speed.
We have now found both the calibration constants: Kp = 0.4
and Ki = 0.002
. Don't forget to save the workspace (cruise_control_sim.mat
).