Digital Control Example: Designing Cruise Control using Root-Locus method

In this digital control version of the cruise control problem, we are going to use the root-locus design method to design the digital controller. If you refer to the Cruise Control: Modeling page, the open-loop transfer function was derived as

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

The design requirements are

• Rise time: Less than 5 seconds
• Overshoot: Less than 10%
• Steady-state error: Less than 2%

## Discrete transfer function

The first step in performing a discrete analysis of a system is to find the discrete equivalent transfer function of the continuous portion. We will convert the above transfer function (Y(s)/U(s)) to the discrete transfer function using the Matlab function called c2dm. To use this c2dm, you need to specify four arguments: Numerator matrix (num), denominator matrix (den), sampling time (Ts), and the 'method'. You should already be familiar with how to enter num and den matrices. The sampling time (Ts), in the unit of sec/sample, should be smaller than 1/(30*BW), where BW is the closed-loop bandwidth frequency. For the method, we will use the zero-order hold ('zoh').

Let the sampling time equals 1/50 sec assuming that the bandwidth frequency is 1 rad/sec. Now enter the following commands to an m-file and run it in the command window.

```
num=[1];
den=[1000 50];

Ts=1/50;

[numDz,denDz] = c2dm (num,den,Ts,'zoh')
```

The following matrices should be returned to the command window.

```
numDz =

1.0e-04*

0	0.1999

denDz =

1.0000      -0.9990
```

From these matrices, the discrete transfer function can be written as

## Root-Locus in z-plane

Recall from the Digital Control Tutorial, the Matlab function called zgrid should be used to find an acceptable region of the discrete root-locus that gives the desired gain (K). The zgrid requires two arguments: Natural frequency (Wn) and the damping ratio (zeta). These two arguments can be found from the rise time and the overshoot requirements and the following two equations.

where

• zeta=Damping ratio
• Tr=Rise time
• Mp=Maximum overshoot

Since our rise time and overshoot requirements are 5 seconds and 10%, respectively, we can determine that the natural frequency (Wn) must be greater than 0.36 rad/sec and the damping ratio (zeta) must be greater than 0.6.

Let's generate the root-locus and use the zgrid to find the acceptable region of the root-locus. But before doing that, if you refer to the Digital Control Tutorial, the natural frequency argument for zgrid needs to be in the unit of rad/sample, so let the Wn = 0.36*Ts = 0.0072 rad/sample. Now add the following commands to the above m-file and rerun it. You should get the following plot.

```
Wn=0.0072;
zeta=0.6;

rlocus (numDz,denDz)
zgrid (zeta, Wn)
axis ([-1 1 -1 1])
```

The dotted line on the right, which is very small and can not be seen in this case, indicates the locations of constant natural frequency (Wn), and the natural frequency is greater than 0.0072 outside the line. The other dotted line indicates the locations of constant damping ratio (zeta), and the damping ratio is greater than 0.6 inside the line.

In the above plot, you see that the root-locus is drawn in the desired region. Let's find a gain (K) using the Matlab function rlocfind and obtain the corresponding step response. Add the following commands to the above m-file and rerun it in the Matlab command window.

```
[K,poles]=rlocfind (numDz,denDz)

[numcDz,dencDz] = cloop (K*numDz,denDz);

U=10;
[x] = dstep (U*numcDz,dencDz,201);

figure
t=0:0.05:10;
stairs (t,x)
```

In the command window, you should see the prompt asking you to select a point on the root-locus. Click on the root-locus around +0.9. The gain (K) and the pole location should be returned to the command window. Also, you should see the closed-loop stairstep response shown below.

As you noticed, this response satisfies all of the design requirements. But the gain associated with this response is approximately 4500. The system having this large gain (too much control effort) might not be available in a real physical system , even though it is possible in the Matlab simulation. To obtain a desired response with a reasonable control effort, we will modify the discrete controller.

## Compensation using a digital controller

Recall from the continuous Cruise Control: Root-Locus page, the lag controller was added to the system to obtain the desired response. In this digital control version of the cruise control problem, we will modify the existing digital controller by adding a function of the form

There is a guideline to design digital lead and lag compensators. However, design method described there generally applies for improving the system response. In this this particular problem, we are not going to use the method described in that page and use our own educated analysis to design the compensator.

First, we need to reduce the gain (K) while keeping the reasonable response. Recall from your control textbook, the gain (K) equals 0 at poles and infinity at zeros. Thus, if we place the pole inside the desired region and pick a locus near that pole, we should have a reasonable response with smaller gain. Moreover, for the system to be stable, all poles must be placed inside the unit circle.

Consider these two things, we will place the compensator pole somewhere outside the natural frequency requirement and inside the damping ratio requirement, say at +0.6, and the zero at the left of that pole, say at -0.6. The location of this zero can be changed later, if necessary.

Now we got the discrete compensator transfer function. Let's generate the root-locus and obtain the step response. Create an new m-file and enter the following commands.

```
num=[1];
den=[1000 50];

Ts=1/50;
[numDz,denDz] = c2dm (num,den,Ts,'zoh');

Wn=0.0072;
zeta=0.6;

rlocus (numDnew,denDnew)
zgrid (zeta, Wn)
axis ([-1 1 -1 1])

[K,poles] = rlocfind (numDnew,denDnew)

[numcDnew,dencDnew] = cloop (K*numDnew,denDnew);
U=10;
[x] = dstep (U*numcDnew,dencDnew,201);

figure
t=0:0.05:10;
stairs (t,x)
```

Running this m-file in the command window give you the following root-locus.

In the command window, you should be asked to pick a point on the root-locus. Click on the locus near +0.9. You should now have the step response similar to the one shown below.

This response is about the same as what we obtained without the additional controller. However, if you check the command window, the gain has decreased to around 1000. This system satisfies all design requirements with the reasonable control effort.

Note: A design problem does not necessarily have a unique answer. For practice, you may try other compensators to obtain a better response than the one shown above.