Skip to content

imhyeonwoo/b747-autopilot-control

Repository files navigation

B747 Autopilot Control System

This project designs an Altitude Tracking Autopilot for the Boeing 747.
Based on a linearized longitudinal dynamics model, it applies an Inner Loop / Outer Loop cascade control architecture.


System Overview

Linearized Longitudinal Model

The B747 longitudinal dynamics are represented in state-space form:

$$\dot{\mathbf{x}} = \mathbf{A}\mathbf{x} + \mathbf{B}\mathbf{u}$$ $$\mathbf{y} = \mathbf{C}\mathbf{x} + \mathbf{D}\mathbf{u}$$

State vector and input vector:

$$\mathbf{x}_{long} = \begin{bmatrix} \Delta u \\\ w \\\ q \\\ \Delta\theta \\\ \Delta z_E \end{bmatrix}, \qquad \mathbf{u}_{long} = \begin{bmatrix} \delta_e \\\ \delta_p \end{bmatrix}$$
State Meaning
$\Delta u$ Forward speed deviation (from trim)
$w$ Vertical velocity
$q$ Pitch rate
$\Delta\theta$ Pitch angle deviation
$\Delta z_E$ Vertical position deviation in NED coordinates
Input Meaning
$\delta_e$ Elevator deflection (deviation from trim)
$\delta_p$ Throttle (thrust) deviation

Note: The output matrix is set to $\mathbf{C} = \mathbf{I}$ (identity), so all states are available as outputs.
Only the required signals ($\theta$, $z_E$, etc.) are extracted using a Demux in Simulink.

Altitude Coordinate Conversion (NED)

In the NED (North-East-Down) frame, $z_E$ is positive downward.
To use altitude $h$, the sign must be flipped:

$$h = -z_E$$

In Simulink, this is implemented using a Gain = -1 block to convert $z_E$ to altitude $h$ for Outer Loop feedback.


Control Architecture: Inner Loop / Outer Loop Cascade

The altitude control system is designed as a cascade controller:

Inner Loop Step Response

Why Separate Inner and Outer Loops?

1) Time-Scale Separation

Loop Dynamics Typical response time
Inner loop (pitch) fast dynamics ~1–2 s
Outer loop (altitude) slow dynamics ~20–60 s

This separation allows each loop to be designed independently.

2) Reduced Design Complexity

  • Designing the full high-order MIMO system at once is complex.
  • Cascade design enables each loop to be treated as a lower-order SISO problem.

3) Improved Stability

  • If the inner loop is stabilized first, the outer loop can be designed on top of a well-behaved inner closed-loop system.

4) Easier Tuning and Debugging

  • Problems can be localized to a specific loop.
  • Each loop can be tested and tuned independently.

Inner Loop: Pitch Attitude Control

Purpose

The inner loop makes the aircraft pitch angle ($\theta$) rapidly track the command $\theta_{cmd}$ generated by the outer loop.

The relationship “moment → $q$$\theta$” is not separated into additional blocks; it is already embedded in the state-space matrices $\mathbf{A}, \mathbf{B}$.

Signal Flow

$$e_\theta = \theta_{cmd} - \theta \quad \xrightarrow{\text{PID}} \quad \delta_{e,cmd} \quad \xrightarrow{G_{servo}(s)} \quad \delta_e \quad \xrightarrow{\text{Aircraft}} \quad \theta$$

Transfer Function Extraction

For inner loop design, extract the SISO transfer function:

$$G_{\theta\delta_e}(s) = \frac{\theta(s)}{\delta_e(s)}$$

MATLAB example: 4th output ($\theta$), 1st input ($\delta_e$)

G_theta_deltae = minreal(tf(sys_long(4,1)));

Elevator Servo Model

The actuator is modeled as a first-order lag:

$$G_{servo}(s) = \frac{-1}{0.1s + 1}$$

Note: The numerator is $-1$ to match the sign convention between elevator deflection and pitch response.

Open-Loop Transfer Function

$$L(s) = C_{inner}(s) \cdot G_{servo}(s) \cdot G_{\theta\delta_e}(s)$$

Design Requirements

  • Overshoot: ≤ 10% (target damping ratio $\zeta = 0.6$)
  • Settling time (2%): ≤ 2 s

Root Locus–Based Design

