This example shows how one of the engineers who worked on the Apollo Lunar Module digital autopilot design team would have done it using Simulink if it had been available in 1961.
Developing the autopilot in Simulink took only a fraction of the time it took for the original design of the Apollo Lunar Module autopilot. A Stateflow diagram in the model specifies the logic that implements the phase-plane control algorithm described in the article linked below. Depending on which region of the diagram the Lunar Module is executing, the Stateflow diagram will be in either a Fire_region or a Coast_region. Note the transitions between these different regions depend on certain parameters. The Stateflow diagram determines whether or not to transition to another state and then computes which reaction jets to fire.
Figure 1: Simulink-based design of the lunar module digital autopilot
Building a digital autopilot was a daunting task in 1961 because there was very little industrial infrastructure for it - everything about it was in the process of being invented. Here is an excerpt from the Summer 1999 News & Notes article:
"One reason why the [autopilot's machine code] was so complex was that the number of jets that could be used to control the rotations about the pilot axes was large. A decision was made to change the axes that the autopilot was controlling to the "jet axes". This made a dramatic change in the number of lines of code and in the ability to program the autopilot in the existing computer. Without this improvement, it would have been impossible to have the autopilot use only 2000 words of storage. The lesson of this change is that when engineers are given the opportunity to code the computer with the system they are designing, they can often modify the design to greatly improve the code. These are changes that programmers would never suggest, since they only code what was written in a code specification. But with MATLAB, Simulink, and Stateflow, the design engineer can also be the one who codes the design (using Simulink Coder™), and the gap between designer and coder is reduced."