Case Study · 01
Smart Factory M221 AI/ML System
A software-based Industry 4.0 simulation that bridges a virtual PLC to ML-driven closed-loop control — built around the Schneider M221 control philosophy, without requiring physical PLC hardware.
Reading
Smart Factory
M221
TL;DR
A software-based Industry 4.0 pipeline that connects a simulated PLC to a machine-learning service in a closed control loop — without requiring physical PLC hardware. It models the Schneider M221 control philosophy: industrial telemetry flows out through Modbus and MQTT, an ML service scores the machine's condition, and a control supervisor acts on those scores automatically.
Context
The goal was to build a complete closed-loop pipeline — from machine data acquisition to intelligent control — that mirrors how a real Industry 4.0 line would work, but entirely in software. Rather than modeling a real Schneider M221 PLC in isolation, the system simulates the industrial process itself: temperature, vibration, current, speed, production count, and energy consumption.
Architecture
The system is structured as a chain of independent stages:
[Simulated Process]
temperature, vibration, current, speed,
production count, energy consumption
│
▼
[Virtual PLC Memory]
PLC-style %M / %MW registers
│ (Modbus TCP)
▼
[Edge Bridge]
Modbus TCP → MQTT
│ (MQTT)
▼
[Streamlit Dashboard] [ML Service]
real-time visualization anomaly score
of machine states, maintenance risk
trends, alarms, and recommended speed
ML predictions │
▼
[Write-back to Modbus registers]
│
▼
[Control Supervisor]
normal / warning / alarm
automatic response
This reflects the pipeline as described in the project's own documentation. A visual architecture diagram is planned but not yet available — this text representation is the verified structure.
PLC & Industrial Communication
The virtual PLC exposes its state using a PLC-style memory model (%M for
discrete bits, %MW for memory words), mirroring how a real Schneider M221
organizes its internal state. This memory is served over Modbus TCP,
and an edge bridge relays it onward as MQTT telemetry for the dashboard
and ML service to consume.
AI / ML Component
A machine-learning service analyzes the incoming telemetry to calculate an anomaly score, a maintenance-risk estimate, and a recommended machine speed. These predictions are written back into the same Modbus register space the PLC uses, so the control logic can consume them exactly as it would consume any other PLC value.
Closed-Loop Control
A software control supervisor watches the ML output and enforces three states: maintaining normal operation, reducing speed under warning conditions, and stopping the process when maintenance risk crosses an alarm threshold — entirely driven by the ML predictions written back into PLC memory.
Key Decision
Hardware-swappable design. The virtual PLC layer was deliberately scoped so that it can later be replaced by a real Schneider M221 PLC without redesigning the rest of the pipeline — the Modbus TCP interface is the same contract a physical PLC would expose. This was chosen over hard-coding the simulation into the ML/dashboard layers, which would have made a future hardware swap much more disruptive.
Honest Limitations
This is a software simulation. It has not yet been run against physical PLC hardware — the hardware-swappable architecture is a design property, not a validated deployment. No production usage data, accuracy figures, or uptime metrics exist for this system, and none are claimed here.
What's Next
The natural next step is validating the same Modbus TCP interface against a real Schneider M221 PLC, which the architecture was designed to support without rework.