关于 matlab-integrate-pcb-circuit
这项技能帮助 MATLAB 用户将 RF PCB 组件组合成电路并分析其互连行为,涵盖端口级联、集总元件加载和 S 参数导出。也介绍与天线阵列及信号完整性分析的衔接方式。
主要功能
- 01使用 `pcbcascade` 级联 PCB 组件
- 02通过 `pcbElement` 接入 RF 电路
- 03为内部端口连接集总元件
- 04计算并导出 Touchstone S 参数
- 05衔接天线阵列与信号完整性分析
适用场景
- 01组合多个滤波器或传输线级
- 02为 PCB 结构加载电容或电阻
- 03将计算所得 S 参数导入其他仿真流程
- 04分析 PCB 馈电网络与天线阵列的集成
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ matlab/ matlab-agentic-toolkit --skill matlab-integrate-pcb-circuit安装后在 Claude Code 中输入/matlab-integrate-pcb-circuit确认已加载。
附带文件manifest.yaml
详细介绍
级联和集成 RF PCB 组件
适用场景
- 使用
pcbcascade将两个或多个 PCB 组件首尾级联 - 使用
pcbElement将 PCB 组件封装为电路元件,以供 RF Toolbox 使用 - 使用集总元件(变容二极管、终端)加载内部端口
- 通过
rfwrite将 S 参数导出为 Touchstone 文件 - 将 RF PCB 馈电网络与天线阵列集成
- 与 Signal Integrity Toolbox 对接,进行眼图分析
不适用场景
- 设计单个滤波器、耦合器或传输线——请使用相应的设计技能
- 从头构建自定义 PCB 几何结构——请使用
matlab-assemble-pcb-layout - 对单个组件进行 EM 分析——请使用
matlab-analyze-em - 设置材料——请使用
matlab-manage-pcb-material
典型工作流
- **之前:**使用设计技能(
matlab-design-pcb-filter、matlab-design-pcb-coupler等)或matlab-analyze-em,创建并验证单个组件 - **此技能:**级联组件、添加集总元件、导出 Touchstone,并对接眼图分析
- **之后:**使用
matlab-write-pcb-layout将最终设计导出为 Gerber;或将 S 参数馈入 Signal Integrity Toolbox 工作流
快速参考
| 任务 | 代码 |
|---|---|
| 级联两个组件 | out = pcbcascade(comp1, comp2) |
| 使用矩形板级联 | out = pcbcascade(comp1, comp2, 'RectangularBoard', true) |
| 交互式级联 | pcbcascade(comp1, comp2, 'Interactive', true) |
| 创建电路元件 | elem = pcbElement(comp) |
| 设置分析端口 | elem.AnalysisPorts = {1, 2} |
| 附加集总元件 | elem.PortNumber = {3, 4}; elem.PortValue = {capacitor(2.2e-12), resistor(50)} |
| 添加到 RF 电路 | add(ckt, [1 2 0 0], elem) |
| 导出为 Touchstone | rfwrite(sp, 'comp.s2p') |
| 使用选项导出 | rfwrite(sp, 'comp.s2p', FrequencyUnit='GHz', Format='DB') |
pcbcascade — 端到端连接组件
pcbcascade 函数将两个 RF PCB 组件的端口彼此连接,生成一个用于全波分析的 pcbComponent。
基本级联
HPF = filterStub;
HPF.StubShort = [1 1 1 1 1];
HPF.Height = 0.508e-3;
% ... set HPF properties ...
LPF = filterStepImpedanceLowPass;
LPF.Height = 0.508e-3;
LPF = design(LPF, 7e9);
BPF = pcbcascade(LPF, HPF, "RectangularBoard", true);
show(BPF);
分析级联结果
freq = linspace(1e6, 12e9, 51);
sp = sparameters(BPF, freq, 'SweepOption', 'interp');
rfplot(sp);
RectangularBoard 选项
| 值 | 行为 |
|---|---|
true | 在级联布局周围创建一个矩形介质板 |
false(默认) | 使用组件几何结构的自然板形 |
交互式级联模式
用于可视化端口对齐:
pcbcascade(comp1, comp2, 'Interactive', true);
这会启动一个 GUI,供你直观地连接端口并调整间距。
多级级联
通过依次级联,将两个以上组件串接起来:
stage1 = design(filterStepImpedanceLowPass, 5e9);
stage2 = design(microstripLine, 5e9);
stage3 = design(filterStepImpedanceLowPass, 5e9);
% Match substrates — design() defaults differ across object types
stage2.Substrate = stage1.Substrate;
stage2.Height = stage1.Height;
stage2.Conductor = stage1.Conductor;
stage3.Substrate = stage1.Substrate;
stage3.Height = stage1.Height;
stage3.Conductor = stage1.Conductor;
% Cascade stage1 + stage2, then result + stage3
intermediate = pcbcascade(stage1, stage2, 'RectangularBoard', true);
final = pcbcascade(intermediate, stage3, 'RectangularBoard', true);
show(final);
级联要求
- 两个组件必须共用相同的基板(
Height、Substrate) - 连接接口处的端口线宽应一致
- 组件在端口边缘处连接(comp1 的端口 2 连接到 comp2 的端口 1)
pcbElement — RF Toolbox 电路集成
pcbElement 将 RF PCB 组件封装为可在 RF Toolbox circuit 框架中使用的电路元件,从而支持分布参数与集总参数混合建模。
基本用法
comp = design(couplerBranchline, 5e9);
elem = pcbElement(pcbComponent(comp));
S = sparameters(elem, linspace(3e9, 7e9, 51), 'SweepOption', 'interp');
rfplot(S);
行为模型与全波模型
% Behavioral model (fast, uses analytic approximation)
elem = pcbElement(comp, 'Behavioral', true);
% Full-wave solve (accurate, uses MoM)
elem = pcbElement(comp, 'Behavioral', false);
并非所有组件都支持行为模型模式。如果不支持,系统会发出警告并自动使用全波模式。
将 pcbElement 添加到电路
ckt = circuit;
c1 = interdigitalCapacitor;
c2 = interdigitalCapacitor('NumFingers', 3);
p = pcbElement(c2, 'Behavioral', false);
add(ckt, [1 2 0 0], c1); % Default pcbElement created automatically
add(ckt, [2 3 0 0], p);
setports(ckt, [1 0], [3 0]);
S = sparameters(ckt, 8e9);
使用内部端口进行分布参数与集总参数混合建模
pcbElement 最强大的用途是将集总元件(电容器、电阻器、电感器)连接到 EM 结构的内部端口。这可用于对带变容二极管的可调滤波器、负载谐振器和偏置 T 网络进行建模。
概念
- 在 PCB 上将额外的
FeedLocations定义为内部端口对 - 使用
pcbElement封装 - 设置
AnalysisPorts(用于提取 S 参数的外部 I/O 端口) - 设置
PortNumber(要加载的内部端口索引) - 设置
PortValue(连接到这些端口的集总元件)
模式:带终端的负载耦合器
% Start with a 4-port coupler
comp = design(couplerRatrace, 5e9);
pcb = pcbComponent(comp);
% Create pcbElement
elem = pcbElement(pcb);
% Ports 1,2 are external I/O (for S-parameter extraction)
elem.AnalysisPorts = {1, 2};
% Ports 3,4 are loaded with lumped elements
elem.PortNumber = {3, 4};
elem.PortValue = {resistor(50), resistor(50)};
% Analyze the 2-port network with internal loads
S = sparameters(elem, linspace(3e9, 7e9, 51), 'SweepOption', 'interp');
rfplot(S);
模式:使用变容二极管的可调滤波器
% Design a filter with extra internal feed points for varactors
pcb = pcbComponent;
% ... build custom filter geometry with internal feed pads ...
% FeedLocations rows 1,2 = external I/O
% FeedLocations rows 3,4 and 5,6 = varactor pads (internal port pairs)
pcb.FeedLocations = [x1 y1 1 3; % Port 1: input
x2 y2 1 3; % Port 2: output
x3 y3 1 3; % Port 3: varactor pad A+
x4 y4 1 3; % Port 4: varactor pad A-
x5 y5 1 3; % Port 5: varactor pad B+
x6 y6 1 3]; % Port 6: varactor pad B-
elem = pcbElement(pcb);
elem.AnalysisPorts = {1, 2};
elem.PortNumber = {{3,4}, {5,6}};
elem.PortValue = {capacitor(2.2e-12), capacitor(2.2e-12)};
S = sparameters(elem, linspace(1e9, 10e9, 51), 'SweepOption', 'interp');
rfplot(S);
支持的 PortValue 类型
| 类型 | 示例 |
|---|---|
resistor | resistor(50) |
capacitor | capacitor(2.2e-12) |
inductor | inductor(1e-9) |
| S 参数文件 | 'component.s2p' |
PortNumber 格式
% Single-port loads (each port terminated individually)
elem.PortNumber = {3, 4};
elem.PortValue = {resistor(50), resistor(50)};
% Port-pair loads (2-port element connected across a pair)
elem.PortNumber = {{3,4}, {5,6}};
elem.PortValue = {capacitor(2.2e-12), nport('varactor.s2p')};
天线集成
将 RF PCB 馈电网络与 Antenna Toolbox 阵列集成。
企业式功分器 + 微带贴片阵列
% Design corporate power divider
pdc = powerDividerCorporate;
pdc = design(pdc, 5e9);
pdc.NumOutputPorts = 4;
pdc.PortSpacing = physconst('lightspeed') / 5e9;
% Design patch antenna
ant = patchMicrostripInsetfed;
ant.Substrate = dielectric('Teflon');
ant = design(ant, 5e9);
% Convert to pcbStack for shape extraction
pcbant = pcbStack(ant);
TopLayer = pcbant.Layers{1};
% Create linear array of patches
for i = 2:4
a = copy(TopLayer);
a = translate(a, [0, pdc.PortSpacing*(i-1), 0]);
TopLayer = TopLayer + a;
end
% Merge divider and antenna array into single pcbStack
pcbcomp = pcbComponent(pdc);
pcbant1 = pcbStack;
pcbant1.BoardShape = pcbcomp.BoardShape;
pcbant1.BoardThickness = pcbcomp.BoardThickness;
pcbant1.Layers = pcbcomp.Layers;
pcbant1.FeedDiameter = pcbcomp.FeedDiameter;
pcbant1.FeedLocations = pcbcomp.FeedLocations(1,:); % Keep only input port
% Combine top layers
pcbant1.Layers{1} = pcbant1.Layers{1} + TopLayer;
show(pcbant1);
pcb2D 截面与串扰
有关 pcb2D 截面分析、trace2D 设置、RLGC 提取、slice() 以及耦合走线之间的串扰,请参阅 matlab-design-pcb-transmission-line。
将 S 参数导出到 Touchstone 文件
使用 rfwrite 将计算出的 S 参数保存为 Touchstone 文件,以便在其他工具或仿真中重复使用。
基本导出
sp = sparameters(pcbComponent, freq, 'SweepOption', 'interp');
rfwrite(sp, 'component.s2p');
rfwrite 选项
| 选项 | 值 | 说明 |
|---|---|---|
FrequencyUnit | 'Hz'、'kHz'、'MHz'、'GHz' | 频率列的单位 |
Parameter | 'S'、'Y'、'Z' | 网络参数类型 |
Format | 'MA'、'DB'、'RI' | 幅度-角度、dB-角度、实部-虚部 |
ReferenceResistance | 标量(默认值为 50) | 以欧姆为单位的参考阻抗 |
rfwrite(sp, 'filter_2p4GHz.s2p', FrequencyUnit='GHz', Format='DB');
将 Touchstone 加载为 nport
n = nport('component.s2p');
% Use in any RF Toolbox circuit
add(ckt, [1 2], n);
rfwrite 会根据端口数量自动选择文件扩展名(.s2p、.s4p 等)。
高级集成模式
Nolen 矩阵波束成形
Nolen 矩阵通过级联支线耦合器和移相器来构建 N×N 波束成形网络。通过级联各个 RF PCB 组件进行构建:
coupler = design(couplerBranchline, fc);
ps = design(phaseShifter, fc, PhaseShift=90);
% Extract S-parameters for each, then cascade via circuit()
ckt = circuit;
add(ckt, [1 2 3 4], nport(sparameters(coupler, freq, 'SweepOption', 'interp')));
add(ckt, [3 5], nport(sparameters(ps, freq, 'SweepOption', 'interp')));
% ... build full N×N matrix
单脉冲比较器
X 波段单脉冲比较器使用四个 ratrace 耦合器生成和波束与差波束:
rr = design(couplerRatrace, fc);
S_rr = sparameters(rr, freq, 'SweepOption', 'interp');
% Build 4-coupler comparator network using circuit()
放大器匹配网络
使用微带线 T 形结和短截线创建输入/输出匹配网络,然后与放大器 S 参数级联:
% Build matching network as pcbComponent
tee = traceTee(Length=[L1, L2], Width=[W1, W2]);
pcb = pcbComponent(tee);
pcb.Substrate = dielectric("FR4");
S_match = sparameters(pcb, freq, 'SweepOption', 'interp');
% Load amplifier S-parameters and cascade
amp = nport('amplifier.s2p');
ckt = circuit;
add(ckt, [1 2 0 0], nport(S_match)); % Input match
add(ckt, [2 3 0 0], amp); % Amplifier
add(ckt, [3 4 0 0], nport(S_match)); % Output match
setports(ckt, [1 0], [4 0]);
S_total = sparameters(ckt, freq);
使用 Parallel Link Designer 分析 FEXT/NEXT
pcb2D 的全波 EM 结果可导出到 Signal Integrity Toolbox 进行系统级分析:
cs = pcb2D;
% ... configure traces, substrate
[r, l, g, c] = rlgc(cs, freq);
% Export to Parallel Link Designer for eye diagram analysis
通过 S 参数连接公式进行优化
搜索用于跨接间隙或加载内部端口的最佳集总元件时,针对每个候选值重新求解 EM 的速度过慢。更好的方法是只提取一次 N 端口 S 矩阵,然后使用 S 参数网络数学方法对元件值进行解析扫描。
模式:提取一次,解析扫描
% 1. Build 4-port structure (2 external + 2 internal ports at the gap)
pcb = pcbComponent;
% ... set up geometry with 4 feeds ...
freq = linspace(9e9, 11e9, 101);
S4 = sparameters(pcb, freq, 50, 'SweepOption', 'interp'); % Solve once
% 2. Partition the 4-port S-matrix into external (1,2) and internal (3,4)
S = S4.Parameters;
S11 = S(1:2, 1:2, :); S12 = S(1:2, 3:4, :);
S21 = S(3:4, 1:2, :); S22 = S(3:4, 3:4, :);
% 3. Sweep element impedance analytically (no EM re-solve)
Z0 = 50;
Zvals = linspace(1, 500, 1000); % Candidate impedances
bestS11 = 0; bestZ = NaN;
for k = 1:numel(Zvals)
Gamma_L = (Zvals(k) - Z0) / (Zvals(k) + Z0);
GammaM = Gamma_L * eye(2);
% S-parameter connection: S_ext = S11 + S12*GammaM*inv(I - S22*GammaM)*S21
for fi = 1:size(S,3)
Sext = S11(:,:,fi) + S12(:,:,fi) * GammaM / ...
(eye(2) - S22(:,:,fi) * GammaM) * S21(:,:,fi);
s11_dB = 20*log10(abs(Sext(1,1)));
if s11_dB < bestS11
bestS11 = s11_dB; bestZ = Zvals(k);
end
end
end
适用场景
| 场景 | 方法 |
|---|---|
| 扫描 R/L/C 值 | 提取一次 N 端口,进行解析扫描 |
| 少量离散元件选项 | 使用带 PortValue 的 pcbElement(每次都会重新求解) |
| 对最佳值进行最终验证 | 使用所选值的 pcbElement 进行全波确认 |
与每次迭代都重新求解 EM 相比,这项技术的速度快几个数量级——任务 8 在几秒钟内扫描了 1000 个阻抗值,而 EM 求解需要数小时。
注意事项
-
pcbcascade 基板匹配:两个组件的
Substrate、Height和Conductor必须完全相同。不同对象类型的design()默认值不同(例如,filterStepImpedanceLowPass默认使用自定义介质,而microstripLine默认使用 Teflon)。调用pcbcascade前,务必将一个组件的基板属性复制到另一个组件。 -
端口宽度匹配:级联时,comp1 输出端口的馈线宽度应与 comp2 输入端口的馈线宽度匹配。宽度不匹配会导致不符合实际情况的阻抗不连续。
-
pcbElement 端口顺序:
AnalysisPorts的索引必须是FeedLocations中定义的馈电索引的子集。AnalysisPorts中的端口 1 对应FeedLocations的第一行。 -
PortNumber 与 AnalysisPorts:
PortNumber中列出的端口会加载集总元件,因此不能用作外部分析端口。不要在AnalysisPorts和PortNumber中包含相同的端口索引。 -
行为模式可用性:并非所有目录对象都支持
Behavioral=true。行为模型是一种快速近似;最终设计验证时请使用Behavioral=false。 -
企业式功分器 + 天线组装:使用
+组合形状时,请确保它们在物理上重叠或接触。互不相连的形状会形成断开的几何结构,无法正确仿真。 -
filterStub 不支持 design():
filterStub不支持design()。请手动设置短截线尺寸。 -
pcbElement 的 Behavioral 默认值为 true:包装目录对象时,
Behavioral默认值为true(快速解析解)。如需全波精度,请显式设置Behavioral=false。 -
级联后的端口重新编号:
pcbcascade(comp1, comp2, portA, portB)会连接comp1:portA和comp2:portB,这两个端口会消失。剩余端口会重新编号:先列出 comp1 的剩余端口(按原顺序,跳过 portA),再列出 comp2 的剩余端口(跳过 portB)。例如:comp1 有端口 [1,2],comp2 有端口 [1,2,3]。pcbcascade(comp1, comp2, 2, 1)会生成组合端口:[comp1:1, comp2:2, comp2:3]。请务必使用show(combined)进行确认。 -
天线级联中的接地平面连续性:默认情况下,
pcbcascade不会合并接地平面。要获得连续接地平面,请使用'GroundFloodFill', true;对于微带馈电天线,这一点至关重要:pcbcascade(feed, ant, 2, 1, 'GroundFloodFill', true)。 -
SI 频率采样:对于宽带 SI 通道,至少使用 400 个频率点。频率点过少会导致时域转换(眼图)中出现伪影。
-
pcbcascade 不接受集总元件:
pcbcascade只能连接pcbComponent对象。要将 PCB 组件与集总resistor/capacitor/inductor元件组合,请使用circuit()对象:先用pcbElement包装 PCB 组件,再将 pcbElement 和集总元件通过节点连接添加到circuit,并调用setports()。示例:
pe = pcbElement(comp); pe.Name = 'txline';
C = capacitor(100e-12); C.Name = 'Cblock';
R = resistor(50); R.Name = 'Rterm';
ckt = circuit('modified');
add(ckt, [1 2], C); % Series DC block
add(ckt, [2 3], pe); % PCB element
add(ckt, [3 0], R); % Shunt termination
setports(ckt, [1 0], [3 0]);
S = sparameters(ckt, freq);
相关技能
matlab-design-pcb-filter— 用于级联的滤波器对象matlab-design-pcb-coupler— 用于级联的耦合器/功分器对象matlab-assemble-pcb-layout— 使用 pcbComponent 创建自定义几何结构matlab-analyze-em— S 参数提取和场分析
版权所有 2026 The MathWorks, Inc.