5.5.22 · D1Embedded Systems & Real-Time Software

Foundations — Software-in-the-Loop (SIL) simulation — all software, simulated hardware

2,132 words10 min readBack to topic

This page assumes nothing. Every word, arrow, and symbol the parent note leaned on is built here from the ground up, in an order where each idea rests on the one before it.


0. The picture the whole topic hangs on

Before any symbol, look at the loop itself. Everything else is just a label on one of these boxes or arrows.

Why the topic needs this: the word "loop" appears in the name SIL. If you don't see the circle, none of the timing, feedback, or "the software doesn't know it's fake" ideas make sense.


1. Signal — the thing that flows on the arrows

Picture: a wire carrying a value. In the real car this wire is a real cable; in SIL it is a variable passed between two functions. Same meaning, different medium.

Why needed: the parent note talks about "sensor data", "control outputs", "CAN bus messages", "ADC readings". Every one of those is a signal — a number travelling along an arrow in the loop picture.


2. Sensor and Actuator — the two ends

Picture: sensor = an eye (world → number), actuator = a hand (number → world). The code sits between the eye and the hand.

Why needed: SIL's whole trick is to replace the eye and the hand with equations. To understand what is being replaced, you must first know what they do.


3. Plant — the machine being controlled

Picture: think of a factory ("plant") that takes an input command and slowly produces an output behaviour.

Why needed: the parent's central component is the "plant model". You cannot model a plant if you don't know a plant is the physical system, separate from the code.


4. Model — a maths stand-in for reality

Look at the two curves: the real machine (orange dots) and the model (blue line) don't match perfectly — and that's fine. A model only has to be close enough to reveal a bad decision by the software.

Why needed: SIL replaces hardware with a model. "Fidelity", "low/medium/high fidelity", "model error" — all of these are statements about how closely the blue line hugs the orange dots.


5. State — the memory of the plant

Picture: a snapshot. Freeze the world; the numbers written on that frozen frame are the state.

Why needed: the parent writes velocity_next = velocity - .... That is: new state computed from old state. The loop is really "state → software → command → new state → repeat".


6. Discrete time vs continuous time

This is the deepest symbol the parent uses, so we build it slowly with a picture.

  • The real plant lives in continuous time.
  • Your controller is a computer program; it can only run at ticks. So it lives in discrete time.

The symbols the parent throws at you, decoded:

Why needed: the whole "cosimulation / solver / stability" section is about how to make the smooth plant fit onto the discrete ticks of the code. Miss this and the parent's Euler formula is gibberish.


7. Turning smooth physics into steps — the Euler idea

Look back at figure s03: the straight blue jumps are Euler steps. When is too big, the jumps overshoot the orange curve badly — that is the "numerical instability / divergence" the parent warns about.


8. Feedback and closed-loop

Picture: this is the circle of arrows from figure s01. Break any arrow and the loop is open.

Why needed: SIL is a closed-loop test — the whole value is that the software's outputs come back to it as new inputs, exactly like reality.


9. HAL — the swappable adaptor

Picture: a wall socket. Your appliance (core logic) plugs into a standard socket. Behind the wall it might be solar, coal, or a battery — the appliance never knows. Swapping what's behind the wall = swapping the HAL.

Why needed: without the HAL split there'd be no way to run the same production code on a PC. The whole technique depends on this one swappable layer.


10. Proportionality — reading and

Picture: folding paper — each fold doubles thickness. The parent's claim "bug-fix cost is \, $10\times, $100\times, $1000\times$ across stages" is exactly this: each later stage multiplies the cost. That's why fixing bugs early (in SIL) is so cheap.


The prerequisite map

Signal = a number over time

Sensor and Actuator

Closed loop feedback

Plant = machine controlled

Model = equation stand-in

State = memory of plant

Discrete vs continuous time

Euler step and delta t

Software Under Test plus HAL

SIL simulation

Exponential cost per stage

Read it top-down: signals let sensors talk; sensors close the loop; plants get modelled; models carry state through time; time forces the Euler step; the HAL lets real code join the loop; cost explains why we bother. All arrows converge on SIL.


Equipment checklist

Cover the right side and answer each; only continue to the deep-dives when all are green.

What is a signal in one phrase?
A number standing for a physical quantity that changes over time.
Sensor vs actuator?
Sensor: world → number (input). Actuator: number → world (output).
What is the plant?
The physical system your software controls (motor, car, room) — not the controller.
What is a model?
An equation that mimics a system's behaviour without being the real thing.
What does state mean?
The minimal numbers needed now to predict the next moment (e.g. speed + position).
Difference between continuous and discrete time?
Continuous updates every instant (smooth curve); discrete only at evenly spaced ticks (dots).
What does mean, and its value at 100 Hz?
The gap between ticks; .
Read and the Euler formula in words.
= one step's time width; new state = old state + slope × step.
Why can't be huge?
The straight Euler jumps overshoot the true curve and the sim diverges.
Open-loop vs closed-loop?
Open: send commands, never check. Closed: read the new state and react each tick.
What does a HAL do?
Hides how I/O happens so the same core logic runs on a PC (SIL) or real chip.
Why does bug-fix cost grow exponentially across stages?
Each later stage multiplies cost via physical irreversibility and coordination — SIL is the cheapest.

See also: the parent topic, and once these foundations feel solid: Hardware-in-the-Loop (HIL), Unit Testing for Embedded Systems, Real-Time Operating Systems (RTOS), Sensor Fusion Algorithms.