Skip to content
Hrushiekesh Reddy Kanjula
AOI inspection results and SMT machine telemetry being linked by timestamps into a closed-loop analytics system

Linking AOI Defects to SMT Machine Events With a Time-Window Join

AOI defects and SMT machine events share no key, so I join them on time and cut a 20-minute defect investigation to a 30-second query.

Published
April 20, 2026
Author
Hrushiekesh Reddy Kanjula
Read time
~4 min
Category
engineering

Closed-loop cross-linking of AOI inspection and SMT machine telemetry

AOI results and SMT machine telemetry live in separate databases. Linking a defect to a machine event takes about 20 minutes by hand. You read the defect report, pull the machine log for that hour, and look for anything unusual while the board was inside the machine. In the assembly hub, a SQL query does the same job in about 30 seconds.

No shared key

The two systems have no common identifier. The AOI machine doesn't know the head ID. The SMT machine doesn't know the AOI defect code. The only shared datum is time, because both recorded events in the same production window.

So a plain JOIN ON foreign_key doesn't work. The link has to be temporal. Find the telemetry that was active while a specific board was inside the SMT machine.

The time-window join

The SMT machine logs an entry_time and an exit_time for every board. The AOI record carries the board serial number. The serial number links the AOI defect to the board's production window. The BETWEEN clause then pulls every telemetry event inside that window.

SELECT 
    a.board_serial,
    a.defect_type,
    a.defect_location,
    a.inspection_time,
    m.head_id,
    m.nozzle_type,
    m.error_code,
    m.event_timestamp
FROM aoi_defects a
JOIN board_production_windows bpw 
    ON a.board_serial = bpw.board_serial
JOIN machine_telemetry m 
    ON m.event_timestamp BETWEEN bpw.machine_entry_time 
                              AND bpw.machine_exit_time
WHERE a.defect_type IN ('TOMBSTONE', 'MISALIGNMENT', 'MISSING_COMPONENT')
  AND a.inspection_date > DATE('now', '-7 days');

Time-window join linking board production windows to coincident machine telemetry events

Adding component context

The join gives a list of machine events that overlapped a defective board. That list is not yet actionable. You also need to know which component the machine was working on during each event.

The forward-fill CTE from the previous post attributes each telemetry event to a component. Joining it in lets us compare the two views side by side.

WITH attributed_telemetry AS (
    SELECT 
        m.*,
        COALESCE(m.component_ref, 
                 LEAD(m.component_ref) OVER (
                     PARTITION BY m.head_id ORDER BY m.event_timestamp
                 )) AS attributed_component
    FROM machine_telemetry m
),
defect_investigation AS (
    SELECT 
        a.board_serial,
        a.defect_location AS aoi_flagged_ref,
        a.defect_type,
        at.head_id,
        at.nozzle_type,
        at.error_code,
        at.attributed_component AS machine_attributed_ref,
        -- Do they agree?
        at.attributed_component = a.defect_location AS refs_match
    FROM aoi_defects a
    JOIN board_production_windows bpw ON a.board_serial = bpw.board_serial
    JOIN attributed_telemetry at 
        ON at.event_timestamp BETWEEN bpw.machine_entry_time 
                                  AND bpw.machine_exit_time
    WHERE at.error_code IS NOT NULL
)
SELECT * FROM defect_investigation WHERE refs_match = TRUE;

When refs_match = TRUE, the component AOI flagged is the same one the machine reported an error on during that board's window. That is the strongest finding the query produces. It is a direct link between a defect and a machine event, which is stronger than a correlation.

Confirmed causal links where AOI defect location matches machine error attribution

A week of production data typically gives a handful of high-confidence findings. Three patterns came up repeatedly in my experience.

Nozzle-specific failures. One nozzle type kept showing up in confirmed links for tombstone defects on 0402 capacitors. Its inner diameter was slightly worn. It was still within spec, but it gave inconsistent vacuum on the smallest components. Catching this means replacing the nozzle two days before the weekly maintenance cycle, not after it starts dropping parts.

Temperature-correlated misalignment. The machine also logs temperature. Cross-linking the timestamps sometimes shows misalignment errors clustered in the first 20 minutes of a shift. That is before the machine reaches operating temperature and its thermal expansion stabilizes. A 5-minute warm-up cycle before running serialized boards eliminates the cluster.

Pick order interactions. Sometimes a large IC pick followed right away by a small resistor on the adjacent head hurts placement accuracy on the resistor. The inertia from the heavy IC pick affects the head's position when it moves to the resistor. Reordering the placement sequence in the program removes the interaction.

None of these is visible in the AOI data alone or in the telemetry alone.

The dashboard

The queries feed a dashboard in the assembly hub UI that shows confirmed defect-cause pairs in real time. Click a board serial number and you see its full production story. That includes which heads placed which components, which telemetry events fell in its window, and which AOI defects were found.

Defect investigation dashboard showing board production timeline and confirmed causal links

The time saving matters, but the bigger effect is on behavior. When root cause analysis takes 20 minutes, engineers skip it for minor defects. When it takes 30 seconds, every defect gets looked at, and every data point can feed back into the process.

Hire me