Source Code

These source-code files derive from a printout of Luminary 116 (the Apollo 12 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Ron Burkey, and transcribed to source code by a team of volunteers. This colorized, syntax-highlighted form was created by assembling that transcribed source code. Note that the full page images are available on the Virtual AGC project page at archive.org, while reduced-size images are presented at the VirtualAGC project website. Report or fix any transcription errors at the Virtual AGC project code repository.

Notations on the program listing read, in part:

	GAP:  ASSEMBLE REVISION 116 OF AGC PROGRAM LUMINARY BY NASA 2021112-071
	19:09 AUG. 11,1969
Note that the date is the date of the printout, not the date of the program revision.

064274,000002:                                                                                                  ## Copyright:   Public domain.
064275,000003:                                                                                                  ## Filename:    SPS_BACK-UP_RCS_CONTROL.agc
064276,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
064277,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM) 
064278,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
064279,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
064280,000008:                                                                                                  ##              that the code format has been changed to conform to the
064281,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
064282,000010:                                                                                                  ##              original YUL assembler.
064283,000011:                                                                                                  ## Reference:   pp. 1497-1500
064284,000012:                                                                                                  ## Assembler:   yaYUL
064285,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
064286,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
064287,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
064288,000016:                                                                                                  ##              2017-01-23 RRB  Updated for Luminary 116.
064289,000017:                                                                                                  ##              2017-03-14 RSB  Proofed comment text via 3-way diff vs
064290,000018:                                                                                                  ##                              Luminary 99 and 131.
064291,000019: 

Page 1497

064293,000021:                                                                                                  #  PROGRAM NAME:  SPSRCS
064294,000022: 
064295,000023:                                                                                                  #  AUTHOR:  EDGAR M. OSHIKA (AC ELECTRONICS)
064296,000024: 
064297,000025:                                                                                                  #  MODIFIED:  TO RETURN TO ALL AXES VIA Q BY P.S.WEISSMAN, OCT 7, 1968
064298,000026: 
064299,000027:                                                                                                  #  MODIFIED TO IMPROVE BENDING STABILITY BY G. KALAN,FEB.14, 1969
064300,000028:                                                                                                  #  FUNCTIONAL DESCRIPTION:
064301,000029: 
064302,000030:                                                                                                  #  THIS PROGRAM CONTROLS THE FIRING OF ALL RCS JETS IN THE DOCKED CONFIGURATION ACCORDING TO THE FOLLOWING PHASE
064303,000031:                                                                                                  #  PLANE LOGIC.
064304,000032: 
064305,000033:                                                                                                  #  1. JET SENSE TEST (SPSRCS)
064306,000034: 
064307,000035:                                                                                                  #  IF JETS ARE FIRING NEGATIVELY,SET OLDSENSE NEGATIVE AND CONTINUE
064308,000036:                                                                                                  #  IF JETS ARE FIRING POSITIVELY,SET OLDSENSE POSITIVE AND CONTINUE
064309,000037:                                                                                                  #  IF JETS ARE NOT FIRING,SET OLDSENSE TO ZERO AND GO TO OUTER RATE LIMIT TEST
064310,000038: 
064311,000039:                                                                                                  #  2. RATE DEAD BAND TEST
064312,000040: 
064313,000041:                                                                                                  #  IF JETS ARE FIRING NEGATIVELY AND RATE IS GREATER THAN TARGET RATE, LEAVE
064314,000042:                                                                                                  #  JETS ON AND GO TO INHIBITION LOGIC. OTHERWISE, CONTINUE.
064315,000043:                                                                                                  #  IF JETS ARE FIRING POSITIVELY AND RATE IS   LESS  THAN TARGET RATE, LEAVE
064316,000044:                                                                                                  #  JETS ON AND GO TO INHIBITION LOGIC. OTHERWISE, CONTINUE.
064317,000045: 
064318,000046:                                                                                                  #  3. OUTER RATE LIMIT TEST (SPSSTART)
064319,000047: 
064320,000048:                                                                                                  #  IF MAGNITUDE OF EDOT IS GREATER THAN 1.73 DEG/SEC SET JET FIRING TIME
064321,000049:                                                                                                  #   TO REDUCE RATE AND GO TO INHIBITION LOGIC. OTHERWISE, CONTINUE.
064322,000050: 
064323,000051:                                                                                                  #  4. COAST ZONE TEST
064324,000052: 
064325,000053:                                                                                                  #  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-
064326,000054:                                                                                                  #  TIVE AND CONTINUE. OTHERWISE,SET JET FIRING TIME TO ZERO AND CONTINUE.
064327,000055:                                                                                                  #  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
064328,000056:                                                                                                  #  AND CONTINUE. OTHERWISE,SET JET FIRING TIME TO ZERO AND CONTINUE.
064329,000057: 
064330,000058:                                                                                                  #  5. INHIBITION LOGIC
064331,000059: 
064332,000060:                                                                                                  #  IF OLDSENSE IS NON-ZERO:
064333,000061: 
064334,000062:                                                                                                  #        A) RETURN IF JET TIME HAS SAME SIGN AS OLDSENSE
064335,000063:                                                                                                  #        B) SET INHIBITION COUNTER*AND RETURN IF JET TIME IS ZERO
064336,000064:                                                                                                  #        C) SET INHIBITION COUNTER,*SET JET TIME TO ZERO AND RETURN IF SIGN
064337,000065:                                                                                                  #           OF JET TIME IS OPPOSITE TO THAT OF OLDSENSE
064338,000066: 
064339,000067:                                                                                                  #  IF OLDSENSE IS ZERO:
064340,000068:                                                                                                  #        A) RETURN IF INHIBITION COUNTER IS NOT POSITIVE
064341,000069:                                                                                                  #        B) SET JET TIME TO ZERO AND RETURN IF INHIBITION COUNTER IS POSITIVE
064342,000070:                                                                                                  #  *NOTE: INHIBITION COUNTERS CAN BE SET TO 4 OR 10 FOR THE P, AND UV AXES,
064343,000071:                                                                                                  #  RESPECTIVELY, IN SPSRCS. THEY ARE DECREMENTED BY ONE AT THE BEGINNING OF

