Source Code

This source code is very close to the Apollo Guidance Computer software for the Apollo 13 Lunar module. This revision of the Luminary 131 program is from December of 1969, whereas there was a later revision in January of 1970, and still another revision in February, which is the code that flew on the mission. As far as this transcription is concerned, it was originally from a copy made in 1991 of a printout from the collection of AGC developer Don Eyles for collector David Craig. It was subsequently scanned by Gary Neff, reprocessed for online presentation at the now-discontinued History of Recent Science and Technology (HRST) website of MIT's Dibner Institute (the full-quality scans being discarded in the process), and finally transcribed by Ron Burkey for the Virtual AGC Project. Although a high-quality replacement scan for a completely illegible page was later provided by Gary Neff, the reduced legibility of the reprocessed HRST posting nevertheless caused many errors to be introduced into the transcription. Accordingly, a second scan of the same physical printout was made in 2017 for the Virtual AGC Project's collection at the Internet Archive, and used to correct the transcription errors. All of the scanned materials mentioned, as well as other Luminary 131 related material, are available online. Don Eyles apprently made additional hand-written notes in printout between 1991 and 2017, so the two scans are not identical in that respect. The page-headings in the printout read, in part:
	GAP:  ASSEMBLE REVISION 131 OF AGC PROGRAM LUMINARY BY NASA 2021112-091
	17:53 DEC. 19, 1969
Note that the date is the date the printout was made, not the date on which the program revision was released, although these happen to be very close together.

063872,000002:                                                                                                  ## Copyright:   Public domain.
063873,000003:                                                                                                  ## Filename:    SPS_BACK-UP_RCS_CONTROL.agc
063874,000004:                                                                                                  ## Purpose:     A section of Luminary 1C, revision 131.
063875,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
063876,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
063877,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
063878,000008:                                                                                                  ##              that the code format has been changed to conform to the
063879,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
063880,000010:                                                                                                  ##              original YUL assembler.
063881,000011:                                                                                                  ## Reference:   pp. 1499-1502 
063882,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
063883,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
063884,000014:                                                                                                  ## Mod history: 06/08/03 RSB.   Began transcribing.
063885,000015:                                                                                                  ##              05/14/05 RSB    Corrected website reference above.
063886,000016:                                                                                                  ##              2010-10-25 JL   Indentation fixes.
063887,000017:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
063888,000018:                                                                                                  ##                              original hardcopy, as opposed to the PDF page
063889,000019:                                                                                                  ##                              numbers in 1701.pdf.
063890,000020:                                                                                                  ##              2017-02-28 RSB  Proofed comment text using octopus/ProoferComments.
063891,000021:                                                                                                  ##              2017-03-14 RSB  Comment-text fixes noted in proofing Luminary 116.
063892,000022: 

Page 1499

