# Apollo Abort Guidance System

The Apollo Abort Guidance System (AGS, also known as Abort Guidance Section) was a backup computer system providing an abort capability in the event of failure of the Lunar Module's primary guidance system (Apollo PGNCS) during descent, ascent or rendezvous. As an abort system, it did not support guidance for a lunar landing.
The AGS was designed by TRW independently of the development of the Apollo Guidance Computer and PGNCS.
It was the first navigation system to use a strapdown Inertial Measurement Unit rather than a gimbaled gyrostabilized IMU (as used by PGNCS). Although not as accurate as the gimbaled IMU, it provided satisfactory accuracy with the help of the optical telescope and rendezvous radar. It was also lighter and smaller in size.

## Description

The Abort Guidance System included the following components:
* Abort Electronic Assembly (AEA): the AGS computer
* Abort Sensor Assembly (ASA): a simple strapdown IMU
* Data Entry and Display Assembly (DEDA): the astronaut interface, similar to DSKY
The computer used was MARCO 4418 (MARCO stands for Man Rated Computer) whose dimensions were 5 by 8 by 23.75 inches (12.7 by 20.3 by 60.33 centimeters); it weighed 32.7 pounds (14.83 kg) and required 90 watts of power. Because the memory had a serial access it was slower than AGC, although some operations on AEA were performed as fast or faster than on AGC.
The computer had the following characteristics:
* It had 4096 words of magnetic core memory with a 5 microsecond cycle time. Lower 2,048 words were erasable memory (RAM), higher 2,048 words served as fixed memory (ROM), with one sense wire only passing through zero cores.$^{:p.5}$ The fixed and erasable memory were constructed similarly so the ratio between fixed and erasable memory was variable.
* It was an 18-bit machine, with 17 magnitude bits and a sign bit. The addresses were 13 bits long; MSB indicated index addressing.
* Data words were two's complement and in fixed-point form.

### Registers

The AEA has the following registers:
* A: Accumulator (18 bit)
* M: Memory Register (18 bit), holds data that are being transferred between the central computer and memory
* Q: Multiplier-Quotient Register (18 bit), stores the least significant half of result after multiplication and division. It can be also used as extension of Accumulator
* Index Register (3 bit): used for index addressing
Other registers include:
* Address Register (12 bit): holds the memory address requested by central computer
* Operation Code Register (5 bit): holds 5-bit instruction code during its execution
* Program Counter (12 bit)
* Cycle Counter (5 bit): controls shift instructions
* Timers (2 registers): produce the control timing signals
* Input Registers: 13 registers. Many of the input registers had counters to integrate pulses from the abort and primary guidance systems.

### Instruction set

The AEA instruction format consisted of five-bit instruction code, index bit and a 12-bit address.
The computer had 27 instructions:
ADD: The contents of memory location are added to Accumulator A. The contents of the memory location remain unchanged.
ADZ (Add and Zero): The contents of memory are added to Accumulator A. The contents of memory are set to zero.
SUB (Subtract): The contents of memory are subtracted from Accumulator A. The contents of memory remain unchanged.
SUZ (Subtract and Zero): The contents of memory are subtracted from Accumulator A. The contents of memory are set to zero.
MPY (Multiply): The contents of Accumulator A are multiplied by the contents of memory. The most significant part of the product is placed in the Accumulator A, the least significant part is placed in Register Q.
MPR (Multiply and Round): Identical to MPY instruction, the most significant part of the product in Accumulator A is rounded by adding one to the contents of Accumulator A if bit 1 of Q Register equals one.
MPZ (Multiply and Zero): Identical to MPR instruction, the contents of memory are set to zero.
DVP (Divide): The contents of Accumulator A and Register Q that form a dividend are divided by the contents of memory. The quotient is placed in Accumulator A and rounded unless the rounding would cause overflow.
COM (Complement Accumulator): The contents of Accumulator A are replaced with their two's complement. If the contents of the Accumulator A are positive, zero or minus one, the contents remain unchanged.
CLA (Clear and Add): The Accumulator A is loaded from memory. The contents of memory remain unchanged.
CLZ (Clear, Add and Zero): Similar to CLA instruction; the contents of memory are set to zero.
LDQ (Load Q Register): The Q Register is loaded with contents of memory. The contents of memory remain unchanged.
STO (Store Accumulator): The contents of Accumulator A are stored in memory. The contents of Accumulator A remain unchanged.
STQ (Store Q Register): The contents of Q Register are stored in memory. The contents of Q Register remain unchanged.
ALS N (Arithmetic Left Shift): The contents of Accumulator A are shifted left N places.
LLS N (Long Left Shift): The contents of Accumulator A and bits 1 - 17 of Q Register are shifted left as one register N places. The sign of Q Register is made to agree with sign of Accumulator A.
LRS N (Long Right Shift): Similar to LLS, but the contents are shifted right N places.
TRA (Transfer): The next instruction is taken from memory.
TSQ (Transfer and Set Q): The contents of the Q Register are replaced with an address field set to one greater than the location of the TSQ instruction. Next instruction is taken from memory.
TMI (Transfer on Minus Accumulator): The next instruction is taken from memory if the contents of the Accumulator A are negative. Otherwise the next instruction is taken in sequence.
TOV (Transfer on Overflow): If the overflow indicator is set, the next instruction is taken from memory.
AXT N (Address to Index): The Index Register is set to N.
TIX (Test Index and Transfer): If the Index Register is positive, it is decremented by one and the next instruction is taken from memory.
DLY (Delay): Execution stops until a timing signal is received. The next instruction is taken from memory.
INP (Input): The contents of input register specified by address are placed in Accumulator A. The input register is either set to zero or remains unchanged (depending upon the selected register).
OUT (Output): The contents of the Accumulator A are placed in output register specified by address.

