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.

064248,000002:                                                                                                  ## Copyright:   Public domain.
064249,000003:                                                                                                  ## Filename:    SPS_BACK-UP_RCS_CONTROL.agc
064250,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
064251,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM) 
064252,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
064253,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
064254,000008:                                                                                                  ##              that the code format has been changed to conform to the
064255,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
064256,000010:                                                                                                  ##              original YUL assembler.
064257,000011:                                                                                                  ## Reference:   pp. 1497-1500
064258,000012:                                                                                                  ## Assembler:   yaYUL
064259,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
064260,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
064261,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
064262,000016:                                                                                                  ##              2017-01-23 RRB  Updated for Luminary 116.
064263,000017:                                                                                                  ##              2017-03-14 RSB  Proofed comment text via 3-way diff vs
064264,000018:                                                                                                  ##                              Luminary 99 and 131.
064265,000019: 

Page 1497

064267,000021:                                                                                                  #  PROGRAM NAME:  SPSRCS
064268,000022: 
064269,000023:                                                                                                  #  AUTHOR:  EDGAR M. OSHIKA (AC ELECTRONICS)
064270,000024: 
064271,000025:                                                                                                  #  MODIFIED:  TO RETURN TO ALL AXES VIA Q BY P.S.WEISSMAN, OCT 7, 1968
064272,000026: 
064273,000027:                                                                                                  #  MODIFIED TO IMPROVE BENDING STABILITY BY G. KALAN,FEB.14, 1969
064274,000028:                                                                                                  #  FUNCTIONAL DESCRIPTION:
064275,000029: 
064276,000030:                                                                                                  #  THIS PROGRAM CONTROLS THE FIRING OF ALL RCS JETS IN THE DOCKED CONFIGURATION ACCORDING TO THE FOLLOWING PHASE
064277,000031:                                                                                                  #  PLANE LOGIC.
064278,000032: 
064279,000033:                                                                                                  #  1. JET SENSE TEST (SPSRCS)
064280,000034: 
064281,000035:                                                                                                  #  IF JETS ARE FIRING NEGATIVELY,SET OLDSENSE NEGATIVE AND CONTINUE
064282,000036:                                                                                                  #  IF JETS ARE FIRING POSITIVELY,SET OLDSENSE POSITIVE AND CONTINUE
064283,000037:                                                                                                  #  IF JETS ARE NOT FIRING,SET OLDSENSE TO ZERO AND GO TO OUTER RATE LIMIT TEST
064284,000038: 
064285,000039:                                                                                                  #  2. RATE DEAD BAND TEST
064286,000040: 
064287,000041:                                                                                                  #  IF JETS ARE FIRING NEGATIVELY AND RATE IS GREATER THAN TARGET RATE, LEAVE
064288,000042:                                                                                                  #  JETS ON AND GO TO INHIBITION LOGIC. OTHERWISE, CONTINUE.
064289,000043:                                                                                                  #  IF JETS ARE FIRING POSITIVELY AND RATE IS   LESS  THAN TARGET RATE, LEAVE
064290,000044:                                                                                                  #  JETS ON AND GO TO INHIBITION LOGIC. OTHERWISE, CONTINUE.
064291,000045: 
064292,000046:                                                                                                  #  3. OUTER RATE LIMIT TEST (SPSSTART)
064293,000047: 
064294,000048:                                                                                                  #  IF MAGNITUDE OF EDOT IS GREATER THAN 1.73 DEG/SEC SET JET FIRING TIME
064295,000049:                                                                                                  #   TO REDUCE RATE AND GO TO INHIBITION LOGIC. OTHERWISE, CONTINUE.
064296,000050: 
064297,000051:                                                                                                  #  4. COAST ZONE TEST
064298,000052: 
064299,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-
064300,000054:                                                                                                  #  TIVE AND CONTINUE. OTHERWISE,SET JET FIRING TIME TO ZERO AND CONTINUE.
064301,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
064302,000056:                                                                                                  #  AND CONTINUE. OTHERWISE,SET JET FIRING TIME TO ZERO AND CONTINUE.
064303,000057: 
064304,000058:                                                                                                  #  5. INHIBITION LOGIC
064305,000059: 
064306,000060:                                                                                                  #  IF OLDSENSE IS NON-ZERO:
064307,000061: 
064308,000062:                                                                                                  #        A) RETURN IF JET TIME HAS SAME SIGN AS OLDSENSE
064309,000063:                                                                                                  #        B) SET INHIBITION COUNTER*AND RETURN IF JET TIME IS ZERO
064310,000064:                                                                                                  #        C) SET INHIBITION COUNTER,*SET JET TIME TO ZERO AND RETURN IF SIGN
064311,000065:                                                                                                  #           OF JET TIME IS OPPOSITE TO THAT OF OLDSENSE
064312,000066: 
064313,000067:                                                                                                  #  IF OLDSENSE IS ZERO:
064314,000068:                                                                                                  #        A) RETURN IF INHIBITION COUNTER IS NOT POSITIVE
064315,000069:                                                                                                  #        B) SET JET TIME TO ZERO AND RETURN IF INHIBITION COUNTER IS POSITIVE
064316,000070:                                                                                                  #  *NOTE: INHIBITION COUNTERS CAN BE SET TO 4 OR 10 FOR THE P, AND UV AXES,
064317,000071:                                                                                                  #  RESPECTIVELY, IN SPSRCS. THEY ARE DECREMENTED BY ONE AT THE BEGINNING OF

Page 1498

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

Page 1499

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

Page 1500

064418,000172: 21,3746           61752                           AD       E                                     
064419,000173: 21,3747           00006                           EXTEND                                         
064420,000174: 21,3750           71411                           MP       DKDB                                  #  PAD LOADED DEADBAND. FRESHSTART: 1.4 DEG
064421,000175: 21,3751           00006                           EXTEND                                         
064422,000176: 21,3752           13767                           BZF      TJZERO                                
064423,000177: 
064424,000178: 21,3753           00006                           EXTEND                                         
064425,000179: 21,3754           63763                           BZMF     +7                                    
064426,000180: 21,3755           31427                           CA       EDOT                                  
064427,000181: 21,3756           63647                           AD       RATELIM2                              
064428,000182: 21,3757           00006                           EXTEND                                         
064429,000183: 21,3760           63767                           BZMF     TJZERO                                
064430,000184: 21,3761           44736        NEGTHRST           CS       HALF                                  
064431,000185: 21,3762           13651                           TCF      POSTHRST   +1                         
064432,000186: 21,3763           43647                 +7        CS       RATELIM2                              
064433,000187: 21,3764           61427                           AD       EDOT                                  
064434,000188: 21,3765           00006                           EXTEND                                         
064435,000189: 21,3766           63650                           BZMF     POSTHRST                              
064436,000190: 21,3767           34755        TJZERO             CA       ZERO                                  
064437,000191: 21,3770           13651                           TCF      POSTHRST   +1                         
064438,000192: 
064439,000193: 21,3771     4766               RATELIM1           =        CALLCODE                              #  = 00032, CORRESPONDING TO 1.73 DEG/SEC
064440,000194: 21,3771     4767               RATEDB1            =        TBUILDFX                              #   = 00045, CORRESPONDS TO 0.101 DEG/SEC
064441,000195: 

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