063894,000024:                                                                                                  #  PROGRAM NAME:         SPSRCS
063895,000025:                                                                                                  #  AUTHOR:               EDGAR M. OSHIKA (AC ELECTRONICS)
063896,000026:                                                                                                  #  MODIFIED:             TO RETURN TO ALL AXES VIA Q BY P. S. WEISSMAN, OCT 7, 1968
063897,000027:                                                                                                  #  MODIFIED TO IMPROVE BENDING STABILITY BY G. KALAN, FEB. 14, 1969
063898,000028: 
063899,000029:                                                                                                  #  FUNCTIONAL DESCRIPTION:
063900,000030:                                                                                                  #        THIS PROGRAM CONTROLS THE FIRING OF ALL RCS JETS IN THE DOCKED CONFIGURATION ACCORDING TO THE FOLLOWING PHASE
063901,000031:                                                                                                  #        PLANE LOGIC.
063902,000032: 
063903,000033:                                                                                                  #        1. JET SENSE TEST (SPSRCS)
063904,000034:                                                                                                  #                IF JETS ARE FIRING NEGATIVELY, SET OLDSENSE NEGATIVE AND CONTINUE
063905,000035:                                                                                                  #                IF JETS ARE FIRING POSITIVELY, SET OLDSENSE POSITIVE AND CONTINUE
063906,000036:                                                                                                  #                IF JETS ARE NOT FIRING, SET OLDSENSE TO ZERO AND GO TO OUTER RATE LIMIT TEST
063907,000037: 
063908,000038:                                                                                                  #        2. RATE DEAD BAND TEST
063909,000039:                                                                                                  #                IF JETS ARE FIRING NEGATIVELY AND RATE IS GREATER THAN TARGET RATE, LEAVE
063910,000040:                                                                                                  #                JETS ON AND GO TO INHIBITION LOGIC.  OTHERWISE, CONTINUE.
063911,000041:                                                                                                  #                IF JETS ARE FIRING POSITIVELY AND RATE IS LESS THAN TARGET RATE, LEAVE
063912,000042:                                                                                                  #                JETS ON AND GO TO INHIBITION LOGIC.  OTHERWISE, CONTINUE.
063913,000043: 
063914,000044:                                                                                                  #        3. OUTER RATE LIMIT TEST (SPSSTART)
063915,000045:                                                                                                  #                IF MAGNITUDE OF EDOT IS GREATER THAN 1.73 DEG/SEC SET JET FIRING TIME
063916,000046:                                                                                                  #                TO REDUCE RATE AND GO TO INHIBITION LOGIC.  OTHERWISE, CONTINUE.
063917,000047: 
063918,000048:                                                                                                  #        4. COAST ZONE TEST
063919,000049:                                                                                                  #                IF STATE (E,EDOT) IS BELOW LINE E + 4 X EDOT > -1.4 DEG AND EDOT IS LESS THAN 1.30 DEG/SEC SET JET TIME POSI-
063920,000050:                                                                                                  #                TIVE AND CONTINUE.  OTHERWISE, SET JET FIRING TIME TO ZERO AND CONTINUE.
063921,000051:                                                                                                  #                IF STATE IS ABOVE LINE E + 4 X EDOT > +1.4 DEG AND EDOT IS GREATER THAN -1.30 DEG/SEC, SET JET TIME NEGATIVE
063922,000052:                                                                                                  #                AND CONTINUE.  OTHERWISE, SET JET FIRING TIME TO ZERO AND CONTINUE.
063923,000053: 
063924,000054:                                                                                                  #        5. INHIBITION LOGIC
063925,000055:                                                                                                  #                IF OLDSENSE IS NON-ZERO:
063926,000056:                                                                                                  #                        A) RETURN IF JET TIME HAS SAME SIGN AS OLDSENSE
063927,000057:                                                                                                  #                        B) SET INHIBITION COUNTER* AND RETURN IF JET TIME IS ZERO
063928,000058:                                                                                                  #                        C) SET INHIBITION COUNTER,* SET JET TIME TO ZERO AND RETURN IF SIGN
063929,000059:                                                                                                  #                           OF JET TIME IS OPPOSITE TO THAT OF OLDSENSE
063930,000060:                                                                                                  #                IF OLDSENSE IS ZERO:
063931,000061:                                                                                                  #                        A) RETURN IF INHIBITION COUNTER IS NOT POSITIVE
063932,000062:                                                                                                  #                        B) SET JET TIME TO ZERO AND RETURN IF INHIBITION COUNTER IS POSITIVE
063933,000063:                                                                                                  #                *NOTE: INHIBITION COUNTERS CAN BE SET TO 4 OR 10 FOR THE P,AND UV AXES,
063934,000064:                                                                                                  #                RESPECTIVELY, IN SPSRCS.  THEY ARE DECREMENTED BY ONE AT THE BEGINNING OF

Page 1500

