Source Code

These source-code files derive from a printout of Luminary 210 (Apollo 15-17 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Jim Lawton, 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 210 OF AGC PROGRAM LUMINARY 
	BY NASA 2021112-161 17:11 MAR. 19,1971
Note that the date is the date of the printout, not the date of the program revision.

065540,000002:                                                                                                  ## Copyright:   Public domain.
065541,000003:                                                                                                  ## Filename:    SPS_BACK-UP_RCS_CONTROL.agc
065542,000004:                                                                                                  ## Purpose:     A section of Luminary revision 210.
065543,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
065544,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 15-17.
065545,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
065546,000008:                                                                                                  ##              that the code format has been changed to conform to the
065547,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
065548,000010:                                                                                                  ##              original YUL assembler.
065549,000011:                                                                                                  ## Reference:   pp. 1505-1508
065550,000012:                                                                                                  ## Assembler:   yaYUL
065551,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
065552,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
065553,000015:                                                                                                  ## Mod history: 2016-11-17 JL   Created from Luminary131 version.
065554,000016:                                                                                                  ##              2016-12-12 MAS  Transcribed.
065555,000017:                                                                                                  ##              2016-12-26 RSB  Comment-text proofed using ProoferComments
065556,000018:                                                                                                  ##                              and corrected errors found.
065557,000019: 

Page 1505

065559,000021:                                                                                                  #  PROGRAM NAME:  SPSRCS
065560,000022: 
065561,000023:                                                                                                  #  AUTHOR:  EDGAR M. OSHIKA (AC ELECTRONICS)
065562,000024: 
065563,000025:                                                                                                  #  MODIFIED:  TO RETURN TO ALL AXES VIA Q BY P.S.WEISSMAN, OCT 7, 1968
065564,000026: 
065565,000027:                                                                                                  #  MODIFIED TO IMPROVE BENDING STABILITY BY G.KALAN,FEB.14,1969
065566,000028:                                                                                                  #  FUNCTIONAL DESCRIPTION:
065567,000029: 
065568,000030:                                                                                                  #  THIS PROGRAM CONTROLS THE FIRING OF ALL RCS JETS IN THE DOCKED CONFIGURATION ACCORDING TO THE FOLLOWING PHASE
065569,000031:                                                                                                  #  PLANE LOGIC.
065570,000032: 
065571,000033:                                                                                                  #  1. JET SENSE TEST (SPSRCS)
065572,000034: 
065573,000035:                                                                                                  #  IF JETS ARE FIRING NEGATIVELY,SET OLDSENSE NEGATIVE AND CONTINUE
065574,000036:                                                                                                  #  IF JETS ARE FIRING POSITIVELY,SET OLDSENSE POSITIVE AND CONTINUE
065575,000037:                                                                                                  #  IF JETS ARE NOT FIRING,SET OLDSENSE TO ZERO AND GO TO OUTER RATE LIMIT  TEST
065576,000038: 
065577,000039:                                                                                                  #  2. RATE DEAD BAND TEST
065578,000040: 
065579,000041:                                                                                                  #  IF JETS ARE FIRING NEGATIVELY AND RATE IS GREATER THAN TARGET RATE,LEAVE
065580,000042:                                                                                                  #  JETS ON AND GO TO INHIBITION LOGIC. OTHERWISE,CONTINUE.
065581,000043:                                                                                                  #  IF JETS ARE FIRING POSITIVELY AND RATE IS   LESS  THAN TARGET RATE,LEAVE
065582,000044:                                                                                                  #  JETS ON AND GO TO INHIBITION LOGIC. OTHERWISE,CONTINUE.
065583,000045: 
065584,000046:                                                                                                  #  3. OUTER RATE LIMIT TEST (SPSSTART)
065585,000047: 
065586,000048:                                                                                                  #  IF MAGNITUDE OF EDOT IS GREATER THAN 1.73 DEG/SEC SET JET FIRING TIME
065587,000049:                                                                                                  #   TO REDUCE RATE AND GO TO INHIBITION LOGIC. OTHERWISE,CONTINUE.
065588,000050: 
065589,000051:                                                                                                  #  4. COAST ZONE TEST
065590,000052: 
065591,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-
065592,000054:                                                                                                  #  TIVE AND CONTINUE. OTHERWISE,SET JET FIRING TIME TO ZERO AND CONTINUE.
065593,000055:                                                                                                  #  IF STATE IS ABOVE LINE  E + 4X EDOT > +1.4 DEG AND EDOT IS GREATER THAN -1.30 DEG/SEC, SET JET TIME NEGATIVE
065594,000056:                                                                                                  #  AND CONTINUE. OTHERWISE,SET JET FIRING TIME TO ZERO AND CONTINUE.
065595,000057: 
065596,000058:                                                                                                  #  5. INHIBITION LOGIC
065597,000059: 
065598,000060:                                                                                                  #  IF OLDSENSE IS NON-ZERO:
065599,000061:                                                                                                  #        A) RETURN IF JET TIME HAS SAME SIGN AS OLDSENSE
065600,000062:                                                                                                  #        B) SET INHIBITION COUNTER*AND RETURN IF JET TIME IS ZERO
065601,000063:                                                                                                  #        C) SET INHIBITION COUNTER,*SET JET TIME TO ZERO AND RETURN IF SIGN
065602,000064:                                                                                                  #           OF JET TIME IS OPPOSITE TO THAT OF OLDSENSE
065603,000065: 
065604,000066:                                                                                                  #  IF OLDSENSE IS ZERO:
065605,000067:                                                                                                  #        A) RETURN IF INHIBITION COUNTER IS NOT POSITIVE
065606,000068:                                                                                                  #        B) SET JET TIME TO ZERO AND RETURN IF INHIBITION COUNTER IS POSITIVE
065607,000069:                                                                                                  #  *NOTE: INHIBITION COUNTERS CAN BE SET TO 4 OR 10 FOR THE P,AND UV AXES,
065608,000070:                                                                                                  #  RESPECTIVELY,IN SPSRCS. THEY ARE DECREMENTED BY ONE AT THE BEGINNING OF

Page 1506

065610,000072:                                                                                                  #  EACH DAP PASS.
065611,000073: 
065612,000074:                                                                                                  #  THE MINIMUM PULSE WIDTH OF THIS CONTROLLER IS DETERMINED BY THE REPETITION  RATE AT WHICH THIS ROUTINE IS CALLED
065613,000075:                                                                                                  #  AND IS NOMINALLY 100 MS FOR ALL AXES IN DRIFTING FLIGHT.   DURING POWERED FLIGHT THE MINIMUM IS 100 MS FOR THE
065614,000076:                                                                                                  #  P AXIS AND 200 MS FOR THE CONTROL OF THE U AND V AXES.
065615,000077: 
065616,000078:                                                                                                  #  CALLING SEQUENCE:
065617,000079: 
065618,000080:                                                                                                  #           INHINT
065619,000081:                                                                                                  #                      TC     IBNKCALL
065620,000082:                                                                                                  #                      CADR   SPSRCS
065621,000083: 
065622,000084: 
065623,000085:                                                                                                  #  EXIT:
065624,000086:                                                                                                  #           TC     Q
065625,000087:                                                                                                  #  ALARM/ABORT MODE:    NONE
065626,000088: 
065627,000089:                                                                                                  #  SUBROUTINES CALLED:    NONE
065628,000090: 
065629,000091:                                                                                                  #  INPUT:      E,EDOT
065630,000092:                                                                                                  #              TJP, TJV, TJU                   TJ MUST NOT BE NEGATIVE ZERO
065631,000093: 
065632,000094:                                                                                                  #  OUTPUT:     TJP, TJV, TJU
065633,000095: 
065634,000096: 
065635,000097: 21,3606                                           BANK     21                                    
065636,000098: 21,2000                                           SETLOC   DAPS4                                 
065637,000099: 21,2000                                           BANK                                           
065638,000100: 
065639,000101: 21,3606                                           COUNT*   $$/DAPBU                              
065640,000102: 
065641,000103: 21,3606  E6,1525                                  EBANK=   TJU                                   
065642,000104: 21,3606           00632        RATELIM2           OCT      00632                                 #  1.125 DEG/SEC
065643,000105: 21,3607           34727        POSTHRST           CA       HALF                                  
065644,000106: 
065645,000107: 21,3610           51505                           NDX      AXISCTR                               
065646,000108: 21,3611           55525                           TS       TJU                                   
065647,000109: 21,3612           11744                           CCS      OLDSENSE                              
065648,000110: 21,3613           13633                           TCF      POSCHECK                              #  JETS FIRING POSITIVELY
065649,000111: 21,3614           13636                           TCF      CTRCHECK                              #  JETS OFF. CHECK INHIBITION CTR
065650,000112: 21,3615           51505        NEGCHECK           INDEX    AXISCTR                               #  JETS FIRING NEGATIVELY
065651,000113: 21,3616           41525                           CS       TJU                                   
065652,000114: 21,3617           10000                           CCS      A                                     
065653,000115: 21,3620           00002                           TC       Q                                     #  RETURN
065654,000116: 21,3621           13623                           TCF      +2                                    
065655,000117: 21,3622           13623                           TCF      +1                                    #  JETS COMMANDED OFF.SET CTR AND RETURN
065656,000118: 21,3623           51505        SETCTR             INDEX    AXISCTR                               #  JET FIRING REVERSAL COMMANDED. SET CTR,
065657,000119: 21,3624           33645                           CA       UTIME                                 #  SET JET TIME TO ZERO,AND RETURN

Page 1507

065659,000121: 21,3625           51505                           INDEX    AXISCTR                               
065660,000122: 21,3626           55767                           TS       UJETCTR                               
065661,000123: 21,3627           34746        ZAPTJ              CA       ZERO                                  
065662,000124: 21,3630           51505                           INDEX    AXISCTR                               
065663,000125: 21,3631           55525                           TS       TJU                                   
065664,000126: 21,3632           00002                           TC       Q                                     
065665,000127: 21,3633           51505        POSCHECK           INDEX    AXISCTR                               
065666,000128: 21,3634           31525                           CA       TJU                                   
065667,000129: 21,3635           13617                           TCF      NEGCHECK   +2                         
065668,000130: 21,3636           51505        CTRCHECK           INDEX    AXISCTR                               #  CHECK JET INHIBITION COUNTER
065669,000131: 21,3637           11767                           CCS      UJETCTR                               
065670,000132: 21,3640           13642                           TCF      +2                                    
065671,000133: 21,3641           00002                           TC       Q                                     #  CTR IS NOT POSITIVE. RETURN
065672,000134: 21,3642           13627                           TCF      ZAPTJ                                 #  CTR IS POSITIVE.INHIBIT FIRINGS
065673,000135: 21,3643           00002                           TC       Q                                     #  CTR IS NOT POSITIVE.RETURN
065674,000136: 21,3644           00004                           OCT      00004                                 
065675,000137: 21,3645           00012        UTIME              OCT      00012                                 
065676,000138: 21,3646           00012                           OCT      00012                                 
065677,000139: 21,3647           44744        NEGFIRE            CS       ONE                                   #  JETS FIRING NEGATIVELY
065678,000140: 21,3650           55744                           TS       OLDSENSE                              
065679,000141: 21,3651           31427                           CA       EDOT                                  
065680,000142: 21,3652           13656                           TCF      +4                                    
065681,000143: 21,3653           34744        PLUSFIRE           CA       ONE                                   
065682,000144: 21,3654           55744                           TS       OLDSENSE                              
065683,000145: 21,3655           41427                           CS       EDOT                                  #  RATE DEAD BAND TEST
065684,000146: 21,3656           22000                           LXCH     A                                     
065685,000147: 21,3657           40111                           CS       DAPBOOLS                              #  IF DRIFTBIT = 1, USE ZERO TARGET RATE

A line is drawn immediately to the right of DRIFTBIT below.

065687,000149: 21,3660           74735                           MASK     DRIFTBIT                              #  IF DRIFTBIT = 0, USE 0.10 RATE TARGET
065688,000150: 21,3661           10000                           CCS      A                                     
065689,000151: 21,3662           34760                           CA       RATEDB1                               
065690,000152: 21,3663           60001                           AD       L                                     
065691,000153: 21,3664           00006                           EXTEND                                         
065692,000154: 21,3665           63675                           BZMF     SPSSTART                              
065693,000155: 21,3666           13612                           TCF      POSTHRST   +3                         
065694,000156: 
065695,000157: 21,3667           51505        SPSRCS             INDEX    AXISCTR                               #  JET SENSE TEST
065696,000158: 21,3670           11525                           CCS      TJU                                   
065697,000159: 21,3671           13653                           TCF      PLUSFIRE                              #  JETS FIRING POSITIVELY
065698,000160: 21,3672           13674                           TCF      +2                                    
065699,000161: 21,3673           13647                           TCF      NEGFIRE                               #  JETS FIRING NEGATIVELY
065700,000162: 21,3674           55744                           TS       OLDSENSE                              #  JETS OFF
065701,000163: 21,3675           31427        SPSSTART           CA       EDOT                                  #  OUTER RATE LIMIT TEST
065702,000164: 21,3676           00006                           EXTEND                                         
065703,000165: 21,3677           74757                           MP       RATELIM1                              
065704,000166: 21,3700           10000                           CCS      A                                     
065705,000167: 21,3701           13720                           TCF      NEGTHRST                              #  OUTER RATE LIMIT EXCEEDED
065706,000168: 21,3702           13704                           TCF      +2                                    
065707,000169: 21,3703           13607                           TCF      POSTHRST                              #  OUTER RATE LIMIT EXCEEDED
065708,000170: 21,3704           31427                           CA       EDOT                                  #  COAST ZONE TEST
065709,000171: 21,3705           61751                           AD       E                                     

Page 1508

065711,000173: 21,3706           00006                           EXTEND                                         
065712,000174: 21,3707           71411                           MP       DKDB                                  #  PAD LOADED DEADBAND. FRESHSTART: 1.4 DEG
065713,000175: 21,3710           00006                           EXTEND                                         
065714,000176: 21,3711           13726                           BZF      TJZERO                                
065715,000177: 
065716,000178: 21,3712           00006                           EXTEND                                         
065717,000179: 21,3713           63722                           BZMF     +7                                    
065718,000180: 21,3714           31427                           CA       EDOT                                  
065719,000181: 21,3715           63606                           AD       RATELIM2                              
065720,000182: 21,3716           00006                           EXTEND                                         
065721,000183: 21,3717           63726                           BZMF     TJZERO                                
065722,000184: 21,3720           44727        NEGTHRST           CS       HALF                                  
065723,000185: 21,3721           13610                           TCF      POSTHRST   +1                         
065724,000186: 21,3722           43606                 +7        CS       RATELIM2                              
065725,000187: 21,3723           61427                           AD       EDOT                                  
065726,000188: 21,3724           00006                           EXTEND                                         
065727,000189: 21,3725           63607                           BZMF     POSTHRST                              
065728,000190: 21,3726           34746        TJZERO             CA       ZERO                                  
065729,000191: 21,3727           13610                           TCF      POSTHRST   +1                         
065730,000192: 
065731,000193: 
065732,000194: 21,3730     4757               RATELIM1           =        CALLCODE                              #  = 00032, CORRESPONDING TO 1.73 DEG/SEC
065733,000195: 21,3730     4760               RATEDB1            =        TBUILDFX                              #   = 00045, CORRESPONDS TO 0.101 DEG/SEC

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