r/matlab • u/Barnowl93 • 43m ago
Tips Not everything with hardware is HiL... What are you actually testing?
I've been seeing a few posts both here and on other subreddits that mix up hardware in the loop (HiL), processor in the loop (PiL) and any kind of deployment to hardware. As a result, it's hard for people to give good advice and suggestions in cases where we may be talking about different things. A few months ago I wrote a blog to demystify it a bit. Here's the short version
MiL (model in the loop, or desktop simulation): everything is simulated. Here we are testing the design itself.
SiL (software in the loop): the generated code (say C or C++) runs on your PC against the same plant model. Now we are testing the software implementation that matches our design.
PiL (processor in the loop): the code runs on the real target board while the plant stays on the host. They exchange data step by step, so it isn't real-time. Checking that the target processor gives us the same answers as the PC.
HiL (hardware in the loop): the plant runs on a real-time simulator (like speedgoat), and the controller talks to it through its physical I/O in real time. (sometimes real parts of the plant in the loop too)
My point is that putting code on a board doesn't make it HiL. In PiL the plant is simulated and nothing has to run in real time, in HiL the plant is simulated in real time through real I/O, and in a full deployment nothing is simulated.
Here's the link to the blog if you want more in depth info
https://blogs.mathworks.com/engineering/2026/08/20/how-do-we-know-our-system-will-actually-work/
One thing I didn't specifically cover is desktop HiL with Simulink Desktop Real-Time, where the plant runs in real time on your own PC with an I/O board instead of a dedicated real-time target. I'll cover that in a future post.
Hope this all helps