Page 1498

064345,000073:                                                                                                  #  EACH DAP PASS.
064346,000074: 
064347,000075:                                                                                                  #  THE MINIMUM PULSE WIDTH OF THIS CONTROLLER IS DETERMINED BY THE REPETITION  RATE AT WHICH THIS ROUTINE IS CALLED
064348,000076:                                                                                                  #  AND IS NOMINALLY 100 MS FOR ALL AXES IN DRIFTING FLIGHT.   DURING POWERED FLIGHT THE MINIMUM IS 100 MS FOR THE
064349,000077:                                                                                                  #  P AXIS AND 200 MS FOR THE CONTROL OF THE U AND V AXES.
064350,000078: 
064351,000079:                                                                                                  #  CALLING SEQUENCE:
064352,000080: 
064353,000081:                                                                                                  #                INHINT
064354,000082:                                                                                                  #                TC      IBNKCALL
064355,000083:                                                                                                  #                CADR    SPSRCS
064356,000084: 
064357,000085:                                                                                                  #  EXIT:
064358,000086: 
064359,000087:                                                                                                  #                TC      Q
064360,000088:                                                                                                  #  ALARM/ABORT MODE:     NONE
064361,000089: 
064362,000090:                                                                                                  #  SUBROUTINES CALLED:   NONE
064363,000091: 
064364,000092:                                                                                                  #  INPUT:                E,EDOT
064365,000093:                                                                                                  #                        TJP, TJV, TJU           TJ MUST NOT BE NEGATIVE ZERO
064366,000094: 
064367,000095:                                                                                                  #  OUTPUT:               TJP, TJV, TJU
064368,000096: 
064369,000097: 21,3647                                           BANK     21                                    
064370,000098: 21,2000                                           SETLOC   DAPS4                                 
064371,000099: 21,2000                                           BANK                                           
064372,000100: 
064373,000101: 21,3647                                           COUNT*   $$/DAPBU                              
064374,000102: 
064375,000103: 21,3647  E6,1525                                  EBANK=   TJU                                   
064376,000104: 21,3647           00632        RATELIM2           OCT      00632                                 #  1.125 DEG/SEC
064377,000105: 21,3650           34736        POSTHRST           CA       HALF                                  
064378,000106: 
064379,000107: 21,3651           51505                           NDX      AXISCTR                               
064380,000108: 21,3652           55525                           TS       TJU                                   
064381,000109: 21,3653           11745                           CCS      OLDSENSE                              
064382,000110: 21,3654           13674                           TCF      POSCHECK                              #  JETS FIRING POSITIVELY
064383,000111: 21,3655           13677                           TCF      CTRCHECK                              #  JETS OFF. CHECK INHIBITION CTR
064384,000112: 21,3656           51505        NEGCHECK           INDEX    AXISCTR                               #  JETS FIRING NEGATIVELY
064385,000113: 21,3657           41525                           CS       TJU                                   
064386,000114: 21,3660           10000                           CCS      A                                     
064387,000115: 21,3661           00002                           TC       Q                                     #  RETURN
064388,000116: 21,3662           13664                           TCF      +2                                    
064389,000117: 21,3663           13664                           TCF      +1                                    #  JETS COMMANDED OFF.SET CTR AND RETURN
064390,000118: 21,3664           51505        SETCTR             INDEX    AXISCTR                               #  JET FIRING REVERSAL COMMANDED.  SET CTR,
064391,000119: 21,3665           33706                           CA       UTIME                                 #  SET JET TIME TO ZERO, AND RETURN

