Skip to Main Content Skip to Search
Accelerating the pace of engineering and science

 

Newsletters - MATLAB Digest

Autopilot Design using Simulink and the Control System Toolbox

by Greg Wolodkin, Karen Gondoly, and Pascal Gahine


Introduction

In this article, we consider the design and analysis of an altitude-hold autopilot using MATLAB®, Simulink®, and the Control System Toolbox. We begin with a nonlinear Simulink model of the aircraft's longitudinal dynamics. From this nonlinear model, we extract linearized models using the Simulink LTI Viewer. We then use these linear models for control design within the Root Locus Design GUI. To evaluate our designs, we insert the resulting compensators back into the Simulink diagram for nonlinear simulation of the closed-loop system.

You can download the Simulink model and the MAT-file containing the model parameters and control designs. These files were generated using MATLAB 5.2, Simulink 2.2, and version 4.1 of the Control System Toolbox.

Overview

To prevent collisions, eastbound aircraft are required to maintain an altitude which is an odd multiple of 1000 feet. Westbound aircraft are required to fly at an even multiple of 1000 feet. Good pilots can maintain their altitude to within +/-50 feet of the desired altitude, though this requires constant effort. The purpose of an altitude-hold autopilot is to maintain the desired altitude, freeing the pilot to perform other more important tasks.

Passenger comfort is a major consideration in the design of the autopilot, so any corrections to altitude should be smooth and without significant overshoot. In terms of time-domain constraints, a settling time of approximately 30 seconds is our final goal.

Signals available in the model for feedback include the altitude h and the pitch rate q. Since the required changes in altitude are small, the control surface used for actuation is the elevator, situated at the tail of the aircraft. Elevator deflection directly affects the pitch rate (with an open-loop time constant of about 1.5 seconds). Integrating the pitch rate yields the pitch angle, and another integration produces the altitude h.

The Simulink Model

The Simulink model for the aircraft's longitudinal dynamics is depicted in the following figures.]

Simulink model used for design and simulation.

In the airframe itself, we use first-order linear models to obtain the pitch rate q and the vertical component of velocity w from elevator deflection. The bandwidth is roughly 0.65 rad/s. In the airframe model shown, a constant forward velocity u (along the aircraft body axes) is assumed

Subsystem containing the airframes longitudinal dynamics.

The Sensors(IMU) block in figure 1 contains one integrator to obtain the pitch angle and a second integrator to yield the altitude from the pitch angle and the aircraft velocity components. In the following figure, the pitch angle enters nonlinearly via the sine term.

Subsystem containing pitch rate and altitude sensors.

The actuator model contains first-order dynamics with saturation on the actuator position and on its rate of change. For small input signals (linear region), the bandwidth is 20 rad/s. Deflections are limited to +/-45 degrees, while the rate at which the control surface moves is limited to +/-0.35 rad/s, or about 20 degrees per second.

Subsystem containing the elevator dynamics.

Control Strategy and Design Objectives

Our objective is the design of an autopilot capable of holding the aircraft's altitude relatively constant. In terms of pilot and passenger comfort, minimal overshoot and a reasonably long settling time are important constraints. Translated into physical design goals, we will aim for a final closed-loop settling time of about 30 seconds and a damping ratio of about 0.6.

We will be basing our design on two assumptions. First we assume that the aircraft is traveling with constant forward velocity. Recall that our actuator is the elevator rather than the engine (which takes several seconds to spool up before its effects would be seen). The second assumption we make is that the aircraft's pitch angle is small so that cos(x) is approximately 1 and sin(x) is approximately x.

In designing the compensator structure, we choose to first close an inner loop from pitch rate q to desired elevator deflection . A simple gain in this inner loop can improve the airframe's damping and will enable us to do a better job when closing the outer loop around the altitude h. As we shall see, the outer loop requires more than a gain to stabilize the plant, and our final designs will make use of a lead-lag compensator there. The following figure shows a simplified schematic of the two-loop control problem.

Block diagram illustrating the two-loop control problem.

The combination of a double integrator and a right-half-plane zero in the aircraft model places a challenging constraint on our control design. The double integrator occurs due to the relationship between pitch rate and altitude at constant velocity. The nonminimum-phase zero stems from the physics of the elevator at the tail of the aircraft. To gain altitude, for example, the elevator must be commanded upward. As the elevator rises, the airstream over the tail is disrupted, resulting in an initial loss of lift which causes the aircraft to drop. The tail of the plane drops further due to the downward force on the elevator, and the aircraft pitches upward and begins climbing.

