MIL, SIL and HIL testing
Widen the scope of verification in the order model, software, real hardware. How most problems are found before the real vehicle.
| Stage | Under test | Plant | Problems found |
|---|---|---|---|
| MIL (Model) | Simulink control model | Model | Control algorithm, logic |
| SIL (Software) | Generated or hand-written C code (on a PC) | Model | Code generation, fixed point, implementation differences |
| PIL (Processor) | Running on the real MCU | Model (PC) | Compiler, execution time |
| HIL (Hardware) | The finished real ECU | Real-time simulator | I/O, communication, diagnostics, fault reactions |
MIL → SIL back-to-back test
Feed the same inputs to the model and the code and compare the outputs. If the difference exceeds the allowed range, check the code-generation settings and the numeric representation.
HIL
A real-time simulator (dSPACE, NI, Vector) imitates the vehicle, motor and sensors with mathematical models and is connected to the real ECU's I/O pins and CAN. Situations that are dangerous or hard to reproduce on a real vehicle (a broken sensor wire, overvoltage, extreme temperature signals) can be tested again and again.
In a personal project
- MIL: simulate the PID and plant in Python/Simulink
- SIL: unit-test the control code on a PC
- Simple HIL: a second MCU imitates the motor and sensor signals and tests your board
The cost grows with each stage to the right, so the aim is to find as much as possible on the left.