# Acausal Modelling and Control Sytem

**URL:** <https://discourse.julialang.org/t/acausal-modelling-and-control-sytem/127003>\
**Category:** Modelling & Simulations\
**Tags:** question, control, modelling, controlsystems\
**Created:** [March 16, 2025, 9:50am UTC](https://discourse.julialang.org/t/acausal-modelling-and-control-sytem/127003 "2025-03-16T09:50:12Z")\
**Posts on this page:** 3\
**Page:** 2

<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:** [May 1, 2025, 8:19am UTC](https://discourse.julialang.org/t/acausal-modelling-and-control-sytem/127003/21 "2025-05-01T08:19:42Z")

</div>

How the example works:

1. First, the functions that generate the symbolic DAE system are called. They return a vector of equations, and in addition vectors of initial values.
2. Then, an ODE system is created from these vectors.
3. Then the system is symbolically simplified (might take 30-60s)
4. Now the init! function is called on the ODE system to find the initial state
5. Now, in a loop for each timestep:
  - first, the system is simulated for one timestep of the control system
  - then the controller is called
  - the system parameters are updated from the controller output
  - this repeats until the final simulation time is reached.

In reality, it is a bit more complex, but first you have to understand this simple scheme.

Is it clear now?

In the given example, the controller is operating at 20 Hz, it uses a fixed time step of 50ms. The continues time model of the physical system is using a varying time step solver, in average about 100 iterations are needed to converge for simulating the 50ms time span of the outer loop.

To clarify: I am not using MTK to implement the controller, only to implement the model of the physical system.

---

<div class="post-metadata">

**Author:** ![AndhikaTama](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andhikatama/32/215293_2.png) [@AndhikaTama](https://discourse.julialang.org/u/AndhikaTama)\
**Post date:** [May 1, 2025, 9:29am UTC](https://discourse.julialang.org/t/acausal-modelling-and-control-sytem/127003/22 "2025-05-01T09:29:39Z")

</div>

Alright, thank you—I’ve understood the general idea. However, I’m still not quite sure how to apply it to my code that ive created based on this reference [DC Motor with Speed Controller · ModelingToolkitStandardLibrary.jl](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/tutorials/dc_motor_pi/).

---

<div class="post-metadata">

**Author:** ![AndhikaTama](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andhikatama/32/215293_2.png) [@AndhikaTama](https://discourse.julialang.org/u/AndhikaTama)\
**Post date:** [May 4, 2025, 3:39pm UTC](https://discourse.julialang.org/t/acausal-modelling-and-control-sytem/127003/23 "2025-05-04T15:39:55Z")

</div>

Hello, i manage to find the solution and find the right connection to each component using ModellingToolkit @mtkmodel. But when i try to use solve function it causes this warning like this :

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/f/5f21e8e49f1be56da9a5af6c1927280fbe640f7b.png)

How can i debug and solve this issue? Does modellingtoolkit have the tools to solve this problem?

[Previous page](https://discourse.julialang.org/t/acausal-modelling-and-control-sytem/127003.md?page=1)
