next up previous contents
Next: Output Up: The Simulator Program Previous: The Simulator Program

Main Loop

The main loop of the program repeatedly executes tasks in the proper sequence to simulate the airplane. Each iteration of the loop is called a frame, and a frame occupies a fixed length of time. Figure 1 presents the main loop.

Figure 1: Flowchart of the simulator's main loop.

Before the main loop begins, the simulator sets the state variables of the airplane based on the initial conditions. The flight simulator may have to convert the initial conditions to its internal format; for example, converting Euler angles to quarternions using Equations 26-29, or converting geodetic to geocentric coordinates using the equations from Reference 1.

The frame begins with the flight simulator performing output based on the current aircraft state. (The loop is timed so that the output step finishes at the exact time represented by the state variables.) Following output, the simulator inputs the control positions and settings, and sets the control variables accordingly.

Following the input, the simulator calculates the state of the airplane for the beginning of the next frame. This is done using a finite-difference numerical integration of the state variables. The time step in the numerical integration must be small enough to capture the shortest time scales in airplane motion. The short period mode and roll mode have very short half-damping times for many aircraft. For example, Reference 7 reports a roll mode half-damping time of 0.13 seconds for a Piper Cherokee 180. Thus, the time step should be somewhat smaller than 0.1 seconds.

However, output, which is usually by far the most time consuming task of the flight simulator, often requires more time than is available in a single time step. To accommodate the output, one frame can have multiple time steps. For example, if the time step size is 0.01 seconds, and the simulator takes about 0.03 seconds to perform all output for a single frame, then the frame length would be 0.04 seconds, with 4 time steps per frame. (Output dominates processing time so much that the time required by other tasks is often considered negligible.)

The actual time to output a frame can vary. The plain landscape of Nebraska has much fewer polygons than the mountainous landscape of Colorado, and thus requires much less processing time. As an airplane flies from Colorado to Nebraska, the simulator might be able to decrease the number of time steps per frame, and thus get a better frame rate. Conversely, when flying from Nebraska to Colorado, the simulator might have to increase the time steps per frame. Therefore, the simulator periodically adjusts the number of steps per frame to optimize the frame rate.

After all tasks in the frame have been completed, the simulator pauses. The purpose of the pause is to maintain a fixed frame length. For example, if the processing time for a frame is 0.03 seconds, and the frame length is 0.04 seconds, then the simulator pauses for 0.01 seconds. The pause varies in duration to accommodate any fluctuations in the processing time.

Following the pause, the simulator loops back to the output step.

The rest of the section describes the output and calculation tasks in more detail.

next up previous contents
Next: Output Up: The Simulator Program Previous: The Simulator Program
Carl Banks