mcpField
M
matlab-design-pcb-filter

matlab-design-pcb-filter

github.com/matlab其他1.2k82 次安装1 天前更新
代码仓库

关于 matlab-design-pcb-filter

面向 MATLAB PCB 设计流程的 RF 滤波器设计技能,涵盖带通、低通、带阻及 SIW 等拓扑。它还提供从 S 参数测量数据提取耦合矩阵的方法,并说明滤波器选择与仿真前检查。

主要功能

  1. 01设计多种带通滤波器拓扑
  2. 02设计低通、带阻及陷波滤波器
  3. 03从 S 参数提取耦合矩阵
  4. 04按带宽、选择性和尺寸选型
  5. 05检查网格密度并计算 S 参数

适用场景

  1. 01按目标频率设计 PCB 滤波器
  2. 02从测量数据分析滤波器模型
  3. 03比较滤波器响应并调整结构

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-design-pcb-filter

安装后在 Claude Code 中输入/matlab-design-pcb-filter确认已加载。

附带文件manifest.yaml

详细介绍

设计 RF 滤波器

适用场景

  • 设计带通滤波器(耦合线、发夹式、开环、梳线、交指式、SIW)
  • 设计低通滤波器(阶梯阻抗式)
  • 设计带阻或陷波滤波器(脊线式、基于短截线)
  • 从测得的 S 参数数据中提取耦合矩阵(measuredFilter)
  • 根据带宽、选择性或尺寸要求选择滤波器拓扑

不适用场景

  • 设计用于阻抗控制的传输线 — 使用 matlab-design-pcb-transmission-line
  • 设计耦合器或分路器 — 使用 matlab-design-pcb-coupler
  • 设计无源元件(电感、电容、巴伦)— 使用 matlab-design-pcb-passive
  • 设置基板或导体材料 — 使用 matlab-manage-pcb-material
  • 设计完成后优化滤波器尺寸 — 使用 matlab-optimize-pcb-design

典型工作流

  1. 之前: matlab-manage-pcb-material — 设置基板和导体
  2. 此技能: 设计滤波器(目录对象或自定义几何结构)
  3. 检查网格/内存: memoryEstimate(obj, fc, 'RetainMesh', true) — 在开始完整求解前检查自动网格密度
  4. 之后: matlab-analyze-em — 验证 S 参数 → matlab-optimize-pcb-design — 调整尺寸 → matlab-write-pcb-layout — 导出 Gerber

快速参考 — 滤波器选择

滤波器对象类型极数最适用于
filterCoupledLine带通2–8通用微带 BPF
filterHairpin带通2–8紧凑型 BPF、折叠谐振器
filterOpenLoop带通4/6/8紧凑型准椭圆滤波器
filterCombline带通2–6窄带、高 Q
filterInterdigital带通2–8宽带、良好的阻带性能
filterStepImpedanceLowPass低通3–9分布式 LPF
filterStubLP/HP/BSN 个短截线灵活的短截线拓扑
filterSpurline带阻1–2紧凑型陷波滤波器
SIWFilter带通2–6PCB 内高 Q 波导
measuredFilter带通N从测量数据中提取模型

带通滤波器

耦合线滤波器
f = filterCoupledLine;
f = design(filterCoupledLine, 3e9);    % Design at 3 GHz
show(f);
sp = sparameters(f, linspace(1e9, 5e9, 101), 'SweepOption', 'interp');
rfplot(sp);

关键属性:FilterOrder、CoupledLineLength、CoupledLineWidth、CoupledLineSpacing、PortLineLength、PortLineWidth。

发夹式滤波器

采用折叠耦合线谐振器,实现紧凑尺寸:

f = design(filterHairpin, 3e9);
show(f);
memoryEstimate(f, 3e9, 'RetainMesh', true);  % Check mesh density before solving
sp = sparameters(f, linspace(1e9, 5e9, 101), 'SweepOption', 'interp');
rfplot(sp);

关键属性:FilterOrder、CoupledLineLength、CoupledLineWidth、CoupledLineSpacing、PortLineLength、PortLineWidth、Spacing、ResonatorOffset、FeedOffset。

切比雪夫响应

在 design() 中传入 FilterType 和 RippleFactor,以获得等波纹通带响应:

f = design(filterHairpin, 1.8e9, FBW=10, FilterType='Chebyshev', RippleFactor=0.5);

FilterType 选项:'Butterworth'(默认)、'Chebyshev'。FBW 用于设置分数带宽(%)。RippleFactor 用于设置通带波纹(dB,默认值为 0.5)— 仅适用于切比雪夫滤波器。

五阶发夹式滤波器
f = filterHairpin;
f.FilterOrder = 5;
f = design(f, 2.4e9);
show(f);
开环滤波器

采用交叉耦合实现准椭圆响应:

f = filterOpenLoop;
f.NumPoles = 6;
f.FeedOffset = 0.5e-3;
show(f);
sp = sparameters(f, linspace(1e9, 5e9, 101), 'SweepOption', 'interp');
rfplot(sp);

关键属性: NumPoles(4/6/8)、ResonatorLength、ResonatorWidth、SplitGap、GapHorizontal、GapVertical、FeedOffset、CoupledResonatorGap、QuadrupletGap、QuadrupletOffset。

梳线滤波器

短路谐振器,非常适合窄带应用。注意: filterCombline 没有 design 函数 — 请手动设置属性:

f = filterCombline;
f.FilterOrder = 3;
f.Height = 1.6e-3;
show(f);

关键属性: FilterOrder、ResonatorLength(标量或向量)、ResonatorWidth、ResonatorSpacing(标量或向量)、ResonatorOffset、FeedOffset、Capacitor(加载电容 — 梳线滤波器的特有属性)。

交指式滤波器

采用交替排列的短路谐振器,适用于宽带应用。注意: filterInterdigital 没有 design 函数 — 请手动设置属性:

f = filterInterdigital;
f.FilterOrder = 4;
f.Height = 1.6e-3;
show(f);
sp = sparameters(f, linspace(3e9, 7e9, 101), 'SweepOption', 'interp');
rfplot(sp);

关键属性: FilterOrder、ResonatorLength(标量或向量)、ResonatorWidth(标量或向量)、ResonatorSpacing(标量或向量)、ResonatorOffset、ViaDiameter(标量或向量 — 交指式滤波器的特有属性)、FeedOffset、IsShielded、Connector。

低通滤波器

阶梯阻抗低通滤波器
f = filterStepImpedanceLowPass;
f = design(filterStepImpedanceLowPass, 2.5e9);
show(f);
sp = sparameters(f, linspace(0.1e9, 5e9, 101), 'SweepOption', 'interp');
rfplot(sp);

主要属性:FilterOrder、HighZLineWidth、LowZLineWidth、HighZLineLength、LowZLineLength。

带阻/陷波滤波器

支节线滤波器

使用一侧耦合线段的紧凑型陷波器:

f = filterSpurline;
show(f);
sp = sparameters(f, linspace(1e9, 6e9, 51), 'SweepOption', 'interp');
rfplot(sp);

双支节线可实现更深的抑制:

f = filterSpurline;
f.LineType = 'Double';
show(f);

主要属性: LineType('Single'/'Double')、CoupledLineLength、CoupledLineWidth、CoupledLineSpacing、LineGap(耦合线与输出线之间的间隙——支节线滤波器的独有属性)、IsShielded、Connector。

短截线滤波器(开路/短路)

filterStub 对象支持开路短截线(带阻)和短路短截线(高通):

f = filterStub;
f.StubLength = [6e-3 6e-3 6e-3];
f.StubWidth = [0.5e-3 0.5e-3 0.5e-3];
f.StubOffsetX = [-6e-3 0 6e-3];
f.StubShort = [0 0 0];         % 0=open (bandstop), 1=short (highpass)
f.StubDirection = [0 0 0];     % 0=below, 1=above trace
f.SeriesLineWidth = 1.8e-3;
f.SeriesLineLength = 12e-3;
show(f);

主要属性: StubLength(向量)、StubWidth(向量)、StubFeedOffsetX(向量)、StubShort(0=开路,1=短路;向量)、StubDirection(0=向下,1=向上;向量)、SeriesLineLength、SeriesLineWidth、IsShielded、Connector。

