The Replayable Factory: Turning PLC Data into a Digital Twin That Can Rewind
How machine data from PLCs on assembly lines and sorters, a physics-aware digital twin, and synchronized video turn a vague jam into a provable root cause.

Every plant has the same argument after a jam: what actually happened?
The operator saw one thing. The PLC logged another. The camera caught a third angle. Three hours later, the line is running again and nobody can prove which story was right.
I spent years on the controls side of large distribution operations. The most useful thing I built wasn’t a faster sorter. It was a way to rewind the building.
Table of Contents
- Why Root Cause Analysis Usually Fails
- Step 1: Treat PLC Data as an Event Stream
- Step 2: Build a Twin That Can Replay, Not Just Display
- Step 3: Overlay Video to Verify the Model
- What Changes When You Can Rewind
- Where AI Fits (and Where It Doesn’t)
- Summary
- Technical Q&A
Why Root Cause Analysis Usually Fails
Industrial data is abundant and nearly useless after the fact. PLC registers hold sensor states for milliseconds before something overwrites them. HMI screens show the present. Maintenance notes live on a whiteboard.
So an RCA becomes testimony. People reconstruct a sequence of events from memory, and the loudest explanation wins.
Three things break it:
| Failure | What it looks like | Why it kills the RCA |
|---|---|---|
| Volatile state | Sensor and drive data overwritten within the scan cycle | The evidence no longer exists |
| Siloed timestamps | PLC, WMS and camera clocks drift apart | You can’t align cause and effect |
| No physical model | Logs say a sensor tripped, not what the freight did | You see the symptom, never the mechanism |
KEY INSIGHT: An RCA is only as good as your ability to reproduce the event. If you can’t replay it, you’re guessing with extra steps.
Step 1: Treat PLC Data as an Event Stream
The first move is boring and decisive: capture every state transition, with a trusted timestamp, off the controller.
Assembly lines and sorters already emit what you need. Photo-eye edges, encoder counts, drive faults, divert confirmations, and interlock states all change on a scan loop. The job is to stream those changes to durable storage as events with one shared clock, not as sampled dashboards.
Three rules keep this honest:
- Log transitions, not snapshots. A sensor flickering at 20 ms is a finding. A one-second average hides it.
- One time base. Sync controllers, gateways and video to the same source, or every later step is noise.
- Keep the raw record. Derived metrics are opinions. Raw events are evidence.
This is the same pattern I use in AyoWork: append-only events with provenance, so anything that happened can be re-examined later.
Step 2: Build a Twin That Can Replay, Not Just Display
Most digital twins are 3D dashboards. They show the plant now. That’s useful for operations and useless for forensics.
A replayable twin takes the recorded event stream and drives a kinematic model of the line. Conveyors move at their logged speeds. Packages appear where the sensors said they did. Diverters fire when the PLC commanded them.
Then you scrub a timeline.
- Scrub to any second and see the state of every device.
- Slow down a jam to the scan-cycle level.
- Branch: change one input (a gap, a ramp, a timing window) and re-run to see if the outcome flips.
That last capability is where the twin earns its keep. You are no longer asking “what happened?” You’re asking “what would have prevented it?” and testing the answer against recorded reality.
Step 3: Overlay Video to Verify the Model
A twin is a hypothesis. Video is the ground truth you check it against.
When the recorded footage is time-aligned to the event stream, you can lay the twin’s prediction over the real picture. If a package in the model leaves the belt at the same instant it does in the video, the model is trustworthy for that event. If it diverges, the divergence is the finding.
Overlay gives you two jobs in one view:
- Validate the physics. Friction, timing and actuator-latency assumptions get tested against what the cameras saw.
- Prove the cause. The sequence is visible, aligned, and shareable with the vendor, the maintenance lead and the plant manager at the same time.
The argument stops being “what happened?” It becomes “here it is.”
What Changes When You Can Rewind
Replay changes behavior, not just analysis.
| Without replay | With replay |
|---|---|
| RCA takes days and ends in “likely” | RCA takes hours and ends in a demonstrated sequence |
| Fixes target the symptom | Fixes target the mechanism and are tested before deployment |
| Knowledge walks out with the shift | Every incident becomes a reusable case |
| Vendor disputes are he-said-she-said | Everyone looks at the same timeline |
That last row matters more than people expect. Evidence turns a negotiation into an engineering conversation.
Where AI Fits (and Where It Doesn’t)
AI is useful here in two specific places, and neither is “decide what broke.”
- Triage at scale. Thousands of events a minute are too many for people. A model can cluster recurring patterns, flag near-misses, and queue the incidents worth replaying.
- Drafting the first hypothesis. An agent can read the event window, propose a candidate cause, and attach the evidence. A human accepts or rejects it.
What stays deterministic: the replay itself, the physics model, and the sign-off. The model proposes. The recorded events and the physics decide.
I use the same rule for AI agents in business systems. Anything that touches reality goes through a deterministic layer that can be audited.
Summary
- RCA fails when evidence is volatile. Stream PLC transitions to durable storage on one clock.
- A twin that only displays can’t investigate. Make it replay recorded events and allow branching.
- Video validates the model. Align it to the event stream and overlay the twin’s prediction.
- Replay changes the economics of incidents. Faster RCAs, tested fixes, reusable cases.
- Use AI for triage and first hypotheses. Keep replay and sign-off deterministic.
Technical Q&A
What data do you need to build a replayable twin?
Timestamped state transitions from the controllers (sensor edges, encoder counts, drive and divert events), a shared time base, and a kinematic model of the equipment. Video is optional for replay and essential for validation.
How accurate does the twin need to be?
Accurate enough that its prediction matches the video for the events you care about. Start with timing and kinematics, then add friction and actuator latency where the overlay shows divergence.
Can this work on equipment that’s already installed?
Yes. Most of the signals already exist in the controller. The work is capturing them off the PLC without disturbing the scan cycle, then standardizing the timestamps.
Next Step
I’m writing this series as I build the systems behind it. If you’re wrestling with RCAs, machine data, or digital twins on a real line, I’d like to compare notes. Find me on LinkedIn, or read how the same event-first thinking shapes AyoWork.