Hardware-In-Loop Testing

Hardware-In-Loop testing infrastructure. Work Project

Project Overview

This project involved the design and implementation of a Hardware-in-the-Loop (HIL) testing framework for a marine gyroscopic stabilizer under active development at Dometic Marine. The goal was to create a repeatable, reliable way to validate safety-critical firmware directly on a fully assembled gyro unit, keeping pace with rapid software changes while reducing regressions and manual testing overhead.

The system enables deterministic fault injection, state-machine verification, and system-level validation by manipulating sensor inputs and CAN traffic while observing real firmware behavior on production hardware.

System Architecture

  1. Hardware-in-the-Loop Test Environment:
    Firmware is executed on a fully assembled gyroscopic stabilizer rather than a simulated or bench-level setup. This ensures that firmware interacts with real sensors, ECUs, and hardware timing characteristics while still allowing controlled test conditions.
  2. CAN-Based Test Control:
    A CAN-to-USB interface is used to inject sensor values, override internal variables, and force state transitions. This allows precise control of system inputs without modifying firmware or physically manipulating hardware.
  3. Automated Test Execution:
    Tests are written in Python and executed using Pytest. Each test applies deterministic CAN messages, monitors system responses, and verifies expected diagnostic flags, state transitions, and timing behavior.
  4. Initialization & Reset Logic:
    A robust initialization routine ensures every test starts from a known state. This includes ECU resets, clearing diagnostic flags, restoring configuration defaults, and running an automated calibration routine when required.

Key Technical Contributions

  1. Deterministic Fault Injection:
    Sensor values and internal parameters can be forced across diagnostic thresholds to reliably trigger faults such as low battery voltage, sensor invalid states, and safety interlocks. This enables repeatable validation of fault handling logic.
  2. State-Machine Verification:
    Tests confirm correct progression through operational, locked, calibration, and fault states, including timing consistency and recovery behavior once fault conditions are cleared.
  3. Test Isolation & Repeatability:
    Tests are designed to be fully independent. Any interrupted or failed run can be restarted without manual cleanup, preventing false failures caused by residual system state.

Results

The HIL framework consistently detected deviations in firmware behavior across revisions, including timing changes, altered diagnostic thresholds, and unexpected state transitions. Tests proved reliable across repeated runs and multiple firmware branches, providing a dependable baseline for regression testing.

Compared to the previous manual workflow, firmware validation became faster, more consistent, and significantly less error-prone. Issues that previously surfaced late in development were caught immediately during HIL testing.

Impact

This framework closed the gap between rapid firmware development and insufficient manual testing. It reduced regression risk, improved developer confidence in new changes, and established a scalable foundation for future automation. The system is well-suited for integration into a CI pipeline where firmware changes are automatically validated before merging.

Conclusion

This project delivered a practical, production-relevant HIL testing system for a safety-critical marine product. By enabling repeatable system-level validation on real hardware, it significantly improved firmware reliability and development velocity. The framework mirrors industry best practices used in automotive and robotics environments and provides a strong base for future automated and continuous-integration testing.