A controller or estimator beside a PLC
An estimator, a soft sensor or a model-based controller runs next to a PLC: it reads the PLC’s measurements, computes at a fixed period and writes estimates or set points back. The PLC keeps the I/O, the interlocks and the safe state.
flowchart LR
subgraph tw[taktwerk, edge PC or Linux PLC]
EST[estimator] --> CTL[controller] --> PI[(image)]
EST --> PI
end
PLC[PLC] -- "measurements, set points" --> PI
PI -- "estimates, manipulated values,<br/>status, heartbeat (gated)" --> PLC
- Package the application with an interface of inputs, outputs, tunables and a status output (Applications as packages, Status and the write gate).
- Map the PLC’s nodes in an
opcua-client: measurements into inputs with amax_age_ms, outputs to the PLC’s variables,taktwerk.heartbeatandtaktwerk.statusto variables the PLC program watches. Per mappingscale,offset,min,maxandmax_unchanged_scheck the values on the way (Conversion and checks). - Gate the writes on the application’s status:
[connector.gate]with{ signal = "est.status", mask = 255 }. A closed gate writes none of the gated outputs; the PLC keeps their last values and sees the heartbeat and the status. - Let operators tune on the PLC’s HMI: a tunable mapped with
sync = trueand async_epochnode is seeded from the engine, forwards an operator’s write into the image and follows other writers (Tunable sync). - Generate the PLC side:
taktwerk plc-mirror project.toml --node-prefix 'ns=4;s='writes an IEC 61131-3 program with one variable per mirrored signal and the map entries that write it, from one walk over the plan, so the two cannot diverge (CLI). - Commission in steps:
check --live, a run withwrites = "dry-run", thenrun --write plc(Commissioning). - Deploy as a bundle to the edge PC or the Linux PLC, supervised by systemd or by taktwerk’s own supervisor (Deploying to devices).
The PLC program must treat a heartbeat that stops advancing, or taktwerk.status other than
1, as the engine being gone, and fall back to its own safe values
(the safety contract).
On a PLC that runs Linux itself, the same binary runs on the PLC; keep the cycle thread’s
priority below the PLC runtime’s own tasks, and record with sink = "buffer" pulled by
taktwerk record from an edge PC (Two sinks).