063936,000066:                                                                                                  #                EACH DAP PASS.
063937,000067: 
063938,000068:                                                                                                  #        THE MINIMUM PULSE WIDTH OF THIS CONTROLLER IS DETERMINED BY THE REPETITION RATE AT WHICH THIS ROUTINE IS CALLED
063939,000069:                                                                                                  #        AND IS NOMINALLY 100 MS FOR ALL AXES IN DRIFTING FLIGHT.  DURING POWERED FLIGHT THE MINIMUM IS 100 MS FOR THE
063940,000070:                                                                                                  #        P AXIS AND 200 MS FOR THE CONTROL OF THE U AND V AXES.
063941,000071: 
063942,000072:                                                                                                  #  CALLING SEQUENCE:
063943,000073:                                                                                                  #                INHINT
063944,000074:                                                                                                  #                TC      IBNKCALL
063945,000075:                                                                                                  #                CADR    SPSRCS
063946,000076: 
063947,000077:                                                                                                  #  EXIT:
063948,000078:                                                                                                  #                TC      Q
063949,000079: 
063950,000080:                                                                                                  #  ALARM/ABORT MODE:     NONE
063951,000081: 
063952,000082:                                                                                                  #  SUBROUTINES CALLED:   NONE
063953,000083: 
063954,000084:                                                                                                  #  INPUT:                E, EDOT
063955,000085:                                                                                                  #                        TJP, TJV, TJU           TJ MUST NOT BE NEGATIVE ZERO
063956,000086: 
063957,000087:                                                                                                  #  OUTPUT:               TJP, TJV, TJU
063958,000088: 
063959,000089: 21,3655                                           BANK     21                                    
063960,000090: 21,2000                                           SETLOC   DAPS4                                 
063961,000091: 21,2000                                           BANK                                           
063962,000092: 
063963,000093: 21,3655                                           COUNT*   $$/DAPBU                              
063964,000094: 
063965,000095: 21,3655  E6,1525                                  EBANK=   TJU                                   
063966,000096: 21,3655           00632        RATELIM2           OCT      00632                                 #  1.125 DEG/SEC
063967,000097: 21,3656           34736        POSTHRST           CA       HALF                                  
063968,000098: 
063969,000099: 21,3657           51505                           NDX      AXISCTR                               
063970,000100: 21,3660           55525                           TS       TJU                                   
063971,000101: 21,3661           11744                           CCS      OLDSENSE                              
063972,000102: 21,3662           13702                           TCF      POSCHECK                              #  JETS FIRING POSITIVELY
063973,000103: 21,3663           13705                           TCF      CTRCHECK                              #  JETS OFF.  CHECK INHIBITION CTR
063974,000104: 21,3664           51505        NEGCHECK           INDEX    AXISCTR                               #  JETS FIRING NEGATIVELY
063975,000105: 21,3665           41525                           CS       TJU                                   
063976,000106: 21,3666           10000                           CCS      A                                     
063977,000107: 21,3667           00002                           TC       Q                                     #  RETURN
063978,000108: 21,3670           13672                           TCF      +2                                    
063979,000109: 21,3671           13672                           TCF      +1                                    #  JETS COMMANDED OFF.  SET CTR AND RETURN
063980,000110: 21,3672           51505        SETCTR             INDEX    AXISCTR                               #  JET FIRING REVERSAL COMMANDED.  SET CTR,
063981,000111: 21,3673           33714                           CA       UTIME                                 #  SET JET TIME TO ZERO,AND RETURN

Page 1501

