I try the Julia Modeling Toolkit as an alternative to Simulink/Simscape. I’m struggling a bit with the connection to the “classical” Julia code. I’m looking for something like a PS-Simulink converter block. The following picture shows my very simple example in Simulink. I’m trying to replicate a similar example in Julia, but I don’t know how to pass values between the logic part and the circuit.

The circuit is simulated using a fixed-step solver (Euler/Heun), and I assume that my logic runs in the same execution loop as the circuit. The Julia code is a slightly modified example of a RC circuit from the ModelingToolkitStandardLibrary.jl. I saw in the library RealInput, RealOutput blocks. Are they attended to this functionality? How can I use them in my example?

```
using ModelingToolkit, OrdinaryDiffEq, Plots
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Blocks: Constant
R = 1.0
C = 1.0
V = 1.0
dt = 0.004
@variables t
@named resistor = Resistor(R = R)
@named capacitor = Capacitor(C = C)
@named source = Voltage()
@named constant = Constant(k = V)
@named ground = Ground()
rc_eqs = [connect(constant.output, source.V)
connect(source.p, resistor.p)
connect(resistor.n, capacitor.p)
connect(capacitor.n, source.n, ground.g)]
@named rc_model = ODESystem(rc_eqs, t,
systems = [resistor, capacitor, constant, source, ground])
sys = structural_simplify(rc_model)
prob = ODEProblem(sys, Pair[], (0, 10.0))
solver = init(prob, Euler(),dt =dt)
# Number of iterations
num_iterations = 1000
for i in 1:num_iterations
step!(solver)
u = solver.u
#??????????????
#??????????????
#??????????????
push!(data_array, u[1])
end
plot(data_array)
```