Software has become commonplace in our lives. From our smartphones to our cars, software is everywhere. On July 20th, 1969, it was not commonplace. The Apollo 11 software that got us to the moon has a few things about it you probably do not know.
The internet is a treasure trove of information. When is the last time you went on a virtual tour outside of the fence of social media?
I did just that. I wanted to learn a bit more about the computer and software used as the guidance system for the Apollo 11 lunar mission when we sent three United States astronauts, Buzz Aldrin, Neil Armstrong, and Michael Collins, and to land on the moon.
As I began to dig, I learned a very interesting story behind the software NASA used. I have been a fan of space exploration and computing since I was a small boy. However, I did not know about these little information nuggets.
Who is Margaret Hamilton?
Margaret is an Indiana native who completed her mathematics degree with a minor in philosophy from the University of Michigan. What I find interesting is how she found interest in mixing the arts with the sciences. Although she selected these, she may have had guidance from her father who taught philosophy. This was a good choice nonetheless.
As a college professor/advisor, I hope all parents and young people read this and it reminds them that college degrees still afford the opportunity to engage in creative learning. Yes, writing computer code does require creativity.
She would eventually join the team at the “I Lab” which was known officially as the Instrumentation Laboratory at MIT. The lab was awarded a major government contract to work on the Apollo mission. This was due to the work with nuclear missile guidance systems they had done. Later the lab would be renamed the Charles Stark Draper Laboratory.
Margaret’s job assignment was to create the in flight control software. Working with other talented engineers, physicists, and mathematicians they produced nearly 145,000 lines of code for the AGC.
To put that into perspective, the software code that is behind Facebook, is more than 62 million lines of code.
As the team lead for the systems design and development, there was a focus on error detection and recovery. This approach had them create a series of error codes. These error codes would help the astronauts and mission control identify problems.
This approach would become important in avoiding the abort of the lunar landing.
To her credit, Margaret was awarded the Presidential Medal of Freedom in 2016 and is often recognized as one of the pioneers who created systems engineering.
What software was used?
The Apollo Guidance Computer (AGC) was installed on board the Apollo 11 Command Module (CM) and Lunar Module (LM). The computer’s software was written in Assembly Language (or Assembler). Assembler is considered a low-level programming language as there are very few “plain language” type words (eg. instructions) easily recognized by humans.
I explain the different types of programming languages in CODING LANGUAGES – The Secret All Programmers Know.
Assembly code is converted to the “machine language” of the computing device (one’s and zeroes) by an assembler utility program that puts it all together. This type of coding is very tedious but takes advantage of the computer’s processing capabilities quite efficiently as you directly manipulate the memory of the hardware.
I spent time in college learning assembler on a Digital Equipment Corporation (DEC) minicomputer and I can say, I have a fond appreciation for coding at that level but prefer high level programming languages.
However, programming at this level with this type of limited resources (memory and processing power) forces a programmer to be very precise.
The AGC was a machine that at the time, was quite capable of processing the assembly code with a single micro processor. However, by today’s standards, there are some calculators and watches that are more powerful and capable of processing multiple instructions simultaneously.
To the geek, like myself, there is something impressive here.
”It’s a 1202." "What is it?”
That was a transmission from mission commander Neil Armstrong upon reviewing the output of the DSKY (Disply Keyboard – pronounced Dis-Key) as they entered the moon’s orbit preparing to descend to the lunar surface.
The DSKY below had astronauts punch in a “noun-verb” sequence. Eg Display – Velocity
Although these were seasoned military pilots and astronauts, I can only imagine their surprise when a code popped up they did not prepare for in the training simulator. Just as shocked had to be the support team on earth felt. Margaret Hamilton and her team did know the code.
1202 was an alarm code programmed into the system that indicated a memory overload and began to force a restart.
When I teach database programming, I often refer to ‘flags’. When an event occurs, a flag goes off triggering another activity. It is now a common practice when developing software.
In this system, the ‘flags’ would trigger error codes.
In 1969, 30,000 feet above the lunar surface, this request by NASA to have the MIT software programmers code flags into the system was a smart decision. If it were not, it is likely the computer may have malfunctioned or shut down.
The problem had to be worked quickly.
Do you abort or continue the landing?
“Go or no go.”
A fellow computer engineer, Frank Garman, located in Mission Control, also recognized the error. With help from astronaut Buzz Aldrin aboard the Lunar Module, they identified what was causing the overload indicated by the computer.
As the software ran, another line of code was loaded into memory that displayed the Lunar Module’s range and velocity. When the code was executed it caused a memory overload. The solution was to not run the code on the Lunar Module but instead have Mission Control monitor the range and velocity then report it to the astronauts.
“Eagle looking great. You’re Go.” stated Charlie Duke at Mission Control.
Where is the Apollo 11 code today?
In 2016 a former NASA intern Chris Garry, uploaded the code to the sharing site Github.
What is awesome about this code base are comments and naming conventions. Comments are lined of text placed in the code that explain what is occurring at that point. Naming conventions are labels applied to name specific events in your code. The ones in here are priceless!
Often times, when I teach students to code, I have to remind them to comment their code as they feel it is not necessary. It is certainly needed.
Comments ensure a communication exists between programmers. They are like notes. They don’t run when the code is executed as they are ignored by the device processing the code.
One of the main purposes of commenting your code is to remind you or another developer as to what that section of code did. You would be surprised how many times these become important, especially when you are writing a program for months or years.
When code becomes so lengthy, as in the AGC code, these comments are typically made mandatory and checked by other team members.
Example Code Comments
One of the best lines is “BURN_BABY_BURN master ingition routine”.
Another set gives even more insight to the humor of the software programmers at that time:
Building Your Own AGC Simulator
As I searched the internet for various digital goodies related to Apollo 11, I was very pleased to find a website that provides you with the onboard simulators for the Apollo Guidance Computers. These simulators can give you a great experience of what the controls were like.
You can visit the AGC Project Simulator Project page for more information and downloads.
- DOWNLOADS: You can install these on your Windows PC, Linux PC, or Raspberry Pi.
- ONLINE (Browser based): https://svtsim.com/moonjs/agc.html
Thank you Dean Koska for sharing this Palm Centro simulator of the AGC.
As Time Goes By...
Looking back at this I cannot help but to think how far we have come with software. This was an incredibly dedicated and intelligent team that made this happen.
So, indications are that we are heading back to the moon in 2024. I wonder what will be different in terms of software and devices. I cannot wait to see!
Happy 50th Anniversary!!!!
Start Coding Today In 5 Minutes!
Take 5 minutes and try a FREE coding activity!
Let Me Help You
If you are a teacher or someone looking to help others learn to code, let me help you.