5.5.21 · D1Embedded Systems & Real-Time Software

Foundations — Hardware-in-the-Loop (HIL) simulation — real hardware, simulated plant

1,944 words9 min readBack to topic

Before you can read the parent HIL note, you need a small pile of words and symbols. The parent note uses them all as if you already know them. This page builds each one from nothing: plain meaning → the picture → why the topic needs it, ordered so each new idea leans only on the ones above it.


1. The two halves of any control problem

Figure — Hardware-in-the-Loop (HIL) simulation — real hardware, simulated plant

Look at the figure. On the left sits the controller. On the right sits the plant. Between them run two arrows:

  • Down-arrow (commands): the controller tells the plant what to do.
  • Up-arrow (measurements): the plant tells the controller what actually happened.

Because the up-arrow feeds back into the brain, this is a loop. That loop is the beating heart of the whole topic — remember its shape, we will keep redrawing it.


2. What HIL replaces — and what it keeps real

Figure — Hardware-in-the-Loop (HIL) simulation — real hardware, simulated plant

Compare the two panels in the figure:

  • Top panel — reality: real brain wired to a real engine.
  • Bottom panel — HIL: the same real brain, but the engine is now a computer with a box of electronics (the I/O box) in the middle converting numbers into voltages and back.

The dashed magenta box is what HIL invents. Everything inside the violet box (the controller) is untouched — that is the whole point.

Recall Why not just simulate the controller too?

Simulating the controller too gives you SIL or MIL, which are cheaper but miss real-chip bugs (timing, drivers, compiler quirks). HIL keeps the chip real precisely to catch those. ::: Because a simulated chip cannot reveal real-chip bugs.


3. Signals: how brains and bodies actually talk

The two arrows in the loop are not "ideas" — they are electrical signals on physical wires. The parent note names several. Here is each, from zero.

Figure — Hardware-in-the-Loop (HIL) simulation — real hardware, simulated plant

The figure shows both. The smooth orange curve is analog (a temperature reading rising). The square magenta trace is digital (a switch flicking on/off). HIL must be able to fake both kinds, because a real plant produces both.

Figure — Hardware-in-the-Loop (HIL) simulation — real hardware, simulated plant

Look at the three stacked PWM traces. All three switch between the same two heights, but the wider the "on" bars, the bigger the fraction , and the higher the dashed average line. This is the number the parent note multiplies by battery voltage to get the applied voltage.


4. The symbols in the motor equations

The parent's derivation uses physics symbols. Each earns its place here.


5. Real-time — the word that makes HIL hard


6. How it all feeds the topic

Controller and Plant loop

The HIL swap: fake the plant

Voltage, analog vs digital

ADC and DAC

PWM duty cycle

GPIO and CAN bus

Motor symbols V I omega theta tau

Plant physics equations

Delta t and stepping

Simulator updates the plant

Real-time deadline

Hardware-in-the-Loop testing

Read it top to bottom: the loop and the swap give the shape; signals + converters wire the swap; the symbols + physics + stepping let the simulator be the plant; the real-time deadline keeps the fake plant honest. Together they make HIL.


Equipment checklist

Self-test: can you answer each before revealing?

What is the "plant" in a control loop?
The physical machine being controlled (engine, motor, car).
What stays REAL in a HIL test, and what becomes simulated?
The controller chip stays real; the plant becomes a computer simulation.
Difference between an analog and a digital signal?
Analog can be any height in a range; digital is only on/off.
What does an ADC do vs a DAC?
ADC turns a voltage into a number; DAC turns a number into a voltage.
What number does PWM's duty cycle encode?
The fraction of each cycle the wire is "on" — i.e. the average power fraction.
Convert 800 RPM to rad/s (formula only).
rad/s.
What does mean and why does the simulator need it?
One small time step; the simulator advances the plant's state one at a time.
What does "real-time" actually require?
Every update finishes before its deadline, every time — not merely "fast".
State the real-time deadline inequality.
.
Why keep the controller real instead of simulating it (SIL)?
Only a real chip reveals real-chip bugs: timing, drivers, compiler quirks.