TRUMPF Laser OPC UA & Siemens Energy SQL: Solving the 95% OEE Polling Loss
Why standard 60-second historian polling misses 95% of fiber laser beam-on time; resolving TRUMPF WSI4 counter anomalies, TruTops M:N nesting inflation, and zero-MES OEE via Siemens energy amperage SQL.
- 01Sheet and tube laser NC cutting programs execute in
10–60seconds (net_beam_on_timeis frequently3–10seconds per cut); whenOPC UAresets per-program counters to0on completion, standard60-secondsnapshot pollers capture only~5%of laser beam-on time and~10%of active cutting time. - 02
TRUMPF(OPC UA+WSI4) stream variants expose cumulativegross_run_timeandnet_processing_timecounters that do not reset across NC programs, yieldnet_processing_time > gross_run_timeon multi-axis overlaps, and leave stickyEstimatedProgramEndTimetimestamps frozen after completion. - 03
TruTopssheet-metal nesting combines parts from 6 different customer work orders onto 1 steel sheet NC program—causing naive SQL joins against ERP work orders (LG_XXX_PRODORD,AFKO) to inflate runtime and scrap 6x without a proportionalNestingAllocationontology entity. - 04For legacy CNC and pipe-laser machines lacking
OPC UAjob states, exact active cutting vs. energized idle time can be reconstructed from Siemens energy-monitoring SQL tables (~5 Ampsenergized idle vs>= 10 Ampsactive cutting) paired with dead-stream staleness watchdogs.
1. The Nyquist 60-Second OEE Polling Trap: Losing 90–95% of Laser Beam-On Time
Industrial historian and SCADA pipelines built for injection molding, stamping presses, or batch furnaces routinely rely on 60-second periodic snapshot polling (ReadRequest every 60s). When that exact architecture is pointed at high-power sheet or tube fiber lasers, it violates the Nyquist sampling criterion and silently destroys OEE accuracy.
On modern sheet and tube laser cells, individual cutting or sub-program cycles run in 10 to 60 seconds, while actual resonator net_beam_on_time is often just 3 to 10 seconds per cut. Crucially, per-program OPC UA execution counters reset back to 0 the instant an NC program completes so the controller can initialize the next cycle.
Whenever a 60-second historian poller wakes up on the minute mark, complete cutting programs start, fire the beam, finish, and reset to 0 entirely between two consecutive ticks. Production telemetry audits demonstrate that standard 60-second snapshot polling captures only ~5% of actual laser beam-on time and ~10% of active cutting time (90–95% permanent data loss). Feeding those snapshots to BI dashboards or an AI agent makes a three-shift laser cell running at capacity appear to sit idle 90%+ of the day.
- Nyquist Violation & Reset Race Conditions: Even shortening a periodic SQL/SCADA timer from
60sto10sfails on3–8stube-laser cuts because any reset-on-complete counter creates an inherent race window between peak cycle accumulation and controller zeroing. - Event-Driven
OPC UA MonitoredItemSubscriptions: Replace periodic polling withOPC UAMonitoredItemsubscriptions configured atSamplingInterval <= 500ms(QueueSize >= 20,discardOldest = false) tied to program-completion events, or ingest strictly monotonic lifetime counters. - Preventing False Idle Blame in AI Agents: Without ontology ingestion guards, a Text-to-SQL agent summing 60-second snapshots computes
4.8%shift utilization and fabricates executive root-cause summaries blaming shop-floor operators for phantom downtime.
Any PLC or OPC UA node that resets to 0 upon NC program completion is mathematically incompatible with periodic timer polling. The ontology layer must strictly derive OEE durations from completion-triggered events or monotonic lifetime counter deltas.
2. Four TRUMPF (OPC UA + WSI4) Telemetry Anomalies That Break Naive BI & Agents
Even after upgrading from 60-second polling to high-frequency TRUMPF OPC UA and WSI4 (Werkstatt-Schnittstelle) event streams, four controller-level telemetry quirks routinely break naive SQL transformations and ungrounded AI agents.
First, on continuous stream variants, cumulative counters such as gross_run_time and net_processing_time do not reset across NC program transitions—summing them raw inflates machine hours by orders of magnitude. Even more counterintuitively, raw controller streams legitimately emit windows where net_processing_time > gross_run_time whenever multi-axis kinematics, automatic pallet-shuttle prep, or parallel nozzle/piercing sub-channels execute concurrently.
- Non-Resetting Cumulative Counters &
net > grossMulti-Axis Overlaps: Stream counters requireLAG()delta windowing partitioned bymachine_idand guarded against PLC reboot counter wraps (current < previous). When parallel auxiliary axes pushnet_processing_timeabove wall-clockgross_run_time, naivegross - netavailability formulas produce negative idle seconds unless clamped to wall-clock time while tracking parallel overlap separately. - Sticky
EstimatedProgramEndTimeTimestamps: While cutting, the controller updatesEstimatedProgramEndTimedynamically; when the NC program finishes, the controller never clears or nulls the node—it simply stops updating it. Hours later on an idle machine, naive agents read the stale timestamp and hallucinate that the laser is "240 minutes overdue on an active cut." <10%Laser-to-Run Ratio = Hardware/Sensor Degradation (Not Operator Idle): Whenbeam_on_delta / gross_run_deltadrops below10%during sustained active runs—often accompanied by depressedfeedrate_overridepercentages—naive OEE dashboards blame operator micro-stops. In production laser physics,<10%beam-to-run ratio duringRUNNINGstate flags protective window contamination, capacitive height-sensor drift, or assist-gas pressure throttling.stopped_malfunctionvsstopped_operator& Raw Germanmessage_text_dePayloads: Fault streams separate unplanned breakdowns (stopped_malfunction-> Availability loss) from planned operator sheet handling/slug removal (stopped_operator-> Setup/Operational wait), while emitting untranslated German NC alarm payloads (message_text_de, e.g., Schneidgasdruck zu niedrig, Abstandsregelung Störung, Schutzglas Verschmutzung) that evade English or TurkishILIKEtext filters.
| Telemetry Signal / Node | Raw Controller Behavior | Naive BI / Agent Failure Mode | Enterprise Ontology Resolution |
|---|---|---|---|
gross_run_time & net_processing_time | Monotonic across NC program boundaries; net > gross on multi-axis/shuttle overlap | SUM() inflates runtime 100x+; gross - net yields negative idle durations | LAG() delta windowing + reboot wrap guard + LEAST(net_delta, wall_delta) clamp |
EstimatedProgramEndTime | Never cleared on program completion; freezes at last finished timestamp | Reports idle/setup machines as hours-overdue active cutting jobs | Nullified unless machine_state = 'RUNNING' and ts updated within fresh window |
beam_on / gross_run < 0.10 & feedrate_override | Machine reports RUNNING while beam duty falls <10% and feedrate throttles | Misattributes optical/gas degradation to operator slowness | Raises HARDWARE_SENSOR_OR_OPTICS_DEGRADATION maintenance diagnostic |
stopped_* & message_text_de | Distinct stop states paired with untranslated German PLC/NC alarm text | Lumps operator waits into machine MTBF; misses alarms on English/Turkish queries | Maps German fault codes & message_text_de to canonical multilingual OEE loss taxonomy |
WITH raw_ticks AS (
SELECT
machine_id,
nc_program_id,
machine_state,
event_ts,
gross_run_time_sec,
net_processing_time_sec,
beam_on_time_sec,
feedrate_override_pct,
estimated_program_end_ts,
LAG(gross_run_time_sec) OVER (PARTITION BY machine_id ORDER BY event_ts) AS prev_gross_sec,
LAG(net_processing_time_sec) OVER (PARTITION BY machine_id ORDER BY event_ts) AS prev_net_sec,
LAG(beam_on_time_sec) OVER (PARTITION BY machine_id ORDER BY event_ts) AS prev_beam_sec,
EXTRACT(EPOCH FROM (
event_ts - LAG(event_ts) OVER (PARTITION BY machine_id ORDER BY event_ts)
)) AS wall_window_sec
FROM mes_raw.trumpf_wsi4_telemetry
WHERE event_ts >= CURRENT_DATE - INTERVAL '1 day'
),
normalized_deltas AS (
SELECT
machine_id,
nc_program_id,
machine_state,
event_ts,
wall_window_sec,
-- Guard against PLC reboot or counter rollover without losing non-resetting program transitions
CASE
WHEN prev_gross_sec IS NULL THEN 0
WHEN gross_run_time_sec < prev_gross_sec THEN gross_run_time_sec
ELSE gross_run_time_sec - prev_gross_sec
END AS gross_run_delta_sec,
CASE
WHEN prev_net_sec IS NULL THEN 0
WHEN net_processing_time_sec < prev_net_sec THEN net_processing_time_sec
ELSE net_processing_time_sec - prev_net_sec
END AS raw_net_delta_sec,
CASE
WHEN prev_beam_sec IS NULL THEN 0
WHEN beam_on_time_sec < prev_beam_sec THEN beam_on_time_sec
ELSE beam_on_time_sec - prev_beam_sec
END AS beam_on_delta_sec,
feedrate_override_pct,
-- Invalidate sticky EstimatedProgramEndTime once program is no longer actively cutting
CASE
WHEN machine_state = 'RUNNING' AND estimated_program_end_ts > event_ts - INTERVAL '5 minutes'
THEN estimated_program_end_ts
ELSE NULL
END AS valid_eta_ts
FROM raw_ticks
)
SELECT
machine_id,
nc_program_id,
SUM(gross_run_delta_sec) AS active_run_sec,
-- Clamp multi-axis / shuttle overlap to wall-clock denominator for OEE; expose overlap separately
SUM(LEAST(raw_net_delta_sec, GREATEST(gross_run_delta_sec, wall_window_sec))) AS capped_net_proc_sec,
SUM(GREATEST(raw_net_delta_sec - gross_run_delta_sec, 0)) AS parallel_axis_overlap_sec,
SUM(beam_on_delta_sec) AS laser_beam_on_sec,
CASE
WHEN SUM(gross_run_delta_sec) >= 120
AND (SUM(beam_on_delta_sec)::numeric / NULLIF(SUM(gross_run_delta_sec), 0)) < 0.10
THEN 'HARDWARE_SENSOR_OR_OPTICS_DEGRADATION'
ELSE 'NOMINAL'
END AS diagnostic_health_flag,
MAX(valid_eta_ts) AS current_program_eta
FROM normalized_deltas
WHERE wall_window_sec BETWEEN 0.1 AND 300
GROUP BY machine_id, nc_program_id;3. The Sheet-Metal Nesting M:N Chasm Trap: NestingExecution vs. ERP WorkOrder
The deadliest cross-system modeling bug in sheet-metal fabrication occurs when joining laser execution logs (NestingExecution) to ERP production work orders (LG_XXX_PRODORD in Logo Tiger or AFKO / AFPO in SAP).
To maximize raw steel plate utilization, TruTops and CAD/CAM nesting engines routinely combine parts belonging to 6 different customer orders onto 1 physical steel sheet NC program (e.g., 3 mm S235JR nest NEST_2026_0841.LST). Simultaneously, a large 500-piece ERP work order spans dozens of nested steel sheets across multiple shifts. The physical reality is a strict M:N (many-to-many) cardinality.
When an analyst or Text-to-SQL agent joins machine OEE execution rows directly to ERP work orders (JOIN nesting_workorders USING (nc_program_id) JOIN LG_301_PRODORD ...) and runs SUM(active_run_sec) or SUM(skeleton_scrap_kg), a textbook Chasm Trap fires: an 18-minute laser sheet run and 42 kg of skeleton scrap get duplicated across all 6 work orders on that plate—multiplying reported laser runtime to 108 minutes (6x) and scrap tonnage to 252 kg (6x)!
- First-Class
NestingAllocationBridge Entity: The ontology forbids direct aggregation acrossNestingExecution ↔ WorkOrder, routing every cost, energy, runtime, and scrap rollup through a proportionalNestingAllocationlink entity. - Dual Physics-Based Weighting (Kinematics vs. Geometry): Laser runtime and kWh energy allocate proportionally by cut contour length + pierce count equivalence (
(cut_contour_mm + pierce_count * pierce_equiv_mm) * completed_qty), whereas raw sheet consumption and skeleton scrap allocate by true part surface area (part_area_mm2 * completed_qty). - Aborted Sheet Reconciliation: If a nozzle crash halts cutting mid-sheet after completing 4 of 6 nested orders, weights recompute over verified
completed_qtyrather than planned CAD nest quantities.
WITH sheet_weights AS (
SELECT
na.nesting_exec_id,
na.work_order_id,
na.erp_prodord_ref, -- Logo LG_XXX_PRODORD.LOGICALREF or SAP AFKO.AUFNR
(na.cut_contour_mm + na.pierce_count * 18.0) * na.completed_qty AS kinematic_load,
SUM((na.cut_contour_mm + na.pierce_count * 18.0) * na.completed_qty)
OVER (PARTITION BY na.nesting_exec_id) AS total_sheet_kinematic_load,
(na.part_area_mm2 * na.completed_qty) AS area_load,
SUM(na.part_area_mm2 * na.completed_qty)
OVER (PARTITION BY na.nesting_exec_id) AS total_sheet_area_load
FROM ontology.nesting_allocations na
WHERE na.completed_qty > 0
)
SELECT
sw.work_order_id,
COUNT(DISTINCT sw.nesting_exec_id) AS nested_sheets_count,
ROUND(SUM(
ne.active_run_sec * (sw.kinematic_load / NULLIF(sw.total_sheet_kinematic_load, 0))
), 2) AS allocated_laser_run_sec,
ROUND(SUM(
ne.skeleton_scrap_kg * (sw.area_load / NULLIF(sw.total_sheet_area_load, 0))
), 3) AS allocated_scrap_kg
FROM sheet_weights sw
JOIN ontology.nesting_executions ne
ON ne.nesting_exec_id = sw.nesting_exec_id
GROUP BY sw.work_order_id;Whenever a physical shop-floor execution (NestingExecution, heat-treat furnace batch, powder-coat rack) fulfills multiple ERP work orders simultaneously, the ontology query compiler must reject any SUM(duration) or SUM(scrap) query lacking an explicit allocation_ratio multiplier.
4. Zero-MES OEE Reconstruction via Siemens Energy Amperage SQL + Dead-Stream Watchdogs
Real brownfield factories rarely have uniform OPC UA coverage: next to brand-new fiber lasers sit legacy CNC press brakes, turret punches, and pipe-laser machines lacking OPC UA job-state licenses. Instead of stalling digital transformation for costly PLC retrofits, plants that already log feeder telemetry into Siemens energy-monitoring SQL tables (SENTRON PAC / Powermanager historians) can reconstruct exact machine operating states directly from phase current draw.
Industrial laser and CNC current signatures separate cleanly into three deterministic bands: below ~1 Amp, the main breaker is de-energized (POWERED_OFF); around ~5 Amps (3.0–8.5 A band), chillers, CNC cabinets, and servo drives sit in energized idle state waiting on material load/unload (IDLE_ENERGIZED); once the resonator and motion axes engage at >= 10 Amps, the machine is unequivocally in active cutting (ACTIVE_CUTTING).
Equally critical across OPC UA, energy SQL, and biometric attendance streams is defending against silent stream outages. When a PLC gateway freezes or a network VLAN drops, zero rows land in SQL—causing naive COALESCE(SUM(cut_sec), 0) / shift_sec queries to misreport 0% OEE for a shift that actually ran non-stop! Ontology staleness heartbeats eliminate false zero-production reports.
- Per-Machine Calibrated Amperage State Machines: Storing machine-specific current thresholds (
off_max_amps,idle_band_amps,active_cut_min_amps) in the ontology yields audit-grade OEE Availability on zero-MES legacy machines without requiring operator tablet taps. - Cross-Sensor Truth Arbitration (
OPC UAvs.Siemens Energy SQL): IfTRUMPF OPC UAstops emitting events for 30 minutes whileSiemensenergy SQL records26 Ampson the same machine feeder, the ontology suppresses false machine downtime and flagsTELEMETRY_COLLECTOR_OUTAGE. - Dead-Stream Heartbeat Watchdogs (
TELEMETRY_STALE): Whenever shift sample coverage drops below85%(across PLC, energy, or biometric turnstile streams), the ontology returnsprovenance_quality_state = TELEMETRY_STALEandNULLfor unverified shift OEE rather than poisoning executive KPIs with0%.
WITH shift_window AS (
SELECT
TIMESTAMP '2026-12-05 08:00:00' AS shift_start,
TIMESTAMP '2026-12-05 16:00:00' AS shift_end,
28800.0 AS planned_shift_sec
),
amperage_intervals AS (
SELECT
e.feeder_machine_id AS machine_id,
e.sample_ts,
e.l1_l2_l3_avg_amps AS amps,
LEAST(
EXTRACT(EPOCH FROM (
LEAD(e.sample_ts, 1, sw.shift_end) OVER (
PARTITION BY e.feeder_machine_id ORDER BY e.sample_ts
) - e.sample_ts
)),
60.0 -- Cap inter-sample duration at 60s so dead streams do not extrapolate last state
) AS valid_slice_sec,
MAX(e.sample_ts) OVER (PARTITION BY e.feeder_machine_id) AS last_heartbeat_ts
FROM energy_sql.siemens_pac_measurements e
CROSS JOIN shift_window sw
WHERE e.sample_ts >= sw.shift_start
AND e.sample_ts < sw.shift_end
)
SELECT
a.machine_id,
ROUND(SUM(a.valid_slice_sec) / MAX(sw.planned_shift_sec), 3) AS telemetry_coverage_ratio,
CASE
WHEN COALESCE(SUM(a.valid_slice_sec), 0) / MAX(sw.planned_shift_sec) < 0.85
THEN 'TELEMETRY_STALE_DO_NOT_REPORT_ZERO_OEE'
ELSE 'VERIFIED'
END AS provenance_quality_state,
ROUND(SUM(CASE WHEN a.amps >= 10.0 THEN a.valid_slice_sec ELSE 0 END), 0) AS active_cutting_sec,
ROUND(SUM(CASE WHEN a.amps >= 3.0 AND a.amps < 10.0 THEN a.valid_slice_sec ELSE 0 END), 0) AS energized_idle_sec,
ROUND(SUM(CASE WHEN a.amps < 3.0 THEN a.valid_slice_sec ELSE 0 END), 0) AS powered_off_sec,
-- Emit OEE cutting utilization ONLY when heartbeat coverage passes the staleness gate
CASE
WHEN COALESCE(SUM(a.valid_slice_sec), 0) / MAX(sw.planned_shift_sec) >= 0.85
THEN ROUND(
SUM(CASE WHEN a.amps >= 10.0 THEN a.valid_slice_sec ELSE 0 END)
/ NULLIF(SUM(a.valid_slice_sec), 0) * 100.0,
2
)
ELSE NULL
END AS verified_cutting_utilization_pct
FROM amperage_intervals a
CROSS JOIN shift_window sw
GROUP BY a.machine_id;Frequently Asked Technical Questions
Does lowering our historian polling interval from 60 seconds to 5 seconds solve the OPC UA OEE loss?
No—it reduces the loss percentage but leaves the underlying bug intact. Short tube-laser cuts and thin-sheet piercing programs finish in 3–4 seconds; because per-program OPC UA counters reset to 0 immediately upon program completion, even a 5-second snapshot timer still misses entire cycles. Always subscribe via event-driven OPC UA MonitoredItems or compute LAG() deltas over non-resetting lifetime counters.
Why does TRUMPF WSI4 occasionally report net_processing_time greater than gross_run_time?
On multi-axis laser cells with automated pallet changers or auxiliary prep channels, the controller accumulates overlapping sub-channel processing durations into net_processing_time while gross_run_time tracks primary cell wall-clock run time. Rather than failing with negative idle numbers, the ontology clamps OEE availability denominators to wall-clock bounds and surfaces the excess as parallel_axis_overlap_sec.
Why not allocate nested laser sheet runtime across ERP work orders by part count (piece quantity)?
A single nested steel plate frequently pairs 50 tiny mounting washers from Order A (40 seconds total laser cut time) alongside 2 heavy chassis side-frames from Order B (16 minutes of intricate contour cutting). Piece-count allocation dumps 96% of machine cost onto the washers. Allocating runtime by cut contour length + pierce count and scrap by true surface area reflects physical reality.
Are the ~5 Amp idle and >=10 Amp cutting thresholds identical across every Siemens-monitored CNC machine?
Exact thresholds are calibrated per machine class in the ontology metadata depending on resonator wattage (e.g., 4 kW vs. 12 kW fiber source) and whether external chillers share the monitored feeder. However, the trimodal physical step-change—breaker off (<1–2 A), energized idle base load (~4–7 A), and active cutting load (>=10 A)—holds reliably across legacy pipe lasers, punches, and press brakes.
Glossary Concepts Referenced in This Guide
ORDER_LINES and PAYMENTS) in one flat SQL query, multiplying totals silently.FOREIGN KEY constraints—common across mature ERP and manufacturing databases.STAT = 4, SPEC_CODE = "B2") in operational tables to verified business states and calculation inclusion rules.Free to reference in engineering docs, ADRs, articles, and course syllabi with attribution.
[TRUMPF Laser OPC UA & Siemens Energy SQL: Solving the 95% OEE Polling Loss — Ontoloji.org](https://ontoloji.org/en/guides/trumpf-laser-opc-ua-and-siemens-energy-sql-oee-polling-loss)