扇形短截线
rs = stubRadialShunt;
rs = design(stubRadialShunt, 5e9);
show(rs);

SIW 带通滤波器

SIWFilter 使用 NumResonators(而非 FilterOrder),且 Substrate 为只读属性(通过内部谐振器对象设置):

f = SIWFilter;
f.NumResonators = 4;
show(f);
sp = sparameters(f, linspace(8e9, 14e9, 51), 'SweepOption', 'interp');
rfplot(sp);

从测量数据提取滤波器

measuredFilter 从测量或仿真的双端口 S 参数数据中提取耦合谐振器电路模型(耦合矩阵、外部 Q、无载 Q)。这可用于滤波器调谐、诊断,以及与理想综合目标进行比较。

主要属性:

  • Sparameters — 双端口 S 参数数据(sparameters 对象)
  • FilterOrder — 模型中的谐振器数量
  • CenterFrequency — 通带中心频率(Hz)
  • BandWidth — 3 dB 带宽(Hz)
  • CouplingMatrix — 提取的 N+2 阶耦合矩阵(提取后填充)
  • QualityFactor — 无载品质因数(调用 qualityfactor() 后填充)

主要方法:

  • residue(mf) — 从 S 参数数据中提取低通导纳留数和极点
  • transversalMat(mf) — 根据留数计算横向耦合矩阵
  • canonicalCouplingMat(mf) — 将横向矩阵旋转为规范(折叠)形式
  • optimize(mf) — 对耦合矩阵进行等谱优化
  • sparameters(mf, freq) — 根据提取的电路模型综合 S 参数
  • qualityfactor(mf) — 计算无载品质因数
完整工作流
% Step 1: Load measured S-parameters and inspect visually
S_meas = sparameters('measured_filter.s2p');
rfplot(S_meas);
% Identify center frequency and bandwidth from the plot

% Step 2: Create measuredFilter with matching initial guess
mf = measuredFilter(Sparameters=S_meas, ...
    FilterOrder=8, ...
    CenterFrequency=2114.6e6, ...
    BandWidth=9.6e6);

% Step 3: Extract residues and poles
residue(mf);

% Step 4: Build transversal matrix, then rotate to canonical form
transversalMat(mf);
M = canonicalCouplingMat(mf);
disp(mf.CouplingMatrix);

% Step 5: Optimize coupling matrix (isospectral flow)
mf = optimize(mf);

% Step 6: Compare extracted model vs measured data
freq = linspace(2.08e9, 2.15e9, 501);
S_model = sparameters(mf, freq);
rfplot(S_meas); hold on;
rfplot(S_model, '--');
legend('Measured', 'Extracted Model');

% Step 7: Quality factor
Q = qualityfactor(mf);
disp(mf.QualityFactor);

自定义滤波器组装

对于目录中没有的拓扑结构,可使用 pcbComponent 进行构建:

% Example: custom 2-pole open-loop filter from shape primitives
sub = dielectric("FR4");
sub.Thickness = 1.6e-3;
cond = metal("Copper");

% Build resonator shapes using traceLine, traceRectangular, Boolean ops
% (see matlab-assemble-pcb-layout skill)

pcb = pcbComponent;
pcb.Layers = {filterShape, sub, groundPlane};
pcb.BoardShape = groundPlane;
pcb.BoardThickness = sub.Thickness;
pcb.Conductor = cond;
pcb.FeedDiameter = feedWidth/2;
pcb.FeedLocations = [x1 y1 1 3; x2 y2 1 3];

多层滤波器

所有滤波器目录对象均支持多层介质:

f = design(filterCoupledLine, 3e9);
sub = dielectric("FR4", "Teflon");
sub.Thickness = [0.8e-3 0.4e-3];   % Set Thickness BEFORE assigning to filter
f.Substrate = sub;
f.Height = 1.2e-3;
show(f);

滤波器选择指南