In terms of the root locus, this combination leads to a pair of poles at the origin, one of which is headed (under proportional control) towards the right-half-plane zero.

We will implement the compensator structure in Simulink using LTI blocks for the two compensators Kq and Kz. This Altitude Controller subsystem is depicted in the following figure

Subsystem containing the two compensators.

Closing the Inner Loop

Closing the inner loop from q to provides an opportunity to improve the damping of the complex-pole pair corresponding to the short-period mode. We begin by obtaining a linearized model with input and output q. To get a linear model, we link the Simulink LTI Viewer to the aircraft model by selecting Linear Analysis from the diagram's Tools menu. Next we break the loop inside the Altitude Controller block and add Input and Output Point blocks on the signals and q, respectively, as shown in the following figure.

Breaking the inner loop to obtain the model aircraft_1.

To obtain an open-loop model for control design, we select Get Linearized Model from the Simulink menu on the LTI Viewer. The following figure shows the step response of the resulting open-loop model aircraft_1

Open-loop step response of the linear model aircraft_1.

Exporting the linear model to the workspace, we find that the model has a complex pole pair at -0.648 +/- 2.24i stemming from the two states found in the airframe. The open-loop damping ratio of this pole pair is less than 0.28, with a natural frequency of 2.3 rad/s. The additional real pole corresponds to the actuator model.

damp(aircraft_1) Eigenvalue Damping Freq. (rad/s) -6.48e-01 + 2.24e+00i 2.77e-01 2.33e+00 -6.48e-01 - 2.24e+00i 2.77e-01 2.33e+00 -2.00e+01 1.00e+00 2.00e+01

We next use the Root Locus Design GUI to design a proportional control Kq for this inner loop.

rltool(aircraft_1)
 
Within the GUI, we are able to change the gain and immediately see its effect not only on the closed-loop poles, but also on closed-loop step responses, open-loop Bode plots, etc. After investigating several values for the gain Kq, we settle on a value of 0.3, which results in an improved damping ratio of 0.67. The natural frequency moves out slightly to 2.75 rad/s. There is still considerable overshoot in this inner loop, but we will address that problem when closing the outer loop.

Root locus is used to design Kq.

  Closed-loop step response confirms the improved damping.

Before continuing, we export the final inner-loop compensator Kq to the workspace and insert it into the Simulink model, making sure we close the inner loop.

Closing the Outer Loop

In the second (outer) loop, we measure altitude and command pitch rate. The goal of this outer loop is to track the desired altitude with minimal error while taking the passenger comfort constraints into consideration. Specifically we would like to have a reasonably well damped (0.5-0.7) system with a settling time of roughly 30 seconds.

To obtain the linearized model for control design, we go back to the Simulink diagram and move the Input/Output Point blocks to either side of the compensator we wish to design -- in this case, Kz. We also open the loop by removing the connection between the output point and the compensator's input port, as shown in the next figure. The resulting linearized model, aircraft_2, is exported to the workspace and loaded into the Root Locus Design GUI as before.

Breaking the outer loop to obtain the model aircraft_2.

The model for this design has one complex pole pair at -1.85e+00 +/- 2.04e+00i, with a damping ratio of 0.67 (as a result of our inner loop compensator). Because the altitude is two integrators away from the pitch, we find two poles at the origin, as shown.

damp(aircraft_2) Eigenvalue Damping Freq. (rad/s) 0.00e+00 -1.00e+00 0.00e+00 0.00e+00 -1.00e+00 0.00e+00 -1.76e+01 1.00e+00 1.76e+01 -1.85e+00 + 2.04e+00i 6.73e-01 2.75e+00 -1.85e+00 - 2.04e+00i 6.73e-01 2.75e+00

This double integrator, together with the right-half plane zero, places a serious constraint on our design options. Using proportional control, we find the poles at the origin stay on the real axis with one of them bound for the RHP zero. In order to stabilize the system, we must do something more.

A lead-lag compensator is a good choice in this setting, because the zero can be used to keep the closed-loop poles in the left-half-plane. We attempt several designs at this stage, dropping interim designs into the Simulink model to compare the linear responses with nonlinear simulation.

First, we try placing the compensator zero very close to the origin at s=-0.001. We place the compensator pole at s=-0.36 with a gain of 0.19. Exporting the compensator to the workspace, we inspect it visually at the command prompt to yield:

Kz1 Zero/pole/gain: 0.19 (s+0.001) -------------- (s+0.36) The linear step response looks good, as shown in the following figure. The damping of the complex pair is where we want it to be, and the settling time is about right.

Root locus is used to design Kz1.

Closed-loop step response meets rise time and overshoot constraints.

