diff --git a/backend/pinscopex/derating.py b/backend/pinscopex/derating.py index e54d3f9..2af4caa 100644 --- a/backend/pinscopex/derating.py +++ b/backend/pinscopex/derating.py @@ -5,11 +5,62 @@ from __future__ import annotations import re from backend.pinscopex.models import ComponentType, DesignGraph, NetType +from backend.pinscopex.resolve_passives import _format_value from backend.pinscopex.utils import natural_sort_key # Dielectric strings that indicate ceramic capacitors _CERAMIC_DIELECTRICS = {"X7R", "X5R", "C0G", "NP0", "Y5V", "X7S", "X6S", "X8R", "C0G (NP0)"} +# Remaining C/C0 vs V/Vrated. Empirical stima, not a vendor lot curve. +_BIAS_CURVES: dict[str, list[tuple[float, float]]] = { + "c0g": [(0.0, 1.0), (1.2, 1.0)], + "x7r": [(0.0, 1.0), (0.25, 0.90), (0.50, 0.70), (0.75, 0.45), (1.0, 0.30), (1.2, 0.22)], + "x5r": [(0.0, 1.0), (0.25, 0.82), (0.50, 0.55), (0.75, 0.32), (1.0, 0.18), (1.2, 0.12)], + "y5v": [(0.0, 1.0), (0.25, 0.50), (0.50, 0.20), (0.80, 0.12), (1.0, 0.10)], +} + + +def _lerp(curve: list[tuple[float, float]], x: float) -> float: + if x <= curve[0][0]: + return curve[0][1] + for (x0, y0), (x1, y1) in zip(curve, curve[1:]): + if x <= x1: + if x1 == x0: + return y1 + t = (x - x0) / (x1 - x0) + return y0 + t * (y1 - y0) + return curve[-1][1] + + +def _bias_family(dielectric: str | None) -> str | None: + if not dielectric: + return None + u = dielectric.upper() + if "C0G" in u or "NP0" in u or "NPO" in u: + return "c0g" + if "Y5V" in u: + return "y5v" + if "X5R" in u or "X6S" in u: + return "x5r" + if "X7R" in u or "X7S" in u or "X8R" in u: + return "x7r" + return None + + +def dc_bias_remaining( + dielectric: str | None, + v_op: float | None, + rated_v: float | None, +) -> float | None: + """Fraction of nominal C remaining under DC bias, or None if not modelled. + + Labelled a *stima*: class-2 MLCC curves vary by lot, thickness and vendor. + """ + family = _bias_family(dielectric) + if family is None or v_op is None or rated_v is None or rated_v <= 0: + return None + return _lerp(_BIAS_CURVES[family], max(0.0, v_op) / rated_v) + def _parse_voltage_rating(s: str | None) -> float | None: """Extract numeric voltage from a rating string like '16V', '25V', '2.5V'.""" @@ -64,10 +115,12 @@ def build_derating_table(graph: DesignGraph) -> list[dict]: rated_v: float | None = None value_fmt: str | None = None dielectric: str | None = None + c_nom: float | None = None if comp.specs and hasattr(comp.specs, "voltage_rating_v"): rated_v = _parse_voltage_rating(comp.specs.voltage_rating_v) value_fmt = getattr(comp.specs, "value_formatted", None) dielectric = getattr(comp.specs, "dielectric", None) + c_nom = getattr(comp.specs, "value_farads", None) # Operating voltage: max non-zero voltage among connected nets op_voltage: float | None = None @@ -107,6 +160,10 @@ def build_derating_table(graph: DesignGraph) -> list[dict]: net_minus = by_v[0][0] net_plus = by_v[-1][0] + factor = dc_bias_remaining(dielectric, op_voltage, rated_v) + c_eff = (c_nom * factor) if (c_nom is not None and factor is not None) else None + c_eff_fmt = _format_value(c_eff, "F") if c_eff is not None else None + rows.append({ "designator": comp.reference, "mpn": comp.mpn, @@ -117,6 +174,12 @@ def build_derating_table(graph: DesignGraph) -> list[dict]: "net_plus": net_plus, "net_minus": net_minus, "dielectric_category": _dielectric_category(comp.component_subtype, dielectric), + "dielectric": dielectric, + "c_nominal_f": c_nom, + "dc_bias_factor": factor, + "c_eff_f": c_eff, + "c_eff_formatted": c_eff_fmt, + "dc_bias_model": "stima" if factor is not None else None, }) rows.sort(key=lambda r: natural_sort_key(r["designator"])) diff --git a/backend/pinscopex/eval_report.py b/backend/pinscopex/eval_report.py index 4cf4c5e..8c47c89 100644 --- a/backend/pinscopex/eval_report.py +++ b/backend/pinscopex/eval_report.py @@ -21,6 +21,7 @@ from backend.pinscopex.passive_rail_check import ( check_supply_decoupling, ) from backend.pinscopex.bom_match_check import check_bom_schematic_match +from backend.pinscopex.hf_coverage_check import check_hf_decoupling_coverage class EvalScores(BaseModel): @@ -81,6 +82,7 @@ def run_deterministic_on_graph(graph: DesignGraph) -> list[Finding]: out.extend(check_i2c_pullups(graph, cmap)) out.extend(check_reset_pullups(graph, cmap)) out.extend(check_bom_schematic_match(graph.schematic_fields, graph.bom_fields)) + out.extend(check_hf_decoupling_coverage(graph, cmap)) return out diff --git a/backend/pinscopex/hf_coverage_check.py b/backend/pinscopex/hf_coverage_check.py new file mode 100644 index 0000000..380b5cb --- /dev/null +++ b/backend/pinscopex/hf_coverage_check.py @@ -0,0 +1,109 @@ +"""HF decoupling coverage — bulk without a small ceramic. + +Without a switching frequency this does not invent a Z(f) target. +INFO only: HF coverage depends on a ~100 nF close to the pin. +""" + +from __future__ import annotations + +from backend.pinscopex.models import ComponentType, DesignGraph, Finding, NetType +from backend.pinscopex.passive_rail_check import ( + _cap_farads, + _is_ground_net, + _is_ic_supply_pin, + _is_nc_net, + _is_regulator_output_pin, + _pin_label, +) +from backend.pinscopex.validate import _match_constraints + +_BULK_MIN_F = 1e-6 +_HF_MAX_F = 1e-6 +_HF_MIN_F = 1e-9 + + +def _esl_hint(footprint: str) -> str: + fp = (footprint or "").upper() + if "0402" in fp: + return "typical ESL ~0.4 nH (0402 stima)" + if "0603" in fp: + return "typical ESL ~0.6 nH (0603 stima)" + if "0805" in fp: + return "typical ESL ~0.8 nH (0805 stima)" + return "ESL depends on package (stima)" + + +def _valued_gnd_caps(graph: DesignGraph, net_name: str) -> list[tuple[str, float]]: + out: list[tuple[str, float]] = [] + unknown = False + for ref in graph.capacitors_on_net(net_name): + cap = graph.components[ref] + others = {n for n in cap.pins.values() if n != net_name} + if not any(_is_ground_net(graph, n) for n in others): + continue + farads = _cap_farads(cap) + if farads is None: + unknown = True + continue + out.append((ref, farads)) + if unknown: + return [] + return out + + +def check_hf_decoupling_coverage( + graph: DesignGraph, + constraints_map: dict, +) -> list[Finding]: + findings: list[Finding] = [] + seen: set[str] = set() + for ref, comp in sorted(graph.components.items()): + if comp.component_type != ComponentType.IC: + continue + cons = _match_constraints(comp.mpn or comp.value, constraints_map) + for pin_num, net_name in sorted(comp.pins.items(), key=lambda x: str(x[0])): + if net_name in seen or _is_nc_net(net_name): + continue + is_rail = _is_ic_supply_pin(graph, cons, pin_num, net_name) or ( + _is_regulator_output_pin(cons, pin_num) + ) + if not is_rail: + continue + net = graph.nets.get(net_name) + if net and net.net_type == NetType.GROUND: + continue + seen.add(net_name) + caps = _valued_gnd_caps(graph, net_name) + if not caps: + continue + has_bulk = any(c >= _BULK_MIN_F for _, c in caps) + has_hf = any(_HF_MIN_F <= c < _HF_MAX_F for _, c in caps) + if not (has_bulk and not has_hf): + continue + bulk_ref = next(r for r, c in caps if c >= _BULK_MIN_F) + fp = graph.components[bulk_ref].footprint + pin_label = _pin_label(cons, pin_num, net_name) + findings.append(Finding( + designator=ref, + mpn=comp.mpn or "", + aspect="decoupling", + source="hf_coverage_check", + status="INFO", + finding=( + f"{ref} net '{net_name}' ({pin_label}) has bulk capacitance " + f"but no ~100 nF ceramic for HF." + ), + why=( + f"Parallel Z(f) of large C is inductive above a few hundred " + f"kHz ({_esl_hint(fp)}). Without f_sw this is not an Ω target." + ), + recommendation=( + f"Add a 10–100 nF ceramic from '{net_name}' to ground near " + f"{ref}, in parallel with the bulk cap." + ), + reference="netlist topology (stima)", + net=net_name, + pins=[f"{ref}.{pin_num}"], + rule_id="PS-ESR-001", + )) + return findings diff --git a/backend/services/validation.py b/backend/services/validation.py index 694031a..5c44cd1 100644 --- a/backend/services/validation.py +++ b/backend/services/validation.py @@ -50,6 +50,7 @@ from backend.pinscopex.passive_rail_check import ( check_supply_decoupling, ) from backend.pinscopex.bom_match_check import check_bom_schematic_match +from backend.pinscopex.hf_coverage_check import check_hf_decoupling_coverage TRACE_VERSION = 1 @@ -74,6 +75,7 @@ def _run_deterministic_checks( ("bom_match_check", lambda: check_bom_schematic_match( graph.schematic_fields, graph.bom_fields, )), + ("hf_coverage_check", lambda: check_hf_decoupling_coverage(graph, constraints_map)), ): try: out.extend(fn()) diff --git a/frontend/content/changelog.md b/frontend/content/changelog.md index f6e0e4d..b4c46a8 100644 --- a/frontend/content/changelog.md +++ b/frontend/content/changelog.md @@ -2,6 +2,14 @@ What's new in Pinscope. +## 2.13.0 — 2026-09-10 — DC-bias C_eff stima + +The derating table now shows an effective capacitance under DC bias for C0G/X7R/X5R ceramics. It is labelled *stima* — not a vendor lot curve. + +- [New] `C_eff` column from an empirical V/Vrated table. Tantalum/electrolytic and unknown dielectrics are left blank. +- [Improved] C0G/NP0 stays at nominal C; X7R at 50% of rated V is about 70% of C. +- [New] Bulk C without a ~100 nF ceramic is `PS-ESR-001` INFO (no invented Z(f) target). + ## 2.12.0 — 2026-09-10 — Pull-up sizing and LDO Cout Deterministic schema checks now size I2C pull-ups, flag NRST pull-downs, and look at LDO VOUT capacitance — still WARNING, never a invented datasheet µF ERROR. diff --git a/frontend/src/app/(app)/project/[id]/page.tsx b/frontend/src/app/(app)/project/[id]/page.tsx index 07029a8..f455d59 100644 --- a/frontend/src/app/(app)/project/[id]/page.tsx +++ b/frontend/src/app/(app)/project/[id]/page.tsx @@ -751,6 +751,9 @@ function DeratingTable({ {failCount} fail )} +
+ C_eff is an empirical DC-bias stima (C0G/X7R/X5R), not a Murata lot curve. +