Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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
  1. Package the application with an interface of inputs, outputs, tunables and a status output (Applications as packages, Status and the write gate).
  2. Map the PLC’s nodes in an opcua-client: measurements into inputs with a max_age_ms, outputs to the PLC’s variables, taktwerk.heartbeat and taktwerk.status to variables the PLC program watches. Per mapping scale, offset, min, max and max_unchanged_s check the values on the way (Conversion and checks).
  3. 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.
  4. Let operators tune on the PLC’s HMI: a tunable mapped with sync = true and a sync_epoch node is seeded from the engine, forwards an operator’s write into the image and follows other writers (Tunable sync).
  5. 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).
  6. Commission in steps: check --live, a run with writes = "dry-run", then run --write plc (Commissioning).
  7. 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).