Page 1499

064393,000121: 21,3666           51505                           INDEX    AXISCTR                               
064394,000122: 21,3667           55770                           TS       UJETCTR                               
064395,000123: 21,3670           34755        ZAPTJ              CA       ZERO                                  
064396,000124: 21,3671           51505                           INDEX    AXISCTR                               
064397,000125: 21,3672           55525                           TS       TJU                                   
064398,000126: 21,3673           00002                           TC       Q                                     
064399,000127: 21,3674           51505        POSCHECK           INDEX    AXISCTR                               
064400,000128: 21,3675           31525                           CA       TJU                                   
064401,000129: 21,3676           13660                           TCF      NEGCHECK   +2                         
064402,000130: 21,3677           51505        CTRCHECK           INDEX    AXISCTR                               #  CHECK JET INHIBITION COUNTER
064403,000131: 21,3700           11770                           CCS      UJETCTR                               
064404,000132: 21,3701           13703                           TCF      +2                                    
064405,000133: 21,3702           00002                           TC       Q                                     #  CTR IS NOT POSITIVE. RETURN
064406,000134: 21,3703           13670                           TCF      ZAPTJ                                 #  CTR IS POSITIVE.INHIBIT FIRINGS
064407,000135: 21,3704           00002                           TC       Q                                     #  CTR IS NOT POSITIVE.RETURN
064408,000136: 21,3705           00004                           OCT      00004                                 
064409,000137: 21,3706           00012        UTIME              OCT      00012                                 
064410,000138: 21,3707           00012                           OCT      00012                                 
064411,000139: 21,3710  E6,1745               OLDSENSE           EQUALS   DAPTREG1                              
064412,000140: 21,3710           44753        NEGFIRE            CS       ONE                                   #  JETS FIRING NEGATIVELY
064413,000141: 21,3711           55745                           TS       OLDSENSE                              
064414,000142: 21,3712           31427                           CA       EDOT                                  
064415,000143: 21,3713           13717                           TCF      +4                                    
064416,000144: 21,3714           34753        PLUSFIRE           CA       ONE                                   
064417,000145: 21,3715           55745                           TS       OLDSENSE                              
064418,000146: 21,3716           41427                           CS       EDOT                                  #  RATE DEAD BAND TEST
064419,000147: 21,3717           22000                           LXCH     A                                     
064420,000148: 21,3720           40111                           CS       DAPBOOLS                              #  IF DRIFTBIT = 1, USE ZERO TARGET RATE
064421,000149: 21,3721           74744                           MASK     DRIFTBIT                              #  IF DRIFTBIT = 0, USE 0.10 RATE TARGET
064422,000150: 21,3722           10000                           CCS      A                                     
064423,000151: 21,3723           34767                           CA       RATEDB1                               
064424,000152: 21,3724           60001                           AD       L                                     
064425,000153: 21,3725           00006                           EXTEND                                         
064426,000154: 21,3726           63736                           BZMF     SPSSTART                              
064427,000155: 21,3727           13653                           TCF      POSTHRST   +3                         
064428,000156: 
064429,000157: 21,3730           51505        SPSRCS             INDEX    AXISCTR                               #  JET SENSE TEST
064430,000158: 21,3731           11525                           CCS      TJU                                   
064431,000159: 21,3732           13714                           TCF      PLUSFIRE                              #  JETS FIRING POSITIVELY
064432,000160: 21,3733           13735                           TCF      +2                                    
064433,000161: 21,3734           13710                           TCF      NEGFIRE                               #  JETS FIRING NEGATIVELY
064434,000162: 21,3735           55745                           TS       OLDSENSE                              #  JETS OFF
064435,000163: 21,3736           31427        SPSSTART           CA       EDOT                                  #  OUTER RATE LIMIT TEST
064436,000164: 21,3737           00006                           EXTEND                                         
064437,000165: 21,3740           74766                           MP       RATELIM1                              
064438,000166: 21,3741           10000                           CCS      A                                     
064439,000167: 21,3742           13761                           TCF      NEGTHRST                              #  OUTER RATE LIMIT EXCEEDED
064440,000168: 21,3743           13745                           TCF      +2                                    
064441,000169: 21,3744           13650                           TCF      POSTHRST                              #  OUTER RATE LIMIT EXCEEDED
064442,000170: 21,3745           31427                           CA       EDOT                                  #  COAST ZONE TEST

