PLC–MES Traceability Pipeline
End-to-end VIN and production-event tracking across a multi-PLC shopfloor, with buffered, validated data delivery into the MES.
Context & challenge
A large automotive assembly plant needed full production traceability — every VIN had to be linked to the exact PLC events (tightening results, leak tests, vision checks) that occurred during its build. The legacy approach relied on manual CSV exports and periodic database inserts, which created gaps, duplicates, and audit failures.
The MES vendor required a structured SQL insert contract: specific table schemas, mandatory fields, and strict ordering. Any malformed record would be rejected and lost. At the same time, the PLC layer had no guaranteed delivery — if the middleware crashed or the network hiccupped, events simply disappeared.
Approach
The solution was built as a lightweight Node-RED edge middleware running on an industrial PC in the cell. The architecture has three logical layers:
- Acquisition — S7 communication nodes poll each PLC on a 500 ms cycle, capturing relevant DB registers and event flags. All raw data is timestamped and written to a local SQLite buffer before any downstream processing.
- Transformation — a set of processing nodes validates mandatory fields, maps PLC data types to MES schema types, and enriches records with station metadata (line, cell, shift). Malformed records are quarantined and logged for review.
- Delivery — validated records are batched and sent to the MES SQL endpoint via a Python microservice that wraps the vendor API. The service retries on transient errors and confirms ACKs before clearing records from the buffer, guaranteeing exactly-once delivery.
Key decisions
Local buffering was the most important design choice. By persisting every raw event to SQLite before forwarding, the system survives MES downtime, network outages, or middleware restarts without losing production data. The buffer acts as a write-ahead log — forward progress is only marked after the MES confirms receipt.
Python was chosen for the delivery microservice because the MES vendor provided a Python SDK, and wrapping it in a small FastAPI service allowed independent scaling and easier debugging than trying to handle retries inside Node-RED flows.
Outcome
After go-live, traceability coverage reached 100 % of in-scope stations. The monthly audit that previously took two days to reconcile was eliminated. Zero data-loss incidents were recorded in the first three months of production operation. The buffered architecture also proved its value during a planned MES maintenance window — roughly 4 000 events queued cleanly and flushed in order once the MES came back online.