Skip to content

Control Loop Delay

Open in simulator →

A stopwatch for the engine: a square-wave command opens and closes a breaker, and the load current comes back into the control domain, so you can count the exact number of time steps each domain crossing costs.

The measurement loop. A square wave cmd commands the breaker; the breaker and the 10 Ω load live in the electrical domain; the load current i_load is picked back up by a From tag, passed through a unity gain, and republished as i_ctl. The two dashed arrows are the domain crossings, and each one costs exactly one time step.

The circuit is deliberately trivial so that nothing but the timing is interesting. A signal_gen square wave at 10 Hz swings cmd between 0 and 1, which commands a breaker feeding a 10 Ω resistor from a 10 V DC source. The resistor publishes its current as i_load. A From tag picks i_load back up into the control domain, a unity gain passes it through, and a Go-To republishes it as i_ctl. The run uses a 1 ms time step over 0.2 s — far coarser than a real EMT study, chosen so that a one-step delay is a visible millisecond on the scope instead of an invisible microsecond.

Plot cmd, brk, i_load, and i_ctl together and read off the edges. The command falls at t = 0.050 s. The breaker state brk and the load current i_load do not follow until t = 0.051 s, one step later. The control-domain copy i_ctl does not follow until t = 0.052 s, two steps later. The same ladder repeats on every edge — cmd switches at 0.050, 0.100 and 0.150 s, the electrical pair at 0.051, 0.101 and 0.151 s, and i_ctl at 0.052, 0.102 and 0.152 s. It is also there at start-up: cmd is already high in the first recorded row at t = 0.001 s, i_load reaches 0.9998 A at t = 0.002 s, and i_ctl gets there at t = 0.003 s.

Nothing about this is a numerical artifact you should try to tune away. Every signal crossing between the control domain and the electrical network is bound to the previous step's value, in both directions, because the two domains have no execution dependency on each other and can run in either order within a step. One crossing costs one step; a loop that leaves the control domain and comes back costs two. The closed value 0.9998 A is just 10/(10+0.001+0.001) — the load plus the breaker's on-resistance and the source's series resistance — and the 10 nA in the open state is leakage through the breaker's 1 GΩ off-resistance.

Two experiments worth running. Cut the time step to 100 µs and the delays shrink to 0.1 ms each: the lag is always two steps, never a fixed amount of time, which is why it stops mattering once the step is small compared with the dynamics you care about. Then raise the square-wave frequency toward the step rate and watch the loop stop tracking altogether — the point at which a two-step lag becomes a real modeling error rather than a curiosity.