
Rotation Heuristics in SMT Assembly, and Why IPC-2581 Would Replace Them
A 180-degree rotation error on a polarized capacitor causes a short circuit, a three-tier heuristic catches most of them, and IPC-2581 would make the problem obsolete.
- Published
- May 4, 2026
- Author
- Hrushiekesh Reddy Kanjula
- Read time
- ~4 min
- Category
- engineering

A polarized capacitor placed 180 degrees off connects its positive terminal to the negative rail. At best it fails open. At worst it explodes. Rotation errors on polarized parts are among the most serious SMT defects, and they are common. The Component Placement List (CPL) that tells the machine how to orient each part is made by people, exported from CAD tools with different rotation conventions, and often wrong.
The assembly hub's rotation validation catches these errors before the machine runs. It uses a three-tier heuristic cascade. It catches about 94% of rotation issues in the hub's test suite. It exists because, in 2026, no universally enforced standard makes heuristics unnecessary.
The CPL file problem
A CPL (also called a centroid or XY file) is a CSV that lists every component on a board. Each row has the X/Y coordinate, the board side (top or bottom) and the rotation angle θ (Theta). θ tells the machine which way to orient the part.
The problem is that CAD tools export θ against different reference conventions. KiCad, Altium, Eagle and OrCAD all treat 0 degrees differently. A part exported from KiCad at θ=0 may need θ=90 in the machine program. Import the file unchecked and every polarized part could be 90 or 180 degrees off.
A CPL file has no metadata that says which convention it used. You cannot read the file and know. You have to infer it from the component type, from historical data and from domain knowledge. The three tiers below do that inference.

Tier 1: database lookup
The first tier is the most reliable. The component library stores num_leads for every component. Two-lead parts (resistors, capacitors, inductors, simple diodes) cause most rotation problems. Orientation matters on them, and their symmetry makes visual inspection hard.
If num_leads == 2 in the library, the part needs rotation validation. The system checks whether the CPL θ fits the expected orientation for that component family. Entries that were manually verified against a customer's CAD export are stored as "deterministic baselines". Those are direct matches and skip tiers 2 and 3.
Tier 2: package profile matching
When the library has no definitive record, the second tier matches on package. Standard 2-pin packages (0402, 0603, 0805, SOD-123, DO-214AC) have known rotation semantics from their geometry and industry convention.
TWO_PIN_PACKAGES = {
"0402", "0603", "0805", "1206", "0201", # chip resistors/caps
"SOD-123", "SOD-323", "DO-214AC", # diodes
"SOT-23", "SOT-323" # small transistors
}
def tier2_package_check(package: str, theta: float) -> str:
if package.upper() in TWO_PIN_PACKAGES:
# Normalize theta to 0-360
normalized = theta % 360
if normalized in (90, 270):
return "VERIFY" # Unusual but not definitively wrong
if normalized == 180:
return "FLAG" # Likely polarity reversal
return "OK"
return "UNKNOWN"Tier 3: part number scanning
Parts that get no definitive result from tiers 1 and 2 go to the third tier. It scans the raw part number for embedded lead-count or polarity codes. Many manufacturer part numbers carry them. "MLCC-2-0402-100N" contains "2" for two leads. "ELEC-CAP-2PIN-100UF-10V" contains "2PIN".
import re
def tier3_lexical_scan(part_number: str) -> str:
two_pin_patterns = [
r'\b2[-_]?PIN\b',
r'\bBIPOLAR\b',
r'\bPOLARIZED\b',
]
for pattern in two_pin_patterns:
if re.search(pattern, part_number, re.IGNORECASE):
return "POLARIZED"
return "UNKNOWN"The other 6% get through. They are non-standard parts with incomplete library entries and non-descriptive part numbers. Those are flagged for manual engineer review.
Bottom-side mirroring
Parts on the bottom of a PCB are placed upside-down. The machine looks at the board from the top, so a bottom-side θ is mirrored. A bottom-side part at θ=0 in the CPL needs θ=180 in the machine program, and the other way round.
The system applies a mirroring transform to all bottom-side parts before validation:
def mirror_bottom_side_theta(theta: float, board_side: str) -> float:
if board_side.upper() == "B":
return (180 - theta) % 360
return thetaIt runs before any tier check. Without it, every bottom-side polarized part would trigger a false-positive rotation violation.

Why IPC-2581 would remove all of this
The heuristics exist because CPL files carry too little information. IPC-2581 is an XML-based data exchange format. It includes explicit polarity indicators, standardized rotation references and component-level metadata. The data says whether a part is polarized and what the correct orientation is. No guessing is needed.
The problem is adoption. As of 2026, most PCB CAD tools can export IPC-2581. Most contract manufacturing customers still send Gerber plus CSV, because that is what they have always sent. The standard exists and the tools support it. Industry practice has not caught up.
The hub is built with IPC-2581 in mind. When a customer sends an IPC-2581 file, the system reads polarity directly and skips tiers 2 and 3. The cascade is a fallback for the legacy format, not a permanent design. The right long-term answer is better data. Until then, database lookup, package matching and part number scanning do the job.