Skip to content

Commit 961911b

Browse files
authored
Merge pull request #93 from diodeinc/match-moar-generics
Add house LEDs, ferrite beads, pin headers
2 parents 3800271 + f1e9e91 commit 961911b

21 files changed

+684
-48
lines changed

board_config.zen

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("units.zen", "Impedance")
22
load("properties.zen", "Layout")
3-
load("bom/match_generics.zen", "add_default_bom_profile")
3+
load("bom/match_generics.zen", "assign_house_parts")
44

55
# Enum Types
66
CopperWeight = enum("0.5oz", "1oz", "2oz")
@@ -381,7 +381,7 @@ def Board(
381381
via_dimensions: list | None = None,
382382
default: bool = False,
383383
modifiers: list | None = None,
384-
bom_profile=add_default_bom_profile,
384+
bom_profile=assign_house_parts,
385385
):
386386
"""Define a PCB board configuration.
387387

bom/helpers.zen

Lines changed: 177 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
"""BOM matching helper functions"""
22

33
load("../utils.zen", "e96", "e24")
4-
load("../units.zen", "ResistanceRange", "Voltage", "Power", "Capacitance")
4+
load(
5+
"../units.zen",
6+
"ResistanceRange",
7+
"Voltage",
8+
"VoltageRange",
9+
"Power",
10+
"Capacitance",
11+
"Resistance",
12+
"Impedance",
13+
"Current",
14+
"Frequency",
15+
)
516

617

718
def prop(c, names):
@@ -66,6 +77,39 @@ def iec60062_4digit(value):
6677
return mantissa + str(mult)
6778

6879

80+
def encode_3digit_multiplier(value):
81+
"""3-digit + multiplier encoding (Uniroyal style): no R-notation, always 3 digits.
82+
83+
Uses J/K/L for negative powers: J=10^-1, K=10^-2, L=10^-3
84+
Examples: 16.2Ω → 162J, 100Ω → 1000, 10kΩ → 1002
85+
"""
86+
mult = 0
87+
norm = value
88+
89+
# Scale to 100-999 range
90+
for _ in range(10):
91+
if norm >= 100.0:
92+
break
93+
norm = norm * 10.0
94+
mult = mult - 1
95+
96+
for _ in range(10):
97+
if norm < 1000.0:
98+
break
99+
norm = norm / 10.0
100+
mult = mult + 1
101+
102+
# Round and format to 3 digits
103+
mantissa = str(int(norm + 0.5))
104+
mantissa = ("0" * (3 - len(mantissa))) + mantissa
105+
106+
# Map multiplier to character
107+
multiplier_map = {-3: "L", -2: "K", -1: "J"}
108+
mult_char = multiplier_map.get(mult, str(mult))
109+
110+
return mantissa + mult_char
111+
112+
69113
def iec60062_3digit(value):
70114
"""IEC 60062 3-digit code: 2 significant digits + multiplier (e.g., 2.2MΩ → 225)."""
71115
if value < 100.0:
@@ -149,6 +193,35 @@ def panasonic_erj(series, resistance_range, voltage, power, tolerance, e_series,
149193
)
150194

151195

196+
def uniroyal(series, resistance_range, voltage, power, tolerance, e_series, suffix, encode):
197+
"""Shorthand for Uniroyal chip resistor series.
198+
199+
Args:
200+
series: Series name (e.g., "0402WGF")
201+
resistance_range: Resistance range (e.g., "10Ohm – 10MOhm")
202+
voltage: Max voltage (e.g., "50V")
203+
power: Power rating (e.g., "0.0625W")
204+
tolerance: Tolerance string (e.g., "1%")
205+
e_series: List of E-series (e.g., ["e96", "e24"])
206+
suffix: Packaging suffix (e.g., "TCE")
207+
encode: Encoding function (typically encode_3digit_multiplier)
208+
209+
Returns:
210+
Resistor series dictionary
211+
"""
212+
return resistor_series(
213+
"Uniroyal Electronics",
214+
series,
215+
resistance_range,
216+
voltage,
217+
power,
218+
tolerance,
219+
e_series,
220+
encode,
221+
suffix,
222+
)
223+
224+
152225
def discrete_resistor_series(manufacturer, series, max_v, power, tolerance, values_with_mpns):
153226
"""Helper to create discrete resistor series (non-E-series, exact values only).
154227