Root locus is used to analyze closed-loop pole movement as PID gains change, and to select gains satisfying stability and response constraints.

PID Controller

$$C_{inner}(s) = K_p + \frac{K_i}{s} + K_d s$$

Designed gains:

Parameter Value
$K_p$ 2.5
$K_i$ 0.5
$K_d$ 2.1

Inner Loop Response

With the inner-loop controller, the pitch angle tracks $\theta_{cmd}$ quickly and stably.

Inner Loop Step Response


Outer Loop: Altitude Control

Purpose

The outer loop makes the aircraft altitude ($h$) track the commanded value.
Assuming the inner loop ensures $\theta \approx \theta_{cmd}$ rapidly, the outer loop generates $\theta_{cmd}$.

Signal Flow

$$e_h = h_{cmd} - h \quad \xrightarrow{C_h(s)} \quad \theta_{cmd} \quad \xrightarrow{\text{Inner Loop}} \quad \theta \quad \rightarrow \quad h$$

Design Requirements

  • Overshoot: ≤ 10%
  • Settling time (2%): ≤ 60 s

Design Notes

Limitations of P-Only Control

  • P-only control struggles to satisfy Ts/OS requirements.
  • Steady-state error remains.

PI Control

  • Adding an integrator removes steady-state error.
  • A grid search is used to find suitable $(K_{p,out}, K_{i,out})$ combinations.

PI Controller

$$C_{outer}(s) = K_{p,out} + \frac{K_{i,out}}{s}$$

Saturation and Anti-Windup

A physical limit is applied to $\theta_{cmd}$ (e.g., $\pm 10^\circ$):

  • Saturation block: limits pitch command
  • Anti-windup: prevents integrator windup during saturation

Limitation Without Throttle Control

Warning: In the current implementation, $\delta_p = 0$ is fixed.

Using only the elevator to control altitude can cause:

  • Energy deficit: speed decreases when climbing
  • Phugoid mode: long-period oscillations may appear
  • Slow response: settling within ~20 s is generally unrealistic

In real aircraft, altitude hold is typically paired with autothrottle to maintain speed/energy.

Outer Loop Response

With both loops closed, altitude tracks $h_{cmd}$ with zero steady-state error.

Outer Loop Step Response


Full Simulink Model

Below is the complete Simulink model integrating the inner and outer loops.

Full Simulink Model

Components:

Block Role
Outer Loop Controller altitude error → pitch command ($\theta_{cmd}$)
Inner Loop Controller pitch error → elevator command ($\delta_e$)
Elevator Servo 1st-order actuator model
B747 Longitudinal Plant linearized longitudinal dynamics (state-space)
Gain (-1) $z_E$$h$ conversion
D2R / R2D degree ↔ radian conversion

Project Structure

b747-autopilot-control/
├── init_model.m                 # Define linear model matrices (A, B, C, D)
├── design_altitude_controller.m # Controller design scripts (Inner/Outer)
├── system_model.slx             # Full Simulink model
├── Linear_Model.slx             # Linear model Simulink file
├── Explanation.md               # Detailed design guide
└── docs/
    └── altitude control/        # Simulation result images
        ├── Full Simulink Model.png
        ├── inner loop response.png
        └── outer loop response.png

How to Run

  1. Launch MATLAB and move to the project directory
  2. Run init_model.m to load the model matrices into the workspace
  3. (Optional) Run design_altitude_controller.m to compute controller gains
  4. Open system_model.slx and run the simulation
>> init_model
>> open_system('system_model')
>> sim('system_model')

Key Takeaways

Item Description
Inner loop fast attitude stabilization ($\theta$ tracking, ~2 s response)
Outer loop slower altitude tracking (generates $\theta_{cmd}$, ~60 s response)
Time-scale separation key enabler for independent loop design
Coordinate conversion $h = -z_E$ in NED
Throttle $\delta_p = 0$ fixed (performance limitation)

References

  • Phase 1 autopilot design guide based on the linear state-space model: Explanation.md

  • Classical control design using PID and root locus

  • The main purpose of this personal project is to understand linearized system and structure of inner and outer loop control system.

About

Design and analysis of a B747 autopilot using "cascaded inner–outer loop" control in MATLAB/Simulink. Main goal of the project is to understand Inner / Outer Loop for control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages