Example: Frequency Response Design method for the Pitch Controller

In the Pitch Controller Modeling page, the transfer function was derived as

The input (elevator deflection angle, delta e) will be 0.2 rad (11 degrees), and the output is the pitch angle (theta).

The design requirements are

• Overshoot: Less than 10%
• Rise time: Less than 5 seconds
• Settling time: Less than 10 seconds
• Steady-state error: Less than 2%
To see the original problem setup, please refer to the Pitch Controller Modeling page.

## Open-loop response

Recall from your control textbook that the frequency response design method is most effective for systems with stable open-loop. To check the open-loop stability of our system, create a new m-file, and enter the following commands. Running this m-file in the MATLAB command window should give you the step response shown below:

```de = 0.2;
num = [1.151 0.1774];
den = [1 0.739 0.921 0];
pitch = tf(num,den);
step(de*pitch)
```

Unfortunately, our system is unstable in open-loop; however, we can still design the feedback system via frequency response method (even though this might not be the easiest way). First, let's generate the open-loop Bode plot and see what it looks like. Change the m-file to the following and re-run it in the MATLAB command window. You should see a Bode plot similar to the one shown below:

```num = [1.151 0.1774];
den = [1 0.739 0.921 0];
pitch = tf(num,den);
bode(pitch)
```

From our design requirements, we can determine that the natural frequency (Wn) must be greater than 0.9 and the damping ratio (zeta) must be greater than 0.52 (please refer to the Pitch Controller: Root-Locus method for details). Using two equations shown below, we see that the bandwidth frequency and the phase margin must be greater than 0.9 and 52 degrees, respectively.

• Tr = Rise time
• Wn = Natural frequency
• BW = Bandwidth frequency
• zeta = Damping ratio
• PM = Phase margin
• Currently, we have a bandwidth frequency of 1 rad/sec and a phase margin of 80 degrees. These values are within our desired region. Let's plot the closed-loop step response and see what it looks like. Delete the bode command from the above m-file and add the following commands. Running this new m-file should give you the following closed-loop step response:
```sys_cl = feedback(pitch,1);
de = 0.2;
t = 0:0.01:10;
step(de*sys_cl,t)
```

As you can see, the transient response is worse, there is a long settling time. We will implement a lead compensator to improve the system response.

Referring to the "Lead or phase-lead compensator using frequency response" section of Lead and Lag Compensator page, a lead compensator will add a positive phase to the system. An additional positive phase increases the phase margin; thus, increase damping. The settling time should decrease as a result of this increased damping.

The transfer function of a typical first-order lead compensator is

We need to find alead, Tlead and Klead. First, the phase margin requirement and the following equation can be used to find alead

Since we are required to have the phase margin of greater than 52 degrees, the alead must be greater than 8.43. Using this alead, the bandwidth frequency requirement of greater than 0.9 and the following equation leads us to have the Tlead of smaller than 0.382.

Let the Klead equal 0.1, alead equal 10, and Tlead equal 0.3 for now and enter the following commands to an new m-file.

```num = [1 151 0.1774];
den = [1 0.739 0.921 0];
pitch = tf(num,den);

k = 0.1;

de = 0.2;
t = 0:0.01:10;
figure
step (de*sys_cl,t)
```

Running this m-file in the MATLAB command window gives you the following Bode and step response plots.

Although both the bandwidth frequency and phase margin have increased, the response still does not satisfy the design requirements. Let's increase alead and decrease Tlead. After several trial and error runs, an alead of 200, Tlead of 0.0025, and Klead of 0.05 , were found which gave the following lead compensator,

providing the desired transient response. To see the step response and the corresponding Bode plot, enter the following commands to an m-file and run it in the command window. You should see both the Bode plot and the step response shown below:
```num = [1 151 0.1774];
den = [1 0.739 0.921 0];
pitch = tf(num,den);

k = 0.1;

de = 0.2;
t = 0:0.01:10;
figure
step (de*sys_cl,t)
```

If you compare the above Bode plot to the original Bode plot, you see both the phase margin and the bandwidth frequency have increased. Increasing both of them improves the rise time, the overshoot, and the settling time, as seen in the above step response plot. To improve the steady-state error, we will add a lag compensator to the system.

## Lag compensator

Referring to the "Lag or phase-lag Compensator using frequency response" section of Lead and Lag Compensator page, a lag compensator reduces the steady-state error. The typical first-order transfer function of a lead compensator is

The steady-state error will be reduced by a factor of alag. From the above step response, we see that the steady-state error is roughly 10%. Thus, alag needs to be approximately 0.1. The Tlag should be greater than alag*Tlag because this compensator must not greatly change the transient response.

After several trial and error runs, an alag of 0.1, Tlag of 20, and Klag of 1.5, were found which gave the following lag compensator,

provided the desired response. To see the step response and the corresponding Bode plot, enter the following commands to an new m-file. Running this m-file in the command window should give you the two plots shown below:
```num = [1 151 0.1774];
den = [1 0.739 0.921 0];
pitch = tf(num,den);

k = 0.05;

Tlag = 20;
alag = 0.1;
at = alag*Tlag;
k2 = 1.5;
numlag = k2/alag*[at 1];
denlag = [Tlag 1];
lag = tf(numlag,denlag);

figure
t = 0:0.01:10;
step(0.2*sys_cl,t)
```

If you see the Bode plot, the low frequency gain has increased while keeping the bandwidth frequency the same. This tells us that steady-state error has reduced while keeping the same rise time. The above step response shows that the steady-state error is acceptable. Now all design requirements are satisfied.

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

Pitch 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