Example: Modeling a Cruise Control System

Physical setup and system equations
Design requirements
MATLAB representation
Open-loop response
Closed-loop transfer function

## Physical setup and system equations

The model of the cruise control system is relatively simple. If the inertia of the wheels is neglected, and it is assumed that friction (which is proportional to the car's speed) is what is opposing the motion of the car, then the problem is reduced to the simple mass and damper system shown below.

Using Newton's law, the modeling equations for this system become:

(1)

where u is the force from the engine. For this example, let's assume that

m = 1000kg
b = 50Nsec/m
u = 500N

## Design requirements

The next step in modeling this system is to come up with some design criteria. When the engine gives a 500 Newton force, the car will reach a maximum velocity of 10 m/s (22 mph). An automobile should be able to accelerate up to that speed in less than 5 seconds. Since this is only a cruise control system, a 10% overshoot on the velocity will not do much damage. A 2% steady-state error is also acceptable for the same reason.

Keeping the above in mind, we have proposed the following design criteria for this problem:

Rise time < 5 sec
Overshoot < 10%

## MATLAB representation

### 1. Transfer Function

To find the transfer function of the above system, we need to take the Laplace transform of the modeling equations (1). When finding the transfer function, zero initial conditions must be assumed. Laplace transforms of the two equations are shown below.

Since our output is the velocity, let's substitute V(s) in terms of Y(s)

The transfer function of the system becomes

To solve this problem using MATLAB, copy the following commands into an new m-file:

```
m=1000;
b=50;
u=500;
num=[1];
den=[m b];
cruise=tf(num,den);
```
These commands will later be used to find the open-loop response of the system to a step input. But before getting into that, let's take a look at the state-space representation.

### 2. State-Space

We can rewrite the first-order modeling equation (1) as the state-space model.

To use MATLAB to solve this problem, create an new m-file and copy the following commands:
```m = 1000;
b = 50;
u = 500;
A = [-b/m];
B = [1/m];
C = [1];
D = 0;
cruise=ss(A,B,C,D);
```
No>e: It is possible to convert from the state-space representation to the transfer function or vice versa using MATLAB. To learn more about the conversion, see the Conversion

## Open-loop response

Now let's see how the open-loop system responds to a step input. Add the following command to the end of your m-file and run it in the MATLAB command window:
```	step(u*cruise)
```

You should get the following plot:

From the plot, we see that the vehicle takes more than 100 seconds to reach the steady-state speed of 10 m/s. This does not satisfy our rise time criterion of less than 5 seconds.

## Closed-loop transfer function

To solve this problem, a unity feedback controller will be added to improve the system performance. The figure shown below is the block diagram of a typical unity feedback system.

The transfer function in the plant is the transfer function derived above {Y(s)/U(s)=1/ms+b}. The controller will to be designed to satisfy all design criteria. Four different methods to design the controller are listed at the bottom of this page. You may choose on PID, Root-locus, Frequency response, or State-space.

Modeling 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