Module 10 · Lesson 2
Hardware and Software in the Loop
Test setups range from pure simulation to flight-like hardware on a bench. This lesson explains what each can and cannot find, and why tests should use the same procedures and ground system as flight.
Learning objectives
After this lesson you will be able to:
- Distinguish software-in-the-loop, processor-in-the-loop and hardware-in-the-loop testing, and describe a flatsat
- Identify which classes of defect each test configuration can and cannot reveal
- Explain why a hardware-in-the-loop simulator must run in real time and how test as you fly applies to software
A ladder of test configurations
Mainstream software moves through unit tests, integration tests, staging and production. Space software has a comparable progression in which each step replaces one more simulated element with the real thing.
| Configuration | What is real | Typically finds | Cannot find |
|---|---|---|---|
| Pure simulation | Nothing; algorithms may be prototypes | Design and algorithm errors | Anything about the flight code |
| Software-in-the-loop | Flight source code, compiled for a workstation | Logic, sequencing and fault-response errors | Problems tied to the flight processor or compiler |
| Processor-in-the-loop | The flight build, on the flight processor type or an emulator | Architecture differences, memory and timing margins | Errors in real electrical interfaces |
| Hardware-in-the-loop | The flight computer or an engineering model, with real interfaces | Driver errors, interface timing | Behavior of units that are still simulated |
| Flatsat | Flight-like units of most subsystems, cabled on a bench | Unit incompatibilities, end-to-end procedures | Effects of flight structure, temperature and vacuum |
The names vary between organizations, and the boundaries blur. An engineering model is a unit built to the flight design but not intended to fly, and a flatsat is a set of such units cabled together on a bench.
What each rung is for
Software-in-the-loop tests run on ordinary build servers. They can run in parallel and faster than real time, because the simulation controls the clock, so thousands of cases can run overnight. The frameworks from Module 09, NASA's core Flight System and JPL's F Prime, can both be built for desktop Linux as well as for flight targets. NASA's open-source NOS3 combines flight software built on the core Flight System with simulated hardware components and a ground system.
The limitation is that the workstation is not the flight computer. The compiler and processor are different, and several widely used space processors store multi-byte values in the opposite byte order to a desktop machine.
Processor-in-the-loop closes that gap by running the flight build on the flight processor type, or on an emulator that executes the same instruction set. It answers questions about processor load and memory use.
Hardware-in-the-loop adds real electrical interfaces. A simulator on the other end of the cables reads the flight computer's outputs and produces its inputs. This is where device drivers meet real signal timing.
A flatsat adds the real units. A program may have only one or two, shared between software developers, operations teams and anomaly investigators and booked by the hour. The comparison is a single staging environment for a whole company that cannot be cloned.
The working rule follows from the difference in cost. Run each test on the lowest rung that is able to find the defect it is looking for.
The simulator has to keep time
In software-in-the-loop testing the simulation owns the clock, as the previous lesson described. That stops being true when real hardware joins the loop. The flight computer runs on its own oscillator and will not wait.
The simulator then becomes a real-time system. In every cycle it must read the actuator commands, advance its models and present fresh sensor values before the flight software asks for them. If a sensor value arrives one cycle late, the controller acts on stale data, and the test may show an instability that the real spacecraft does not have, or hide one that it does.
Hardware-in-the-loop simulators therefore run on real-time operating systems or dedicated hardware and monitor their own timing, so that a missed frame is recorded as a test fault. Their models are often simplified to fit the time budget, the opposite pressure from the previous lesson.
Automation and regression campaigns
Tests at every rung are scripts that set initial conditions, send commands, inject faults at defined times and check telemetry against expected values. Software-in-the-loop suites run on every change, which is continuous integration in the familiar sense.
A regression campaign is a planned rerun of a defined test set against a software baseline, producing evidence for a formal review. The parallel with a release pipeline holds, with three differences:
- On the upper rungs a test takes real time. A scenario covering one low Earth orbit takes about an hour and a half.
- A formal run records its full configuration, including the software build, database version, simulator version and hardware serial numbers.
- Real hardware introduces small timing variations, so checks use tolerances and time windows, not exact values.
An intermittent failure on a hardware test bed may be a real timing defect. It is investigated, not retried until it passes.
Test as you fly, for software
The foundation course introduced the principle of test as you fly. For software it has specific meanings.
- Test the build that will fly. A debug build with extra instrumentation has different timing and memory use. If the software is rebuilt, it is retested.
- Use flight-like configuration. Load the same parameter tables and the same telemetry and command database.
- Run for realistic durations. Counters that roll over, slow memory leaks and storage that fills appear after days, not minutes.
- Use the operational ground system and procedures. Send commands from the real control system with the real database and procedures, which tests all of them along with the software.
- Record every exception. Each difference between test and flight, such as a simulated sensor, is a place where a defect can hide.
A practical example: a timeout only real hardware revealed
A team integrates a new star tracker. The flight software requests an attitude measurement four times a second and declares the unit unresponsive if no reply arrives within a set timeout.
The driver passes months of software-in-the-loop tests, in which the simulated star tracker, written from the interface document, replies almost instantly. On the flatsat, with an engineering model of the real unit, fault protection intermittently declares the star tracker failed and switches to the redundant unit, which is then also declared failed.
Investigation shows that the real unit sometimes takes longer to reply than the typical figure in the document, and the timeout had been set from that figure. No lower rung could have found this, because the model did not contain the delay.
The team sets the timeout from measured worst-case behavior with margin, gives the simulated star tracker the measured spread of response times, and adds a regression test that exercises slow replies on every software change. The flatsat found the defect once, and the lower rungs now guard against its return, as a production incident becomes a regression test.
The simulator's usefulness does not end at launch. The next lesson follows it into operations, where it is kept in step with one particular spacecraft and is often called a digital twin.
Key takeaways
- Test configurations form a ladder. Each rung replaces one more simulated element with a real one, from the flight source code, to the flight processor, to real interfaces, to flight-like units on a bench.
- Lower rungs are cheap, fast and repeatable, so they carry most of the testing. Higher rungs are scarce and slow, and exist to find what only real hardware can show.
- Once real hardware is in the loop the simulator must meet real-time deadlines on every cycle. A missed frame can invalidate a test.
- Test as you fly applies to software too - test the build that will fly, with flight-like configuration, through the operational ground system and procedures.
Knowledge check
Check your understanding. These questions are not graded and you can retry as often as you like.
0 of 3 questions answered.
Glossary
Software-in-the-loop
Testing in which the flight software source code is compiled for a workstation and run against simulated hardware and a simulated environment.
Processor-in-the-loop
Testing in which the flight software is built with the flight toolchain and run on the flight processor type, or an emulator of it, with simulated interfaces.
Hardware-in-the-loop
Testing in which a real flight computer or an engineering copy is connected through real electrical interfaces to a simulator that behaves as its sensors and actuators.
Flatsat
A test bed in which flight-like units of a spacecraft are laid out on a bench and cabled together, usually with a simulator supplying dynamics and environment.
Engineering model
A unit built to the flight design, or close to it, for development and testing and not for flight.
Regression campaign
A planned rerun of a defined set of tests against a software baseline, producing recorded evidence that existing behavior still holds.
References and further reading
- NOS3 - NASA Operational Simulator for Space Systems (opens in a new tab)NASA (GitHub)
- core Flight System (cFS) (opens in a new tab)NASA (GitHub)
- F Prime flight software framework (opens in a new tab)NASA Jet Propulsion Laboratory
Finished this lesson?
Loading your progress…
Lesson version 1.0.0.