Nonlinear Simulation of the Closed Loop

In this section, we will examine the outer-loop compensator that we designed in the previous section and compare the linear responses with nonlinear simulation of the closed loop. The inner loop gain is Kq=0.3, and the outer loop compensator is Kz1.

Recall that the linear step response for Kz1 looked good, with no overshoot and a reasonable settling time. Preliminary simulations in Simulink look good as well. Let's move a step closer to implementation and insert a quantizer block on the output of the Altitude Controller block to investigate the effects of finite word length and quantization noise. Here we'll use 12 bits of precision over the full range of the actuator (-pi/4 to pi/4), or equivalently a quantization level of 3.8e-04 in the Simulink block

Closed loop control system with quantization.

With the quantizer in place, it is a surprise to see what appears to be a ramp error in the output. After 1000 seconds, the elevation is off by nearly 500 feet! Let's turn back to the linear model and try to make some sense of this.

Nonlinear step response from 10K to 10.5K feet shows large error.

Error in desired altitude is almost 500 feet after 1000 seconds!

Using the Input/Output Point blocks, we build a linear model from to h in order to investigate the effect of quantization noise on the model. We export this to the workspace as aircraft_3.

damp(aircraft_3) Eigenvalue Damping Freq. (rad/s) -1.01e-03 1.00e+00 1.01e-03 -1.51e-01 1.00e+00 1.51e-01 -1.90e-01 1.00e+00 1.90e-01 -1.86e+00 + 2.03e+00i 6.75e-01 2.76e+00 -1.86e+00 - 2.03e+00i 6.75e-01 2.76e+00 -1.76e+01 1.00e+00 1.76e+01

The linearized model reveals two problems:

  • A closed-loop pole very near the origin, at s = -1.01e-03
  • A large gain at low frequency, due to the integrators in the sensors

These problems result in very slow dynamics (taking 3000-4000 seconds to settle out) and a large gain from quantization noise to altitude. Because of the compensator zero at s = -1.00e-03, the control system is unable to respond with corrective action. What appears to be a ramp is actually the first part of a very slow exponential response.

Here we see a major flaw in our original pole-zero cancellation design. Any disturbance which enters after the controller will have a huge impact on the plant output. Back to the drawing board . . .

Closing the Outer Loop, Take Two

A more conservative design follows in which we avoid pole-zero cancellation near the origin. In this second design, we place the zero farther back at s=-0.06. We place the pole at s=-3 and choose a gain of k=4, resulting in the following compensator:

Kz2 Zero/pole/gain: 4 (s+0.06) ---------- (s+3)

This compensator results in the following closed-loop poles:

      Eigenvalue          Damping     Freq. (rad/s)  
                                                      
 -1.20e-01 + 2.97e-02i     9.71e-01       1.24e-01    
 -1.20e-01 - 2.97e-02i     9.71e-01       1.24e-01    
 -2.61e+00                 1.00e+00       2.61e+00    
 -1.93e+00 + 1.80e+00i     7.31e-01       2.64e+00    
 -1.93e+00 - 1.80e+00i     7.31e-01       2.64e+00    
 -1.76e+01                 1.00e+00       1.76e+01    

The next figures shows that there is some overshoot in the linear step response. Although the overshoot is undesirable, the final settling time is within range. Above all, we no longer have to contend with the pole at s=-0.001.

Pole-zero cancellation is avoided in designing Kz2.

Closed-loop step response shows 20% overshoot, good settling time.

Nonlinear Simulation, Take Two.

Recall that the linear step response for Kz2 showed a fair amount of overshoot, but the settling time was reasonable. In the nonlinear simulation, due to the rate limits on the actuator, we find that the overshoot does not actually occur.

We also note that this compensator performs well even in the presence of quantization noise, as shown in the responses plotted in the following figure.

Nonlinear step response from 10K to 10.5K feet looks great!

Error in desired altitude is zero in steady state.

Conclusion

We have designed and analyzed two possible altitude-hold autopilots using MATLAB, Simulink, and the Control System Toolbox. We made extensive use of the LTI Viewer to extract linear models from a nonlinear Simulink model of the aircraft. For control design, we imported these linear models into the Root Locus Design GUI. To evaluate our designs, we inserted the resulting compensators back into the Simulink diagram for nonlinear simulation of the closed-loop system. In the simulation phase, we realized that the pole-zero cancellation used in our first design (although promising in terms of linear analysis) did not perform well in the presence of nonlinearities or actuator disturbances. Our second design avoided the problems found in the first and was able to meet our objectives in the full nonlinear simulation.

Contact sales
Subscribe to newsletters