Chapter 06 System
System architecture
Four levels from the controller to the browser display, three software layers, plugin interface
Four levels connect the controller with the simulation on a Raspberry Pi; the software consists of three layers. Every plant model implements the same interface, so that 13 models run without any change to the orchestrator.
The setup can be read as four levels (Fig. 1): the controller at 24 V, converter stages, signal bridge and the simulation on a Raspberry Pi.
The path of a signal
Twelve channels lead from the controller to the model, ten back (Fig. 2).
Controller switches
An output of the LOGO! puts 24 V on a channel.
Convert level
An optocoupler turns this into 5 V, galvanically isolated.
Bridge reads
The Arduino Mega transmits the state serially at 115200 baud.
Model calculates
The gateway provides the inputs, the orchestrator retrieves them and calculates the model in the cycle.
Report back
Changed sensors travel back the same way and, via relay contacts, apply 24 V to the controller again.
Software in three layers
- Presentation layer: the browser with Canvas 2D animation, operating panel and error log, supplied via WebSocket.
- Application layer:
orchestrator.pyon port 8050. It paces the simulation, loads models at runtime (hot swap) and distributes the results. - Communication layer:
gateway.pyon port 8100, the bridge between serial hardware and HTTP, with its own read and write thread and automatic reconnection.
A model is a plugin
Every plant model is an exchangeable module (plugin) with the same structure; the orchestrator knows only one call:
compute_step(inputs, dt) → { plant, sensors, outputs_logical }
inputs are the twelve channels from the outputs of the controller, dt is the step size. What comes back are the physical state (plant), the sensor bits (sensors) and the logical outputs (outputs_logical). Because this holds for all models, 13 plant models now run on the same platform (Fig. 6), without any change to the orchestrator. However, the interface is only agreed upon as a convention, not formally specified (Chapter 11).
Continue with the hardware of the signal level (Chapter 7) and the heated-tank model (Chapter 8).



