Source Code

These source-code files are part of a reconstructed copy of Comanche 051, the original release of the Apollo 11 Command Module (CM) Apollo Guidance Computer (AGC) software.

The reconstruction began with source code of Comanche 055 previously transcribed from a digitized copy of that program. The code was then updated by undoing changes related to the R-2 lunar potential model, using hints from program comments and change-indicating asterisks in the Comanche 055 listing as a guide. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021153D. Note that page numbers in the reconstructed code match those on the Comanche 055 printout, although the added code would likely have changed page numbers for a real Comanche 051 listing.

Comments from the original source code are prefixed with a single '#' symbol, whereas comments added later are prefixed by "##" or "###". Report any errors noted by creating an issue report at the Virtual AGC project's GitHub repository.

017657,000002:                                                                                                  ## Copyright:   Public domain.
017658,000003:                                                                                                  ## Filename:    GIMBAL_LOCK_AVOIDANCE.agc
017659,000004:                                                                                                  ## Purpose:     A section of Comanche revision 051.
017660,000005:                                                                                                  ##              It is part of the reconstructed source code for the
017661,000006:                                                                                                  ##              original release of the flight software for the Command
017662,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 11.
017663,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
017664,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
017665,000010:                                                                                                  ##              exactly match those specified for Comanche 51 in NASA drawing
017666,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
017667,000012:                                                                                                  ##              reconstruction is correct.
017668,000013:                                                                                                  ## Reference:   pp. 412-413
017669,000014:                                                                                                  ## Assembler:   yaYUL
017670,000015:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
017671,000016:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
017672,000017:                                                                                                  ## Mod history: 2019-07-30 MAS  Created from Comanche 55.
017673,000018: 

Page 412

017675,000020: 15,2000                                           BANK     15                                    
017676,000021: 22,2000                                           SETLOC   KALCMON1                              
017677,000022: 22,2000                                           BANK                                           
017678,000023: 
017679,000024: 22,2737  E6,1661                                  EBANK=   BCDU                                  
017680,000025: 
017681,000026:                                                                                                  #  DETECTING GIMBAL LOCK
017682,000027: 22,2737  22,2737               LOCSKIRT           EQUALS   WCALC                                 
017683,000028: 22,2737           70740        WCALC              LXC,1    DLOAD*                                
017684,000029: 22,2740           01130                                    RATEINDX                              
017685,000030: 22,2741           04771                                    ARATE,1                               
017686,000031: 22,2742           45002                           SR4      CALL                                  #  COMPUTE THE INCREMENTAL ROTATION MATRIX
017687,000032: 22,2743           44530                                    DELCOMP                               #  DEL CORRESPONDING TO A 1 SEC ROTATION
017688,000033:                                                                                                  #  ABOUT COF
017689,000034: 22,2744           74343                           DLOAD*   VXSC                                  
017690,000035: 22,2745           04771                                    ARATE,1                               
017691,000036: 22,2746           03343                                    COF                                   
017692,000037: 22,2747           77721                           MXV                                            
017693,000038: 22,2750           05003                                    QUADROT                               
017694,000039: 22,2751           17311                           STODL    BRATE                                 
017695,000040: 22,2752           03365                                    AM                                    
017696,000041: 22,2753           55605                           DMP      DDV*                                  
017697,000042: 22,2754           05001                                    ANGLTIME                              
017698,000043: 22,2755           04771                                    ARATE,1                               
017699,000044: 22,2756           77661                           SR                                             
017700,000045: 22,2757           20606                                    5                                     
017701,000046: 22,2760           27317                           STOVL    TM                                    
017702,000047: 22,2761           03311                                    BRATE                                 
017703,000048: 22,2762           77761                           VXSC                                           
017704,000049: 22,2763           05025                                    BIASCALE                              
017705,000050: 22,2764           03275                           STORE    BIASTEMP                              #  ATTITUDE ERROR BIAS TO PREVENT OVERSHOOT
017706,000051:                                                                                                  #  IN SYSTEM
017707,000052: 22,2765           77614                           SETGO                                          #  STATE SWITCH CALCMAN2 (43D)
017708,000053: 22,2766           01035                                    CALCMAN2                              #  0(OFF) = BYPASS STARTING PROCEDURE
017709,000054: 22,2767           45032                                    NEWANGL    +1                         #  1(ON) = START MANEUVER
017710,000055: 
017711,000056: 
017712,000057: 22,2770           00044 15053  ARATE              2DEC     .0022222222                            #  = .05 DEG/SEC
017713,000058: 
017714,000059: 22,2772           00221 24255                     2DEC     .0088888889                            #  = .2 DEG/SEC
017715,000060: 
017716,000061: 22,2774           00554 02660                     2DEC     .0222222222                            #  = .5 DEG/SEC
017717,000062: 
017718,000063: 22,2776           02660 13301                     2DEC     .0888888889                            #  = 2 DEG/SEC                $22.5 DEG/SEC
017719,000064: 
017720,000065: 22,3000           00003 04000  ANGLTIME           2DEC     .000190735                            #  = 100B - 19
017721,000066: 
017722,000067:                                                                                                  #  MANEUVER ANGLE TO MANEUVER TIME
017723,000068: 22,3002           03146 14632  QUADROT            2DEC     .1                                    #  ROTATION MATRIX FROM S/C AXES TO CONTROL
017724,000069: 

Page 413

017726,000071: 22,3004           00000 00000                     2DEC     0          B-28                       #  AXES (X ROT = -7.25 DEG)
017727,000072: 
017728,000073: 22,3006           00000 00000                     2DEC     0          B-28                       
017729,000074: 
017730,000075: 22,3010           00000 00000                     2DEC     0          B-28                       
017731,000076: 
017732,000077: 22,3012           03131 11275                     2DEC     .099200                               #  =(.1)COS7.25
017733,000078: 
017734,000079: 22,3014           77461 47370                     2DEC     -.012620                              #  =-(.1)SIN7.25
017735,000080: 
017736,000081: 22,3016           00000 00000                     2DEC     0          B-28                       
017737,000082: 
017738,000083: 22,3020           00316 30407                     2DEC     .012620                               #  (.1)SIN7.25
017739,000084: 
017740,000085: 22,3022           03131 11275                     2DEC     .099200                               #  (.1)COS7.25
017741,000086: 
017742,000087: 22,3024           00004 05253  BIASCALE           2DEC     .0002543132                            #  = (450/180)(1/0.6)(1/16384)

End of include-file GIMBAL_LOCK_AVOIDANCE.agc.  Parent file is MAIN.agc