需求推荐滤波器备注
紧凑型带通filterHairpin折叠谐振器可节省电路板面积
标准带通filterCoupledLine支持 design(),最适合作为入门选择
高选择性带通filterInterdigital阻带抑制效果好,宽带
电容加载型带通filterCombline窄带、高 Q、短谐振器
交叉耦合/传输零点带通filterOpenLoop准椭圆型,具有传输零点;支持 design()
SIW 技术带通SIWFilter高 Q 的 PCB 内波导
阶梯阻抗低通filterStepImpedanceLowPass支持 design()
带阻陷波filterSpurline非常紧凑,支持单支节或双支节
基于短截线的带通/带阻filterStub灵活的开路/短路短截线拓扑;不支持 design()
从数据中提取模型measuredFilter根据测量结果提取耦合矩阵

设计调整

问题调整项调整方向
通带过宽FilterOrder、Spacing提高阶数,减小间距
插入损耗过高Conductor 厚度使用真实金属,增加厚度
抑制不够深FilterOrder增大
中心频率偏移重新运行 design(filt, freq)--
回波损耗差FeedOffset、FeedType调整馈电位置

注意事项

  1. 对 S 参数使用插值扫频:对于 MoM 求解,始终使用 sparameters(obj, freq, 'SweepOption', 'interp')。直接扫频会在每个频点单独求解,速度明显更慢。

  2. 求解前检查网格密度:目录筛选器会生成密集的自动网格,显著增加运行时间。调用 sparameters() 前,始终先运行 memoryEstimate(obj, fc, 'RetainMesh', true)。如果内存占用过高,请加粗网格:mesh(obj, 'MaxEdgeLength', lambda/6)。完整的网格检查工作流请参阅 matlab-analyze-em。

  3. FilterOrder 与 NumPoles:有些对象使用 FilterOrder,另一些则使用 NumPoles。请检查特定对象的属性。

  4. PortLineLength 会影响响应:端口馈线长度会影响相位,并可能使滤波器的表观中心频率发生偏移。请确保长度足够,以便正确激励。

  5. design() 会设置所有尺寸:调用 design(obj, fc) 后,所有几何参数都会被覆盖。请在调用 design 后自定义属性,而不是之前。

  6. 耦合线滤波器带宽:带宽由 CouplingSpacing 控制——间隙越小,耦合越强,带宽越宽,但会受到制造工艺限制。

  7. StubShort 约定:在 filterStub 中,StubShort=0 表示开路短截线(产生带阻);StubShort=1 表示短路短截线(产生高通)。这一约定可能有悖直觉。

  8. 梳状线/交指/短截线滤波器不支持 design():filterCombline、filterInterdigital 和 filterStub 不支持 design()。请根据谐振器理论手动设置尺寸。

  9. SIWFilter 的 Substrate 为只读属性:无法直接设置 SIWFilter.Substrate。基板由内部谐振器和传输线元件对象控制。

  10. measuredFilter 的初始猜测值很重要。 CenterFrequency 和 BandWidth 必须与测量数据的实际通带十分接近。初始值不佳会导致 residue() 提取出错误的极点。请先直观检查 S 参数数据。

  11. ResonatorSpacing 向量长度 = FilterOrder - 1:对于梳状线、交指和发夹滤波器,ResonatorSpacing 指定的是谐振器之间的间隙。N 阶滤波器有 N 个谐振器,但只有 N-1 个间隙。不要传入 N 个元素,而应传入 N-1 个。

  12. 大多数滤波器的 GroundPlaneLength 为只读属性:filterCombline、filterHairpin 和 filterInterdigital 会根据谐振器尺寸自动计算 GroundPlaneLength 和 GroundPlaneWidth。不要尝试设置这两个属性。

相关技能

  • matlab-manage-pcb-material — 为滤波器性能选择基板
  • matlab-analyze-em — S 参数提取和场可视化
  • matlab-optimize-pcb-design — 优化滤波器尺寸
  • matlab-assemble-pcb-layout — 通过 pcbComponent 实现自定义滤波器拓扑
  • matlab-design-pcb-passive — 用于滤波器的谐振器、巴伦和开口环结构

版权所有 2026 The MathWorks, Inc.

评论

支持 Markdown