OEE Through Real-Time CNC Data: How I Built the Full Calculation Engine

One of the biggest goals in my CNC automation project was not just capturing machine data, but interpreting it into meaningful performance metrics. OEE (Overall Equipment Effectiveness) became the natural next step.
This blog explains how I built a complete OEE engine using the real-time data extracted through PLC → Modbus → Node-RED → n8n → MongoDB → Dashboard.
Why OEE?
Factories rely heavily on manual logs. These logs often miss downtime, overestimate performance, and completely ignore cycle-time fluctuations.
Using machine data changes everything.
OEE gives a real picture of how productive a machine actually is by measuring:
Availability
Performance
Quality
To compute these properly, the entire automation pipeline had to be reliable and accurate.
Extracting Machine Data
The CNC machine sent signals to the PLC such as cycle completion, alarm states, spindle activity, and production pulses. The PLC cleaned and exposed these signals over Modbus so Node-RED could read them.
Node-RED: Preprocessing Layer
Node-RED monitored:
Cycle ON/OFF transitions
Alarm bit
No-cycle timeout (idle logic)
It created event entries such as:
Cycle start
Cycle end
Idle start
Idle end
Alarm start
Alarm end
These were forwarded to n8n for OEE calculations.
n8n as the OEE Engine
n8n workflows calculated:
Availability
Availability = Run Time / Planned Production Time
Performance
Performance = (Ideal Cycle Time × Total Parts) / Run Time
Quality
Quality = Good Parts / Total Parts
OEE
OEE = Availability × Performance × Quality
n8n stored each computed result in MongoDB and synced it with the frontend.
Dashboard Visualization
The React dashboard displayed:
OEE gauge
Availability/Performance/Quality details
Live production count
Cycle-time trends
Machine state timeline
Challenges
Lack of automation experience
Noise in signals
Accurate timestamp alignment
Cycle-time spikes causing wrong performance values
Each issue required debugging, testing, and improving logic across PLC, Node-RED, and n8n.
Conclusion
Building an OEE engine taught me how automation and data engineering come together inside a modern factory. It’s one of the most technically challenging and rewarding parts of this project, and it pushed me much deeper into Industry 4.0 development.




