
Vacuum Nozzle Validation for SMT Assembly in Async Python
If the nozzle is too large for the component body it drops the part, and a 1,600-line async pipeline checks this for every component and nozzle.
- Published
- April 27, 2026
- Author
- Hrushiekesh Reddy Kanjula
- Read time
- ~4 min
- Category
- engineering

Every SMT job has one physical rule. The outer diameter of the vacuum nozzle must not exceed 50% of the component's body width. Go over that and the nozzle overhangs the edge. The vacuum seal breaks. The part drops onto the floor, or onto a part that is already placed.
The rule applies to every component, checked against every nozzle in the machine's current roster. A typical PCB has 200 to 800 components. A machine might rotate through 12 nozzle types. 200 × 12 is 2,400 checks. Nobody does that by hand before production. The assembly hub does it automatically in under 10 seconds with an async pipeline.
The data
Two datasets feed the validation.
Component geometries come from the canonical SQLite library. For each reference designator on the placement list, we need body_width_mm. It comes from manufacturer datasheets and is imported during component normalization.
The machine nozzle roster is the set of nozzles loaded in the machine, each with its outer_diameter_mm. It is queried from the machine's CGI API at runtime. It reflects what is loaded today, not last week.
The validation logic is trivial:
def nozzle_valid_for_component(
nozzle_od_mm: float,
component_body_width_mm: float
) -> bool:
return nozzle_od_mm <= 0.5 * component_body_width_mmThe work is in collecting and correlating the two datasets across hundreds of components and a dozen nozzle types.
Why async
The bottleneck is I/O. The pipeline queries the machine CGI API over the network, the SQLite database on disk, and sometimes the Mouser API for missing geometry. Done in sequence, each component waits for all the I/O of the one before it.
With asyncio, all the geometry queries go out at once. The event loop starts every database read and handles results as they finish. For 500 components, wall-clock time drops from about 25 seconds sequential to about 3 seconds concurrent.
import asyncio
import aiosqlite
async def get_component_geometry(db_path: str, ref_des: str) -> dict:
async with aiosqlite.connect(db_path) as db:
async with db.execute(
"SELECT body_width_mm FROM component_library WHERE ref_des = ?",
(ref_des,)
) as cursor:
row = await cursor.fetchone()
return {"ref_des": ref_des, "body_width_mm": row[0] if row else None}
async def validate_all_components(placement_list: list, nozzle_roster: list, db_path: str):
# Dispatch all geometry queries concurrently
geometry_tasks = [
get_component_geometry(db_path, comp["ref_des"])
for comp in placement_list
]
geometries = await asyncio.gather(*geometry_tasks)
# Now validate each component against all nozzles
violations = []
for geom in geometries:
if geom["body_width_mm"] is None:
violations.append({"ref": geom["ref_des"], "issue": "MISSING_GEOMETRY"})
continue
for nozzle in nozzle_roster:
if not nozzle_valid_for_component(nozzle["od_mm"], geom["body_width_mm"]):
violations.append({
"ref": geom["ref_des"],
"nozzle": nozzle["id"],
"issue": "OVERHANG_VIOLATION",
"ratio": nozzle["od_mm"] / geom["body_width_mm"]
})
return violations
Missing geometry
Not every component has a documented body_width_mm. Older parts from legacy suppliers often have incomplete datasheets. The pipeline has two fallbacks.
Package-based fallback. Standard package sizes have known nominal body widths. An 0402 resistor is 1.0mm × 0.5mm. An 0603 is 1.6mm × 0.8mm. If the library entry has no body width but has a recognized package code, the pipeline uses the package nominal width with a safety margin.
Mouser API enrichment. If the package code is also unknown, the pipeline queries the Mouser API with the manufacturer part number to get dimensions. These lookups are async and cached. The first query fills the library and later runs use the cached value.
Anything still unresolved is flagged in the UI as "geometry unknown — manual review required". It is never silently skipped.
The violation report
The output is a violation report grouped by severity.
| Severity | Nozzle-to-component ratio | Meaning |
|---|---|---|
| CRITICAL | Above 0.6 (20% beyond the constraint) | Likely causes a drop. Assembly must not proceed without changing the nozzle assignment. |
| WARNING | 0.5 to 0.6 | Marginal. May work on a well-maintained nozzle and fail on a worn one. Flagged for engineer review. |
| INFO | 0.45 to 0.5 | Within spec but close to the limit. Noted for monitoring. |

For each violation, the report also suggests substitutions. It lists the nozzles in the roster that would pass for that component, ordered by closeness to the optimal pick ratio. 0.3 to 0.4 is the sweet spot for a reliable vacuum seal.
Why encode it
The 50% rule is not a business rule that might change next quarter. It follows from fluid dynamics and contact geometry. Putting it in an automated pre-production check enforces it the same way regardless of operator experience or shift pressure.
SMT has other physical constraints: thermal pad sizing, solder paste volume, minimum clearance between adjacent parts. The hub's validation framework is designed to encode them with the same pattern. A new constraint becomes a new async coroutine and a new violation type in the report.
Physics does not have bugs. That makes this some of the most reliable code in the hub.