Example: Solution to the Cruise Control Problem Using Frequency Response

The open-loop transfer function for this problem is :

• m=1000
• b=50
• U(s)=10
• Y(s)=Velocity output

The design criteria are:

Rise time < 5 sec
Overshoot < 10%

To see the original problem set, see the Cruise Control Modeling page.

## Bode plot and open-loop response

The first step in solving this problem using frequency response is to determine what open-loop transfer function to use. Just like for the Root-Locus design method, we will only use a proportional controller to solve the problem. The block diagram and the open-loop transfer function are shown below.

In order to use a Bode plot, the open-loop response must be stable. Let Kp equal 1 for now and see how the open-loop response looks like. Create an new m-file and enter the following commands.

```m = 1000;
b = 50;
u = 500;
Kp = 1;
num = 1;
den = [m b];
cruise = tf(num,den);
contr = Kp;
step(u*contr*cruise)
```
Running this m-file in the MATLAB command window should give you the following plot.

As you can see, the open-loop system is stable; thus, we can go ahead and generate the Bode plot. Change the above m-file by deleting the step command and adding in the following command.

```bode(contr*cruise)
```

Running this new m-file should give you the following Bode plot.

## Proportional controller

Let's see what system characteristics we can determine from the above Bode plot. Recall from the Root-Locus Tutorial, the bandwidth frequency (BW) (the frequency at the gain M(dB)=-6~-7.5dB) is roughly equals to the natural frequency (Wn). Using the equation,

the rise time (Tr) for our system can be determined to be extremely long since the gain shown above does not reach -6~-7.5dB. Moreover, the damping ratio is roughly equal to the phase margin (in degrees) divided by 100.

Since our phase margin is approximately 155 degrees, the damping ratio will be 1.55. Thus, we know that the system is overdamped (since the damping ratio is greater than 1). Finally, the steady-state error can be found from the following equation:

For our system, since the low frequency gain M(dB) is approximately -35dB, the steady-state error should be 98%. We can confirm these by generating a closed-loop step response.

```u=10;
sys_cl=feedback(contr*cruise,1);
step(u*sys_cl);
```

In terms of the Bode plot, if we can shift the gain upward so that both the bandwidth frequency and the low frequency gain increase, then both the rise time and the steady-state error will improve. We can do that by increasing the proportional gain (Kp). Let's increase the proportional gain (Kp) to, say, 100 and see what happens. Change the m-file to the following.

```m = 1000;
b = 50;
u = 10;
Kp = 100;
num = 1;
den = [m b];
cruise = tf(num,den);
contr = Kp;
bode(contr*cruise)
```

Running this m-file in the MATLAB command window should give you the following Bode plot.

Now, the low frequency gain is about 6dB (magnitude 2) which predicts the steady-state error of 33%. The bandwidth frequency is about 0.1 rad/sec so that the rise time should be around 18 seconds. Let's take a look at the closed-loop step response and confirm these.

```sys_cl=feedback(contr*cruise,1);
step(u*sys_cl);
```

As we predicted, both the steady-state error and the rise time have improved. Let's increase the proportional gain even higher and see what happens. Change the m-file to the following and rerun it. You should get the following Bode plot.

```m = 1000;
b = 50;
u = 10;
Kp = 500;
num = 1;
den = [m b];
cruise = tf(num,den);
contr = Kp;
bode(contr*cruise)
```

Now, the low frequency gain is 20dB (magnitude 10) that predicts the steady-state error of 9%, and the bandwidth frequency is around 0.6 that predicts the rise time of 3 sec (within the desired value). Thus, both the steady-state error and the rise time should have been improved. Again, let's confirm these by generating the closed-loop step response.

```sys_cl=feedback(contr*cruise,1);
step(u*sys_cl);
```

If you noticed, the steady-state error will eventually reach the desired value by increasing the proportional gain even higher. However, by the time the steady-state error reaches the desired value, the rise time becomes too fast (unrealistic for the real physical system). Thus, let's leave the Kp as it is and implement a lag controller to handle the steady-state error problem.

## Lag controller

If you take a look at the "Lag or Phase-Lag Compensator using Frequency Response" section of the Lead and Lag Compensator page, the lag controller adds gain at the low frequencies while keeping the bandwidth frequency at the same place. This is actually what we need: Larger low frequency gain to reduce the steady-state error and keep the same bandwidth frequency to maintain the desired rise time. The transfer function of the lag controller is shown below.

Now, we need to choose a value for a and T. Recall from the "Lag or Phase-Lag Compensator using Frequency Response" page, the steady-state error will decrease by a factor of a. The value T should be chosen so that two corner frequencies will not be placed close together because transient response gets worse. So let a equal 0.05 and T equal 700 and see what happens. Copy the following m-file and run it in the MATLAB command window. You should see the following Bode plot.

```
m = 1000;
b = 50;
u = 10;
Kp = 600;
num = 1;
den = [m b];
cruise = tf(num,den);
a = 0.05;
T = 700;
numlag = [a*T 1];
denlag = a*[T 1];
contr = Kp*tf(numlag,denlag);
bode(contr*cruise)
figure
sys_cl=feedback(contr*cruise,1);
step(u*sys_cl)
```

Since the low frequency gain has increased while the bandwidth frequency stayed the same, the steady-state error should be reduced and the rise time should stay the same. Let's confirm this by generating a closed-loop step response.

It may be hard to see, but there should be a green, dotted line across just below 10. This line shows the steady-state value of the step, and we can see that the steady-state error has been met. However, the settling time is too long. To fix this, raise the proportional gain to Kp=1500. This gain was chosen from trial-and-error that will not be described here in the interest of length. With this change made, the following Bode and step response plots can be generated.

As you can see, the overshoot is in fact zero, the steady state error is close to zero, the rise time is about 2 seconds, and the settling time is less than 3.5 seconds. The system has now met all of the design requirements. No more iteration is needed.

Frequency Response Examples
Cruise Control | Motor Speed | Motor Position | Bus Suspension | Inverted Pendulum | Pitch Controller | Ball and Beam

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

Tutorials
MATLAB Basics | MATLAB Modeling | PID Control | Root Locus | Frequency Response | State Space | Digital Control | Simulink Basics | Simulink Modeling | Examples

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