Page 1500

064444,000172: 21,3746           61752                           AD       E                                     
064445,000173: 21,3747           00006                           EXTEND                                         
064446,000174: 21,3750           71411                           MP       DKDB                                  #  PAD LOADED DEADBAND. FRESHSTART: 1.4 DEG
064447,000175: 21,3751           00006                           EXTEND                                         
064448,000176: 21,3752           13767                           BZF      TJZERO                                
064449,000177: 
064450,000178: 21,3753           00006                           EXTEND                                         
064451,000179: 21,3754           63763                           BZMF     +7                                    
064452,000180: 21,3755           31427                           CA       EDOT                                  
064453,000181: 21,3756           63647                           AD       RATELIM2                              
064454,000182: 21,3757           00006                           EXTEND                                         
064455,000183: 21,3760           63767                           BZMF     TJZERO                                
064456,000184: 21,3761           44736        NEGTHRST           CS       HALF                                  
064457,000185: 21,3762           13651                           TCF      POSTHRST   +1                         
064458,000186: 21,3763           43647                 +7        CS       RATELIM2                              
064459,000187: 21,3764           61427                           AD       EDOT                                  
064460,000188: 21,3765           00006                           EXTEND                                         
064461,000189: 21,3766           63650                           BZMF     POSTHRST                              
064462,000190: 21,3767           34755        TJZERO             CA       ZERO                                  
064463,000191: 21,3770           13651                           TCF      POSTHRST   +1                         
064464,000192: 
064465,000193: 21,3771     4766               RATELIM1           =        CALLCODE                              #  = 00032, CORRESPONDING TO 1.73 DEG/SEC
064466,000194: 21,3771     4767               RATEDB1            =        TBUILDFX                              #   = 00045, CORRESPONDS TO 0.101 DEG/SEC
064467,000195: 

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