component-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseComponent Search (LCSC + easyeda2kicad)
元件搜索(LCSC + easyeda2kicad)
Find and add component packages to a Zener project without relying on a private registry. The pipeline is:
MPN ──► LCSC C-number ──► easyeda2kicad ──► .kicad_sym + .kicad_mod + .step ──► Zener wrapper (.zen)Use this workflow any time you need a part that isn't already in the workspace tree or covered by stdlib generics (, , , , …).
components/@stdlib/generics/Resistor.zenCapacitor.zenLed.zenThermistor.zen无需依赖私有注册表,即可在Zener项目中查找并添加元件封装。流程如下:
MPN ──► LCSC C编号 ──► easyeda2kicad ──► .kicad_sym + .kicad_mod + .step ──► Zener封装文件(.zen)当你需要的元件不在工作区目录树中,也未被stdlib泛型(、、、等)覆盖时,可使用此工作流。
components/@stdlib/generics/Resistor.zenCapacitor.zenLed.zenThermistor.zenHard Stop Before Manual Creation
手动创建前的强制检查
If LCSC has no entry for the MPN, or fails on the resolved C-number, don't fall back to hand-drawing a symbol/footprint silently. Report what failed, offer manual creation as an option, and get explicit user confirmation.
easyeda2kicad如果LCSC中没有该MPN的条目,或者解析对应的C编号失败,请勿直接手动绘制符号/封装。请报告失败原因,将手动创建作为可选方案,并获得用户的明确确认。
easyeda2kicadSearch Priority
搜索优先级
Always search in this order. Move down only when the higher tier doesn't apply.
- Workspace tree —
components/orglobfor the MPN. If the part is already imported, reuse it viafinder.Module("./components/<Mfr>/<MPN>/<MPN>.zen") - stdlib generics — for plain R, C, L, LED, diode, NPN/PNP, MOSFET, thermistor: use the generic, never import a vendor part.
- LCSC + easyeda2kicad — for ICs, modules, connectors, crystals, anything with a specific MPN.
请始终按照以下顺序进行搜索。仅当更高优先级的选项不适用时,才向下选择。
- 工作区目录树 — 使用
components/或glob查找MPN。如果元件已导入,请通过finder复用。Module("./components/<Mfr>/<MPN>/<MPN>.zen") - stdlib泛型 — 对于普通电阻(R)、电容(C)、电感(L)、LED、二极管、NPN/PNP三极管、MOSFET、热敏电阻:使用泛型元件,切勿导入供应商特定元件。
- LCSC + easyeda2kicad — 适用于IC、模块、连接器、晶振等带有特定MPN的元件。
Step 1 — MPN → LCSC C-number
步骤1 — MPN → LCSC C编号
LCSC parts have a numeric ID. easyeda2kicad needs that ID, not the MPN. Use the agent's web tools:
Cxxxxxxweb_search query="<MPN> site:lcsc.com"
read_web_page url=<top LCSC product page> objective="Find the LCSC C-number (e.g. C25804) and confirm package."Tips:
- LCSC product URLs look like — the trailing
https://www.lcsc.com/product-detail/.../C25804.htmlbeforeCxxxxxis the C-number..html - The product page also lists package, datasheet, stock, and price — capture these for the user.
- Some MPNs map to multiple C-numbers (different reels, suffixes, manufacturers). Pick the one that matches the requested package and shows real stock.
- If no LCSC hit, try the base MPN family (drop ,
-TR, reel/packaging suffixes).-R7
When the user supplies a C-number directly, skip this step.
LCSC元件带有数字格式的 ID。easyeda2kicad需要该ID,而非MPN。请使用Agent的网页工具:
Cxxxxxxweb_search query="<MPN> site:lcsc.com"
read_web_page url=<LCSC顶级产品页面> objective="查找LCSC C编号(例如C25804)并确认封装类型。"小贴士:
- LCSC产品URL格式为—
https://www.lcsc.com/product-detail/.../C25804.html之前的末尾.html即为C编号。Cxxxxx - 产品页面还会列出封装类型、 datasheet、库存和价格 — 请为用户收集这些信息。
- 部分MPN对应多个C编号(不同卷装、后缀、制造商)。请选择与请求封装匹配且有实际库存的编号。
- 如果未找到LCSC结果,尝试使用基础MPN系列(去掉、
-TR等卷装/包装后缀)。-R7
如果用户直接提供了C编号,可跳过此步骤。
Step 2 — Import via easyeda2kicad
步骤2 — 通过easyeda2kicad导入
Resolve the manufacturer and a clean MPN slug first (no spaces, replace with ). Pick a target package directory under .
/_components/<Manufacturer>/<MPN>/bash
mkdir -p components/<Manufacturer>/<MPN>
cd components/<Manufacturer>/<MPN>
easyeda2kicad --full --lcsc_id=Cxxxxx --output <MPN> --overwriteThis writes:
- — symbol library (single symbol)
<MPN>.kicad_sym - — footprint, inside a
<MPN>.pretty/<something>.kicad_modfolder.pretty - — 3D model
<MPN>.3dshapes/<something>.{wrl,step}
Flatten the footprint so the Zener wrapper can reference it as a single file next to the :
.zenbash
mv <MPN>.pretty/*.kicad_mod ./<MPN>.kicad_mod
rmdir <MPN>.pretty(Keep as a folder — references the 3D model by relative path inside it.)
<MPN>.3dshapes/.kicad_modIf the user wants to skip the 3D model for size, drop and use . Note that does not require a 3D model to build.
--full--symbol --footprintpcb首先解析制造商信息和整洁的MPN标识(无空格,将替换为)。在下选择目标封装目录。
/_components/<Manufacturer>/<MPN>/bash
mkdir -p components/<Manufacturer>/<MPN>
cd components/<Manufacturer>/<MPN>
easyeda2kicad --full --lcsc_id=Cxxxxx --output <MPN> --overwrite此命令会生成:
- — 符号库(单个符号)
<MPN>.kicad_sym - — 封装,位于
<MPN>.pretty/<something>.kicad_mod文件夹内.pretty - — 3D模型
<MPN>.3dshapes/<something>.{wrl,step}
扁平化封装结构,以便Zener封装文件可以在旁引用单个文件:
.zenbash
mv <MPN>.pretty/*.kicad_mod ./<MPN>.kicad_mod
rmdir <MPN>.pretty(保留文件夹 — 会通过相对路径引用其中的3D模型。)
<MPN>.3dshapes/.kicad_mod如果用户希望为节省空间跳过3D模型,可去掉参数,使用。注意构建不需要3D模型。
--full--symbol --footprintpcbStep 3 — Generate the Zener wrapper
步骤3 — 生成Zener封装文件
Use the bundled generator script to turn the imported into a starter :
.kicad_sym.zenbash
python3 <SKILL_DIR>/scripts/zener-wrap.py \
--kicad-sym components/<Manufacturer>/<MPN>/<MPN>.kicad_sym \
--footprint <MPN>.kicad_mod \
--mpn <MPN> \
--manufacturer "<Manufacturer>" \
--output components/<Manufacturer>/<MPN>/<MPN>.zenThe generator parses the and emits a skeleton with:
.kicad_sym.zen- top docstring (MPN, manufacturer, package — fill in description by hand)
- /
mpnconfigsmanufacturer - one per pin, classified as
io(),Power, or genericGroundby nameNet - with the
Component(...)dict mapping the original KiCad pin names to those iospins=
After generation, read the file and clean it up by hand:
- Group related ios (split power, signal, control bundles).
- Rename ios to integrator-facing names where it improves clarity (→
+IN_A).IN_POS_A - Add to every
voltage="..."io per the datasheet.Power - Replace with
Net/Analog/ typed interfaces fromDigitalwhere appropriate.@stdlib/interfaces.zen - Remove pins from the
no_connectdict — leave them out, don't expose as ios.pins= - Drop the auto-generated docstring and replace with a short, integrator-facing one (one paragraph: what it is, where it's used, key constraint).
See for the full style rules. See if you want to grow the wrapper into a richer reusable design with surrounding circuitry.
idiomatic-zenerreference-design使用内置的生成器脚本,将导入的转换为初始文件:
.kicad_sym.zenbash
python3 <SKILL_DIR>/scripts/zener-wrap.py \
--kicad-sym components/<Manufacturer>/<MPN>/<MPN>.kicad_sym \
--footprint <MPN>.kicad_mod \
--mpn <MPN> \
--manufacturer "<Manufacturer>" \
--output components/<Manufacturer>/<MPN>/<MPN>.zen生成器会解析并输出一个框架,包含:
.kicad_sym.zen- 顶部文档字符串(MPN、制造商、封装类型 — 需手动补充描述)
- /
mpn配置项manufacturer - 每个引脚对应一个,根据引脚名称分类为
io()、Power或通用GroundNet - 带有
Component(...)字典,将原始KiCad引脚名称映射到对应的iopins=
生成后,请手动阅读并清理文件:
- 分组相关的io(拆分电源、信号、控制组)。
- 重命名io以提高清晰度(如→
+IN_A)。IN_POS_A - 根据datasheet为每个io添加
Power属性。voltage="..." - 适当使用中的
@stdlib/interfaces.zen/Analog或类型化接口替换Digital。Net - 从字典中移除
pins=引脚 — 不要将其暴露为io。no_connect - 删除自动生成的文档字符串,替换为面向集成人员的简短描述(一段文字:元件用途、适用场景、关键约束)。
完整的样式规则请参考。如果希望将封装扩展为包含周边电路的可复用设计,请参考。
idiomatic-zenerreference-designStep 4 — Workspace manifest
步骤4 — 工作区清单
The new component package needs a so the workspace can resolve it. Create:
pcb.tomltoml
undefined新元件包需要文件,以便工作区解析。创建:
pcb.tomltoml
undefinedcomponents/<Manufacturer>/<MPN>/pcb.toml
components/<Manufacturer>/<MPN>/pcb.toml
[package]
name = "<MPN>"
description = "<one-line description>"
If the workspace `pcb.toml` declares `members = [..., "components/*", ...]` (most do), the package is auto-discovered. Verify with:
```bash
pcb build components/<Manufacturer>/<MPN>Fix any errors before instantiating from a board.
[package]
name = "<MPN>"
description = "<单行描述>"
如果工作区的`pcb.toml`声明了`members = [..., "components/*", ...]`(大多数情况如此),则该包会被自动发现。可通过以下命令验证:
```bash
pcb build components/<Manufacturer>/<MPN>在从电路板实例化元件前,请修复所有错误。
Step 5 — Use it
步骤5 — 使用元件
python
MyPart = Module("./components/<Manufacturer>/<MPN>/<MPN>.zen")
MyPart(
name="U1",
VDD=vdd_3v3,
GND=gnd,
# ...
)python
MyPart = Module("./components/<Manufacturer>/<MPN>/<MPN>.zen")
MyPart(
name="U1",
VDD=vdd_3v3,
GND=gnd,
# ...
)Verifying Sourcing with pcb bom
pcb bom使用pcb bom
验证采购信息
pcb bomOnce the part is wired into a board, sanity-check sourcing:
bash
pcb bom boards/<Board>/<Board>.zen -f jsonFor an easyeda2kicad-imported part, the BOM will pick up the MPN you set in the wrapper ( config default). LCSC stock is the same source easyeda2kicad pulled from, so the you used is your sourcing record — capture it in the docstring or a comment for traceability.
mpn=Cxxxxx.zen将元件接入电路板后,请检查采购信息是否正确:
bash
pcb bom boards/<Board>/<Board>.zen -f json对于通过easyeda2kicad导入的元件,BOM会获取你在封装文件中设置的MPN(配置默认值)。LCSC库存与easyeda2kicad获取的来源一致,因此你使用的即为采购记录 — 请将其记录在文档字符串或注释中以便追溯。
mpn=Cxxxxx.zenGenerator Script
生成器脚本
Path:
<SKILL_DIR>/scripts/zener-wrap.pyUsage:
bash
python3 zener-wrap.py \
--kicad-sym path/to/<MPN>.kicad_sym \
--footprint <MPN>.kicad_mod \
--mpn <MPN> \
--manufacturer "<Manufacturer>" \
--output path/to/<MPN>.zen \
[--datasheet docs/<MPN>.pdf] # optionalPin classification rules:
- ,
GND,VSS,VEE,AGND,DGND→V-Ground - ,
VCC,VDD,VPP,VBUS,VS,V+,AVDD,DVDD,VIN→VOUTPower - everything else →
Net
The script never throws on unusual pin names — it sanitizes any string into a valid Zener identifier and falls back to for unnamed pins.
PIN_<num>路径:
<SKILL_DIR>/scripts/zener-wrap.py用法:
bash
python3 zener-wrap.py \
--kicad-sym path/to/<MPN>.kicad_sym \
--footprint <MPN>.kicad_mod \
--mpn <MPN> \
--manufacturer "<Manufacturer>" \
--output path/to/<MPN>.zen \
[--datasheet docs/<MPN>.pdf] # 可选引脚分类规则:
- 、
GND、VSS、VEE、AGND、DGND→V-Ground - 、
VCC、VDD、VPP、VBUS、VS、V+、AVDD、DVDD、VIN→VOUTPower - 其他所有引脚 →
Net
脚本不会因异常引脚名称报错 — 它会将任何字符串清理为有效的Zener标识符,并对未命名引脚使用作为 fallback。
PIN_<num>Common Issues
常见问题
- easyeda2kicad: HTTP 404 on C-number — wrong C-number, or the part has been delisted. Re-search LCSC or pick the alternate-source listing.
- Pin names look like (with overbar markup) — KiCad wraps inverted pin names in
~{NAME}. The generator strips the markup for the io identifier but preserves the original string in the~{...}dict so the symbol still matches.pins= - Footprint references a 3D model that wasn't downloaded — happens with only. Either re-run with
--symbol --footprint, or edit the--fullto remove the.kicad_modblock.(model ...) - Symbol uses /
~/ spaces in pin names — the generator handles these. If the resulting Zener identifier is awkward, rename the io by hand and update the#mapping to keep the original KiCad name on the right.pins=
- easyeda2kicad:C编号返回HTTP 404 — C编号错误,或元件已下架。重新搜索LCSC或选择替代来源的条目。
- 引脚名称显示为(带有上划线标记) — KiCad会将反相引脚名称用
~{NAME}包裹。生成器会为io标识符去除标记,但在~{...}字典中保留原始字符串,以确保符号匹配。pins= - 封装引用未下载的3D模型 — 仅使用参数时会发生此问题。可重新运行命令并添加
--symbol --footprint参数,或编辑--full文件移除.kicad_mod块。(model ...) - 符号引脚名称包含/
~/ 空格 — 生成器会处理这些情况。如果生成的Zener标识符不够直观,请手动重命名io并更新#映射,确保右侧保留原始KiCad名称。pins=