@@ -200,6 +273,109 @@ def murata_cap(dielectric, voltage, cap, base_mpn, suffixes, manufacturer="Murat
200273
}
201274

202275

276+
def led(color: str, voltage_range: str, mpn: str, manufacturer: str) -> dict:
277+
"""Helper to create LED catalog entry.
278+
279+
Args:
280+
color: LED color (e.g., "red", "blue", "green")
281+
voltage_range: Forward voltage range (e.g., "1.8V – 2.4V (2V nom.)")
282+
mpn: Manufacturer part number
283+
manufacturer: Manufacturer name
284+
285+
Returns:
286+
LED dictionary
287+
"""
288+
return {
289+
"color": color,
290+
"forward_voltage": VoltageRange(voltage_range),
291+
"mpn": mpn,
292+
"manufacturer": manufacturer,
293+
}
294+
295+
296+
def pin_header(pins: int, rows: int, pitch: str, orientation: str, mpn: str, manufacturer: str) -> dict:
297+
"""Helper to create pin header catalog entry.
298+
299+
Args:
300+
pins: Number of pins per row
301+
rows: Number of rows (1 or 2)
302+
pitch: Pitch (e.g., "1.27mm", "2.54mm")
303+
orientation: Orientation (e.g., "Vertical", "Horizontal")
304+
mpn: Manufacturer part number
305+
manufacturer: Manufacturer name
306+
307+
Returns:
308+
Pin header dictionary
309+
"""
310+
return {
311+
"pins": pins,
312+
"rows": rows,
313+
"pitch": pitch,
314+
"orientation": orientation,
315+
"mpn": mpn,
316+
"manufacturer": manufacturer,
317+
}
318+
319+
320+
def ferrite_bead(impedance: str, frequency: str, current: str, dcr: str, mpn: str, manufacturer: str) -> dict:
321+
"""Helper to create ferrite bead catalog entry.
322+
323+
Args:
324+
impedance: Impedance with tolerance (e.g., "220Ohm 25%")
325+
frequency: Test frequency (e.g., "100MHz")
326+
current: Rated current (e.g., "1.4A")
327+
dcr: DC resistance max (e.g., "100mOhm")
328+
mpn: Manufacturer part number
329+
manufacturer: Manufacturer name
330+
331+
Returns:
332+
Ferrite bead dictionary
333+
"""
334+
return {
335+
"impedance": Impedance(impedance),
336+
"frequency": Frequency(frequency),
337+
"current": Current(current),
338+
"dcr": Resistance(dcr),
339+
"mpn": mpn,
340+
"manufacturer": manufacturer,
341+
}
342+
343+
344+
def tvs(standoff_voltage: str, clamping_voltage: str, peak_pulse_power: str, mpn: str, manufacturer: str) -> dict:
345+
"""Helper to create TVS diode catalog entry.
346+
347+
Args:
348+
standoff_voltage: Reverse standoff voltage (e.g., "5V" or "5V to 6V")
349+
clamping_voltage: Clamping voltage @ Ipp (e.g., "9.2V" or "9V to 12V")
350+
peak_pulse_power: Peak pulse power (e.g., "200W" or "200W to 400W")
351+
mpn: Manufacturer part number
352+
manufacturer: Manufacturer name
353+
354+
Returns:
355+
TVS diode dictionary
356+
"""
357+
# Use ranges for all values to support flexible matching
358+
standoff_val = (
359+
VoltageRange(standoff_voltage)
360+
if "to" in standoff_voltage
361+
else VoltageRange(standoff_voltage + " to " + standoff_voltage)
362+
)
363+
clamping_val = (
364+
VoltageRange(clamping_voltage)
365+
if "to" in clamping_voltage
366+
else VoltageRange(clamping_voltage + " to " + clamping_voltage)
367+
)
368+
power_val = Power(peak_pulse_power)
369+
370+
return {
371+
"standoff_voltage": standoff_val,
372+
"clamping_voltage": clamping_val,
373+
"peak_pulse_power": power_val,
374+
"mpn": mpn,
375+
"manufacturer": manufacturer,
376+
}
377+
378+
203379
def match_component(match: dict, parts: tuple | list, matcher: str = "match_component"):
204380
"""Create a component modifier that matches specific properties and assigns MPN.
205381

0 commit comments

Comments
 (0)