TVS候选表最常见的程序错误,是把VC、IPP或PPPM当成普通数值排序。两个数字如果对应不同波形、温度或测试电流,排序结果没有工程意义。
下面用Python标准库读取CSV。示例数据全部为合成字段,不代表任何实际品牌或型号。
CSV格式
candidates.csv:
part,vrwm_v,vc_v,vc_at_ipp_a,waveform,temp_c,value_type
DEMO-A,24,38.0,10.0,8/20us,25,max
DEMO-B,24,36.0,8.0,8/20us,25,max
DEMO-C,24,32.0,2.0,10/1000us,25,max
DEMO-D,24,35.0,10.0,8/20us,25,typ
如果直接按vc_v升序,DEMO-C会排第一。但它的波形和电流都不同;DEMO-D又是典型值,不能和最大值混在一起。
检查脚本
from __future__ import annotations
import csv
import sys
from collections import defaultdict
REQUIRED = {
"part", "vrwm_v", "vc_v", "vc_at_ipp_a",
"waveform", "temp_c", "value_type"
}
def read_rows(path: str) -> list[dict[str, str]]:
with open(path, newline="", encoding="utf-8-sig") as file:
reader = csv.DictReader(file)
missing = REQUIRED - set(reader.fieldnames or [])
if missing:
raise ValueError(f"missing columns: {sorted(missing)}")
rows = list(reader)
if not rows:
raise ValueError("candidate table is empty")
return rows
def condition_key(row: dict[str, str]) -> tuple[str, float, float, str]:
return (
row["waveform"].strip().lower(),
float(row["vc_at_ipp_a"]),
float(row["temp_c"]),
row["value_type"].strip().lower(),
)
def group_comparable(rows: list[dict[str, str]]):
groups: dict[tuple, list[dict[str, str]]] = defaultdict(list)
for row in rows:
groups[condition_key(row)].append(row)
return groups
def main(path: str) -> int:
rows = read_rows(path)
groups = group_comparable(rows)
if len(groups) > 1:
print("STOP: VC rows use different test conditions.")
for key, items in groups.items():
names = ", ".join(item["part"] for item in items)
print(f" condition={key}: {names}")
print("Compare VC only inside one condition group.")
return 2
ranked = sorted(rows, key=lambda row: float(row["vc_v"]))
for row in ranked:
print(row["part"], row["vc_v"])
return 0
if __name__ == "__main__":
raise SystemExit(main(sys.argv[1]))
运行:
python check_tvs.py candidates.csv
脚本会以状态码2退出,并打印四组测试条件,而不是生成一个误导性的VC排行榜。
为什么条件键要包含四项
waveform:8/20 μs与10/1000 μs不能直接混排;vc_at_ipp_a:VC随测试电流变化;temp_c:温度会影响器件行为和降额;value_type:典型值不能当成最大保证值。
真实项目还可以加入脉冲公差、封装、极性、数据手册版本和测试方法。
VRWM也不能只比较大小
脚本中vrwm_v尚未参与排序,因为VRWM首先是约束:候选值应覆盖线路最高持续电压。它不是越高越好。提高VRWM可能同时抬高VBR或VC,保护窗口需要重新核对。
可以先加入项目配置:
BUS_MAX_CONTINUOUS_V = 27.0 # 仅为演示值
eligible = [
row for row in rows
if float(row["vrwm_v"]) >= BUS_MAX_CONTINUOUS_V
]
生产系统不应把演示值写死,而应从经过批准的需求文件读取。
程序应该输出“待补证据”
缺少波形、温度或工作点时,不要填0,也不要猜。建议状态:
reject:已知不满足正常工作窗口;needs_evidence:字段缺失或条件不可比较;candidate:可以进入实板验证。
最终批准仍要由规格书、PCB布局、样机和测试结果完成。ASIM阿赛姆产品数据进入候选表时也使用同一规则,不能因为是自有品牌就跳过条件校验。
参考资料: