# MTK HIL simulation and code generation

**URL:** <https://discourse.julialang.org/t/mtk-hil-simulation-and-code-generation/140124>\
**Category:** Modelling & Simulations\
**Tags:** question\
**Created:** [October 20, 2026, 3:40pm UTC](https://discourse.julialang.org/t/mtk-hil-simulation-and-code-generation/140124 "2026-10-20T15:40:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepperoni](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@pepperoni](https://discourse.julialang.org/u/pepperoni)\
**Post date:** [October 20, 2026, 3:40pm UTC](https://discourse.julialang.org/t/mtk-hil-simulation-and-code-generation/140124/1 "2026-10-20T15:40:28Z")

</div>

Hello Julia community,

I wanted to start by saying I really do appreciate Julia and that I don’t like the closed ecosystem of MATLAB/Simulink. However, I feel Simulink, with its real-time package and coders, is the king of hardware-in-the-loop (HIL) simulation. Notwithstanding my disdain for MATLAB, at work I chose to use Simulink for HIL simulation.

My company is working with a few partners, one of which is supplying the core simulation model in FMU format (in co-simulation mode, black box model). This FMU model needs to run at around a 500 Hz update rate. Around this model, I am adding a few lightweight models.

The simulation needs to interact with a physical autopilot that provides a UDP interface to override its sensor readings with the simulation outputs. To match the clock of the physical autopilot, I need to pace my simulation to match the wall clock; however, I do not need sub-millisecond time accuracy. As of today, the simulation sends its output to the autopilots at a 100 Hz update rate.

ModelingToolkit (MTK) is the Julia analogue of MATLAB Simulink but with an acausal engine. From my understanding, MTK development has mostly been directed toward offline simulation of big models on big computers, less toward time determinism. Also, I feel the inherent causal nature of an FMU model negates the acausal advantage of MTK.

And lastly, we might want to use Simulink Coder in the future to produce DO-178C-compliant code and deploy it on autopilot hardware. I wonder if there is any ambition for Julia/MTK to compete with these MATLAB/Simulink workflows. In short, what I want to know is what is the long term vision.

I am dreaming of the day where the answer will be always Julia and MATLAB will become irrelevant.

Am I getting it wrong? What does the community think?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [October 20, 2026, 5:22pm UTC](https://discourse.julialang.org/t/mtk-hil-simulation-and-code-generation/140124/2 "2026-10-20T17:22:30Z")

</div>

> [@pepperoni](#):
>
> Notwithstanding my disdain for MATLAB, at work I chose to use Simulink for HIL simulation.

Well, we use Julia for HIL flight simulations. Which works well at 20 to 100 Hz, I had no need for 400 Hz yet. What I do not understand:

- do you need a simulator that runs on a small, embedded machine?
- how complex are your models? We usually have about 80 states, but we also have models with a few hundred states.
- do you want to use FMU models, or export them, or both?
- how long are your simulations running? Minutes, hours or days?

A lot is already possible today, including code generation: [Automating Aerospace Systems Engineering: PDF-to-Simulation with the Dyad Agent - Video | JuliaHub](https://juliahub.com/videos/automating-aerospace-systems-engineering-pdf-to-simulation-with-the-dyad-agent)

---

<div class="post-metadata">

**Author:** ![ranjan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranjan/32/4832_2.png) [@ranjan](https://discourse.julialang.org/u/ranjan)\
**Post date:** [October 20, 2026, 5:50pm UTC](https://discourse.julialang.org/t/mtk-hil-simulation-and-code-generation/140124/3 "2026-10-20T17:50:58Z")

</div>

Thanks for the question. Have you heard of Dyad? We are developing this on top of the MTK stack. This provides support for the causal modeling and [clocked/discrete-time features](https://help.juliahub.com/dyad/stable/stdlib/DiscreteComponents/) which are controls focused. We also have the ability to [generate C code from these discrete time models too](https://help.juliahub.com/dyad/stable/tutorials/discrete-code-generation.html#Generating-C). We currently target MISRA compliance but looking towards the other standards as well. This should give you an idea of the vision.

You should be able to try out Dyad too: [Installation | Dyad](https://help.juliahub.com/dyad/stable/installation.html)