063983,000113: 21,3674           51505                           INDEX    AXISCTR                               
063984,000114: 21,3675           55767                           TS       UJETCTR                               
063985,000115: 21,3676           34755        ZAPTJ              CA       ZERO                                  
063986,000116: 21,3677           51505                           INDEX    AXISCTR                               
063987,000117: 21,3700           55525                           TS       TJU                                   
063988,000118: 21,3701           00002                           TC       Q                                     
063989,000119: 21,3702           51505        POSCHECK           INDEX    AXISCTR                               
063990,000120: 21,3703           31525                           CA       TJU                                   
063991,000121: 21,3704           13666                           TCF      NEGCHECK   +2                         
063992,000122: 21,3705           51505        CTRCHECK           INDEX    AXISCTR                               #  CHECK JET INHIBITION COUNTER
063993,000123: 21,3706           11767                           CCS      UJETCTR                               
063994,000124: 21,3707           13711                           TCF      +2                                    
063995,000125: 21,3710           00002                           TC       Q                                     #  CTR IS NOT POSITIVE.  RETURN
063996,000126: 21,3711           13676                           TCF      ZAPTJ                                 #  CTR IS POSITIVE.  INHIBIT FIRINGS
063997,000127: 21,3712           00002                           TC       Q                                     #  CTR IS NOT POSITIVE.  RETURN
063998,000128: 21,3713           00004                           OCT      00004                                 
063999,000129: 21,3714           00012        UTIME              OCT      00012                                 
064000,000130: 21,3715           00012                           OCT      00012                                 
064001,000131: 21,3716  E6,1744               OLDSENSE           EQUALS   DAPTREG1                              
064002,000132: 21,3716           44753        NEGFIRE            CS       ONE                                   #  JETS FIRING NEGATIVELY
064003,000133: 21,3717           55744                           TS       OLDSENSE                              
064004,000134: 21,3720           31427                           CA       EDOT                                  
064005,000135: 21,3721           13725                           TCF      +4                                    
064006,000136: 21,3722           34753        PLUSFIRE           CA       ONE                                   
064007,000137: 21,3723           55744                           TS       OLDSENSE                              
064008,000138: 21,3724           41427                           CS       EDOT                                  #  RATE DEAD BAND TEST
064009,000139: 21,3725           22000                           LXCH     A                                     
064010,000140: 21,3726           40111                           CS       DAPBOOLS                              #  IF DRIFTBIT = 1, USE ZERO TARGET RATE
064011,000141: 21,3727           74744                           MASK     DRIFTBIT                              #  IF DRIFTBIT = 0, USE 0.10 RATE TARGET
064012,000142: 21,3730           10000                           CCS      A                                     
064013,000143: 21,3731           34767                           CA       RATEDB1                               
064014,000144: 21,3732           60001                           AD       L                                     
064015,000145: 21,3733           00006                           EXTEND                                         
064016,000146: 21,3734           63744                           BZMF     SPSSTART                              
064017,000147: 21,3735           13661                           TCF      POSTHRST   +3                         
064018,000148: 
064019,000149: 21,3736           51505        SPSRCS             INDEX    AXISCTR                               #  JET SENSE TEST
064020,000150: 21,3737           11525                           CCS      TJU                                   
064021,000151: 21,3740           13722                           TCF      PLUSFIRE                              #  JETS FIRING POSITIVELY
064022,000152: 21,3741           13743                           TCF      +2                                    
064023,000153: 21,3742           13716                           TCF      NEGFIRE                               #  JETS FIRING NEGATIVELY
064024,000154: 21,3743           55744                           TS       OLDSENSE                              #  JETS OFF
064025,000155: 21,3744           31427        SPSSTART           CA       EDOT                                  #  OUTER RATE LIMIT TEST
064026,000156: 21,3745           00006                           EXTEND                                         
064027,000157: 21,3746           74766                           MP       RATELIM1                              
064028,000158: 21,3747           10000                           CCS      A                                     
064029,000159: 21,3750           13767                           TCF      NEGTHRST                              #  OUTER RATE LIMIT EXCEEDED
064030,000160: 21,3751           13753                           TCF      +2                                    
064031,000161: 21,3752           13656                           TCF      POSTHRST                              #  OUTER RATE LIMIT EXCEEDED
064032,000162: 21,3753           31427                           CA       EDOT                                  #  COAST ZONE TEST

Page 1502

064034,000164: 21,3754           61751                           AD       E                                     
064035,000165: 21,3755           00006                           EXTEND                                         
064036,000166: 21,3756           71411                           MP       DKDB                                  #  PAD LOADED DEADBAND.  FRESHSTART: 1.4 DEG
064037,000167: 21,3757           00006                           EXTEND                                         
064038,000168: 21,3760           13775                           BZF      TJZERO                                
064039,000169: 
064040,000170: 21,3761           00006                           EXTEND                                         
064041,000171: 21,3762           63771                           BZMF     +7                                    
064042,000172: 21,3763           31427                           CA       EDOT                                  
064043,000173: 21,3764           63655                           AD       RATELIM2                              
064044,000174: 21,3765           00006                           EXTEND                                         
064045,000175: 21,3766           63775                           BZMF     TJZERO                                
064046,000176: 21,3767           44736        NEGTHRST           CS       HALF                                  
064047,000177: 21,3770           13657                           TCF      POSTHRST   +1                         
064048,000178: 21,3771           43655                 +7        CS       RATELIM2                              
064049,000179: 21,3772           61427                           AD       EDOT                                  
064050,000180: 21,3773           00006                           EXTEND                                         
064051,000181: 21,3774           63656                           BZMF     POSTHRST                              
064052,000182: 21,3775           34755        TJZERO             CA       ZERO                                  
064053,000183: 21,3776           13657                           TCF      POSTHRST   +1                         
064054,000184: 
064055,000185: 21,3777     4766               RATELIM1           =        CALLCODE                              #  = 00032, CORRESPONDING TO 1.73 DEG/SEC
064056,000186: 21,3777     4767               RATEDB1            =        TBUILDFX                              #  = 00045, CORRESPONDS TO 0.101 DEG/SEC

End of include-file SPS_BACK-UP_RCS_CONTROL.agc.  Parent file is MAIN.agc