Example: State-space method for the Pitch Controller

In the Pitch Controller Modeling page, the state-space model 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.

If you are interested in running an animation of this example based on the control techniques used in the state-space tutorial please go to the Pitch Controller Animation page after completing this tutorial.

## Controllability and Observability

The first thing to do in designing a system via state-space method is to check the controllability and observability of the system. For the system to be completely state controllable, the controllability matrix

must have the rank of n. The rank of the matrix is the number of independent rows (or columns). In the same token, for the system to be completely state observable, the observability matrix

must also have the rank of n. Since our controllability matrix and observability matrix are 3x3, the rank for both matrices must be 3. The MATLAB command rank can give you the ranks of both matrices. Create a new m-file and enter the following commands:

```A = [-0.313 	56.7 	0;
-0.0139 	-0.426	0;
0		56.7	0];

B = [0.232;
0.0203;
0];

C = [0 0 1];

D = [0];

pitch = ss(A,B,C,D);

co = ctrb(pitch);
ob = obsv(pitch);

Controllability = rank(co)
Observability = rank(ob)
```
If you run this m-file in the MATLAB command window, you should see
```Controllability =

3

Observability =

3
```
This proves that our system is both completely state controllable and completely state observable.

## Control design via pole placement

The schematic of a full-state feedback system is shown below:

where

• K=Control matrix
• x=State matrix (alpha, q, theta)
• de=-Kx=input
• R=Reference
Recall from the State-Space Tutorial page, the "pole placement" technique can be used to find the control matrix (K). Since the determinant of [sI-(A-BK)] matrix is a third-order polynomial, there are three poles we can place.

In the State-Space Tutorial, the dominant second-order pole placement method was introduced. However for this example, we will use another method called Linear Quadratic Regulator (LQR) method. This method allows you to find the optimal control matrix that results in some balance between system errors and control effort. Please consult your control textbook for details. To use this LQR method, we need to find three parameters: performance index matrix (R), state-cost matrix (Q), and weighting factor (p). For simplicity, we will choose the performance index matrix equals 1 (R=1), and the state-cost matrix (Q) equals to C' x C. The weighting factor (p) will be varied as we see the step response. To see the structure of the Q matrix, type in the following commands to an m-file and run it in the MATLAB command window (or you can simply type them directly into the command window).

```C = [0 0 1];
Q = C'*C
```
You should see the following Q matrix in the command window:
```
Q  =

0 	0	0
0	0	0
0	0	1
```

Now we are ready to find the control matrix (K) and see the response of the system. First, let the weighting factor (p) equal 50. Enter the following commands to a new m-file and run it in the MATLAB command window.

```t = 0:0.1:10;
de = 0.2*ones(size(t));
yo = [0 0 0];

A = [-0.313       56.7    0;
-0.0139      -0.426  0;
0           56.7    0];

B = [0.232;
0.0203;
0];

C = [0 0 1];

D = [0];

p = 50;
Q = [0 0 0;
0 0 0;
0 0 p];

[K] = lqr(A,B,Q,1)

sys_cl=ss(A-B*K,B,C,D);
lsim(sys_cl,de,t,yo)
```
After you run this m-file, you should see the step response similar to the one shown below:

The rise time, overshoot, and settling time look satisfactory. However, there is a large steady-state error. This can be easily corrected by introducing the feedforwarding scaling factor (Nbar).

## Reference input

Unlike other design methods, the full-state feedback system does not compare the output to the reference; instead, it compares all states multiplied by the control matrix (K*x) to the reference (see the schematic shown above). Thus, we should not expect to see the output equal to the input. To obtain the desired output, we need to scale the reference input so that the output equals the reference. This can be easily done by introducing a feed-forwarding scaling factor called Nbar. The basic schematic with the scaling factor (Nbar) is shown below:

We can easily find Nbar from the MATLAB function rscale. Since this rscale is a user-defined function, you need to copy and save the rscale m-file to your directory. For further assistance in using user-defined functions, refer to the function page. After you have saved the rscale m-file to your directory, enter the following commands to a new m-file and run it in the MATLAB command window. You should see the response shown below:

```t = 0:0.1:10;
de = 0.2*ones(size(t));
yo = [0 0 0];

A = [-0.313       56.7    0;
-0.0139      -0.426  0;
0           56.7    0];

B = [0.232;
0.0203;
0];

C = [0 0 1];

D = [0];

pitch = ss(A,B,C,D);

x = 50;
Q = [0 0 0;
0 0 0;
0 0 x];

[K] = lqr(A,B,Q,1)

Nbar = rscale(pitch,K)

sys_cl = ss(A-B*K,B*Nbar,C,D);
lsim (sys_cl,de,t,yo)
```

Now the steady-state error has been eliminated and all design requirements are satisfied.

If you are interested in running an animation of the pitch controller example based on the control techniques used in this tutorial please go to the Pitch Controller Animation page.

State-Space 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 | Animation

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