# Cruise Control: Frequency Domain Methods for Controller Design

Key MATLAB commands used in this tutorial are: `tf` , `feedback` , `step`

## Contents

## System model

The transfer function model for the cruise control problem is given below. Please see the Cruise Control: System Modeling page for the derivation.

(1)

## System parameters

For this example, let's assume that the parameters of the system are

(m) vehicle mass 1000 kg

(b) damping coefficient 50 N.s/m

(r) reference speed 10 m/s

(u) nominal control force 500 N

and the block diagram of a typical unity feedback system is shown below.

## Performance specifications

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

## 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.

(2)

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

```
m = 1000;
b = 50;
u = 500;
Kp = 1;
s = tf('s');
P_cruise = 1/(m*s+b);
C = Kp;
step(u*C*P_cruise)
```

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(C*P_cruise);

## Proportional controller

Refer to the Introduction: Frequency Domain Methods for Controller Design page, and let's see what system characteristics we can determine from the above Bode plot.

The steady-state error can be found from the following equation:

(3)

For this system, the low frequency gain is -34dB = 0.02; therefore, the steady-state error should be 98%. We can confirm this by generating a closed-loop step response as follows.

r = 10; sys_cl = feedback(C*P_cruise,1); step(r*sys_cl);

We need to increase the low frequency gain in order to improve the steady-state error. Specifically, the error needs to be < 2%; therefore, 1/(1+ ) < 0.02 > 49 = 33.8 dB. Since, the low frequency gain is -34 dB and the steady-state error limit needs us to have a low frequency gain of 33.8 dB, to reach the desired steady-state error using proportional control only, requires a > (34 dB + 33.8 dB) = 67.8 dB = 2455. Let's look at the Bode diagram of the compensated open-loop system.

Kp = 2500; C = Kp; bode(C*P_cruise);

As you can see from the Bode plot above, the low frequency magnitude is now, 34 dB. Now let's simulate the step response of the closed loop system with this gain.

sys_cl = feedback(C*P_cruise,1); step(r*sys_cl);

The steady-state error meets the requirements; however, the rise time is much shorter than is needed and is unreasonable in this case since the car can not accelerate to 10 m/s in 2 sec. Therefore, we will try using a smaller proportional gain to reduce the control action required along with a lag compensator to reduce the steady-state error.

## Lag compensator

If you take a look at the "Lag or Phase-Lag Compensator using Frequency Response" section of the Lead and Lag Compensator Design page, the lag compensator 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:

(4)

If you read the "Lag or Phase-Lag Compensator using Root-Locus" section in Lead and Lag Compensator Design page, the pole and the zero of a lag controller need to be placed close together. Also, it states that the steady-state error will be reduced by a factor of . For these reasons, let equal 0.1 and equal 0.02. The proportional gain, = 1000 was chosen by trial-and-error.

Kp = 1000; zo = 0.1; po = 0.02; C_lag = (s+zo)/(s+po); bode(Kp*C_lag*P_cruise);

Let's confirm the performance by generating a closed-loop step response.

sys_cl = feedback(Kp*C_lag*P_cruise,1); t = 0:0.1:20; step(r*sys_cl,t);

As you can see, there is a very slight overshoot, the steady state error is close to zero, and the rise time is under 5 seconds. The system has now met all of the design requirements. No more iteration is needed.