# Apollo 11 Navigation and Guidance Systems: A Deep Dive into the AGC Source Code

> Explore the Apollo 11 navigation and guidance systems within the AGC source code. Discover rendezvous, orbital, and descent algorithms detailed in the chrislgarry/Apollo-11 repository.

- Repository: [Chris Garry/Apollo-11](https://github.com/chrislgarry/Apollo-11)
- Tags: deep-dive
- Published: 2026-03-04

---

**The Apollo 11 Guidance Computer (AGC) implements distinct navigation and guidance systems for both the Command Module (Comanche 055) and Lunar Module (Luminary 099), including rendezvous, orbital, cislunar mid-course, lunar ascent, and powered descent guidance algorithms.**

The Apollo 11 mission relied on sophisticated software running on the Apollo Guidance Computer to navigate between Earth and the Moon. Analyzing the original assembly source in the `chrislgarry/Apollo-11` repository reveals how these **Apollo 11 navigation and guidance systems** were structured as autonomous program pages (P-numbers) executed by the AGC executive, with separate flight programs for the Command Module (CM) and Lunar Module (LM).

## Command Module Navigation (Comanche 055)

The Command Module software, designated **Comanche 055**, contains three primary navigation programs that handle orbital operations and trajectory corrections during translunar and lunar orbital phases.

### Rendezvous Navigation (P20)

The **P20 Rendezvous Navigation** program aligns the CM's attitude toward the LM and updates state vectors using optical tracking marks. Implemented in `Comanche055/P20-P25.agc`, the entry point `PROG20` initializes a cascade of guidance flags before invoking IMU status checks and integration routines.

At lines 38–45, the initialization sequence sets the required tracking environment:

```assembly
PROG20      TC  BANKCALL
            CADR    R02BOTH          # IMU STATUS CHECK

            CAF     ZERO
            TS      TRKMKCNT         # CLEAR REND TRACKING MARK COUNTER

            TS      VHFCNT           # CLEAR REND VHF RNG MARK COUNTER

            TC      UPFLAG           # SET PREF TRACK ATT FLAG

            ADRES   PRFTRKAT         # BIT 10 FLAG 5

            TC      DOWNFLAG         # LEM TO BE UPDATED. VEHUPFLG RESET.

            ADRES   VEHUPFLG         # BIT 8 FLAG 1

            TC      UPFLAG           # SET TRACKFLAG

            ADRES   TRACKFLG         # BIT 5 FLAG 1

            TC      UPFLAG           # SET UPDATFLG

            ADRES   UPDATFLG         # BIT 7 FLAG 1

            TC      UPFLAG           # SET RNDVZFLG

            ADRES   RNDVZFLG         # BIT 7 FLAG 0

```

This flag configuration enables the `INTEGRV` integration routine and `R52` optics processing required for precision tracking.

### Orbital Navigation (P22)

**P22 Orbital Navigation** handles higher-orbit maneuvers such as lunar orbit insertion after rendezvous completion. Located in the same `P20-P25.agc` file following the P20 block (lines 81–92), `PROG22` clears the rendezvous flag (`RNDVZFLG`) and computes the angle between the vehicle's velocity vector and inertial reference axis to maintain orbital alignment.

### Cislunar Mid-Course Navigation (P23)

The **P23 Cislunar Mid-Course Navigation** program corrects the translunar trajectory following trans-lunar injection. Also residing in `Comanche055/P20-P25.agc` (lines 2750–2830), this routine executes a measure-compute-store pattern: it repeatedly measures horizon and landmark angles, updates the navigation matrix **W**, and stores results for crew display.

## Lunar Module Guidance (Luminary 099)

The Lunar Module flight software, **Luminary 099**, implements powered flight guidance for both ascent from the lunar surface and descent to landing, utilizing Lambert transfer solutions and quadratic guidance laws.

### Ascent Guidance (P83)

The **LM Ascent Guidance** program (P83) drives the vehicle from the lunar surface to rendezvous orbit autonomously. The implementation in `Luminary099/ASCENT_GUIDANCE.agc` establishes the guidance loop through flag-controlled initialization at lines 1–15:

```assembly

# Filename:   ASCENT_GUIDANCE.agc

# Purpose:    LM Ascent Guidance (P83)

PROG        TC  BANKCALL            # Transfer to executive

            CADR    R02BOTH          # IMU status check

            CAF     ZERO
            TS      ASCENTCNT        # Clear ascent cycle counter

            TC      UPFLAG           # Set "ascent active" flag

            ADRES   ASCENTFLG

```

Following initialization, the routine computes quadratic guidance laws to update target vectors and feed the digital autopilot.

### Lunar Landing Guidance

**Lunar Landing Guidance** generates the descent equations for the powered landing phase. Found in `Luminary099/LUNAR_LANDING_GUIDANCE_EQUATIONS.agc` (lines 410–470), this module contains the "Main Guidance Equation" handling state transformation, overflow protection, and real-time display updates during the critical descent phase.

### Lambert Aim-Point Guidance

The **General Lambert Aim-Point Guidance** system computes two-point orbital transfer vectors for both ascent and descent planning. Implemented in `Luminary099/GENERAL_LAMBERT_AIMPOINT_GUIDANCE.agc` (lines 30–45), this routine supplies the vector calculations that determine optimal aim-points for powered flight phases.

## Inertial Measurement Unit Infrastructure

Both Comanche 055 and Luminary 099 rely on dedicated IMU subsystems that provide raw inertial data to the navigation programs. These support modules apply corrections and manage sensor modes:

- **IMU Mode Switching** (`IMU_MODE_SWITCHING_ROUTINES.agc`): Selects between inertial-only and optical-aided operational modes
- **IMU Compensation** (`IMU_COMPENSATION_PACKAGE.agc`): Applies temperature-drift and bias corrections to gyro and accelerometer data
- **IMU Calibration and Alignment** (`IMU_CALIBRATION_AND_ALIGNMENT.agc`): Performs initial platform alignment and periodic recalibration

These modules supply the `INTEGRV` and `GRP2PC` filters utilized by P20–P23 and the LM guidance pages.

## Executive Control and Integration

The **AGC Executive** (`Comanche055/EXECUTIVE.agc`) manages program dispatching based on priority flags and job scheduling. Navigation programs operate as "jobs" under this executive, with the **Digital Autopilot Interface** (`Comanche055/CM_ENTRY_DIGITAL_AUTOPILOT.agc`) translating guidance outputs into thruster commands. This architecture allows autonomous switching between navigation modes—for example, transitioning from P22 orbital navigation to P23 mid-course corrections—based on mission phase flags.

## Summary

- The Apollo 11 AGC splits navigation duties between **Comanche 055** (Command Module) and **Luminary 099** (Lunar Module), each containing specialized guidance programs.
- **Rendezvous, orbital, and cislunar navigation** (P20–P23) reside in `Comanche055/P20-P25.agc`, utilizing flag-based initialization and IMU-compensated state vectors.
- **LM ascent and descent guidance** implement quadratic guidance laws in `Luminary099/ASCENT_GUIDANCE.agc` and `Luminary099/LUNAR_LANDING_GUIDANCE_EQUATIONS.agc`.
- **Lambert aim-point calculations** provide transfer orbit solutions for powered flight phases.
- **IMU compensation and alignment** routines ensure sensor accuracy through temperature drift correction and platform alignment.
- The **Executive** system manages real-time scheduling of navigation tasks, coordinating sensor inputs with autopilot outputs.

## Frequently Asked Questions

### What is the difference between Comanche 055 and Luminary 099?

**Comanche 055** is the flight software for the Command Module, containing rendezvous and orbital navigation programs (P20–P23). **Luminary 099** runs on the Lunar Module and includes ascent, descent, and landing guidance algorithms. Both share common IMU compensation routines but implement vehicle-specific guidance laws.

### How does the AGC executive manage navigation programs?

The **Executive** (`Comanche055/EXECUTIVE.agc`) schedules navigation programs as prioritized jobs based on flag states set by the crew or mission sequencer. Programs like P20 or the ascent guidance routine register with the executive, which allocates CPU time to integration routines (`INTEGRV`) and sensor polling while ensuring critical guidance calculations meet real-time deadlines.

### What guidance algorithm was used for the lunar landing?

The lunar landing phase utilized **quadratic guidance equations** implemented in `Luminary099/LUNAR_LANDING_GUIDANCE_EQUATIONS.agc`. This algorithm computed thrust vectors and attitude adjustments based on real-time state vector updates, altitude measurements, and target landing coordinates, firing the Digital Autopilot to control engine throttling and RCS jets.

### How were IMU sensors compensated for drift?

The **IMU Compensation Package** (`IMU_COMPENSATION_PACKAGE.agc`) applied temperature-dependent bias corrections and scale factor adjustments to gyroscope and accelerometer readings. This preprocessing ensured that navigation filters received accurate inertial data, preventing the accumulation of orientation errors during long-duration translunar coasts or precise landing maneuvers.