### Software

First design ideas of the Abort Guidance System did not include the use of the computer but rather a sequencer without any navigation capability. This would be adequate to put the Lunar Module into lunar orbit where the crew would wait for rescue by the Apollo CSM. Later design included a digital computer to provide some autonomy.
The AGS software was written in LEMAP assembly language that uses 27 instructions described above and a set of pseudo-operations used by the assembler.
The main computation cycle was 2 seconds long. This 2-second cycle was divided into 100 segments; each of these segments had a duration of 20 ms. These segments were used for computations that needed to be recalculated every 20 ms (like IMU signal processing, update of PGNCS downlink data, direction cosines update, etc.).
There was also a set of computations that had to be performed every 40 ms (engine commands, external signal sampling, attitude control, etc.).
Other computations were performed every 2 seconds and these equations were divided into smaller groups so they could be recalculated during the remaining (i.e. unused) time of 20 ms segments (e.g. radar data processing, calculation of orbital parameters, computation of rendezvous sequence, calibration of IMU sensors, etc.)
The software for AGS was reviewed many times to find program errors and to reduce the size of the software. There are some known versions of the software that were used for uncrewed and crewed tests.

### User interface

The AGS User interface unit was named DEDA (Data Entry and Display Assembly). Its function was entry and readout of data from the AGS. Some of the system's functionality was built into DEDA unlike the DSKY used by AGC.
DEDA had the following elements:
* Numeral keys 0 - 9
* + and - sign key
* CLR key: clears the entry display and clears the OPR ERR light
* ENTER key: for data/address entry
* READOUT key: reads the data from the specified address and displays the refreshed data every half second
* HOLD key: stops the continuous outputting of data
* OPR ERR light: indicates Operator's error
* displays are used to enter and read the data

## Use of AGS

There are few actual descriptions of the use of the AGS, as a landing abort was never needed during the Apollo missions. There were, however, four cases in which the AGS was used.
Its first use was for testing of the Lunar Module descent stage in Earth orbital flight during the Apollo 9 mission. It was used again in the Apollo 10 mission, following separation of the Lunar Module descent stage prior to the APS burn. An incorrect switch setting leaving AGS in Auto rather than Attitude Hold mode led to a prompt and pronounced deviation in attitude moments before staging. The situation was quickly brought under control.
The next use of the AGS was during the lunar ascent phase of the Apollo 11 mission, when the LM crew performed a sequence of rendezvous maneuvers that resulted in gimbal lock; the AGS was subsequently used to acquire attitude control.
The AGS played an important role in the safe return of Apollo 13 after an oxygen tank explosion left the Service Module crippled and forced the astronauts to use the Lunar Module as a "lifeboat." Supplies of electrical power and water on the LM were limited and the Primary Guidance and Navigation System used too much water for cooling. As a result, after a major LM descent engine burn two hours past its closest approach to the Moon to shorten the trip home, the AGS was used for most of the return, including two mid-course corrections.$^{pp.III-17,32,35,40}$