<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>抗积分饱和 &#8211; Cloudlay</title>
	<atom:link href="https://cloudlay.cn/tag/%e6%8a%97%e7%a7%af%e5%88%86%e9%a5%b1%e5%92%8c/feed/" rel="self" type="application/rss+xml" />
	<link>https://cloudlay.cn</link>
	<description>life</description>
	<lastBuildDate>Sun, 14 Jun 2026 17:08:33 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://cloudlay.cn/wp-content/uploads/2026/01/avatar.ico</url>
	<title>抗积分饱和 &#8211; Cloudlay</title>
	<link>https://cloudlay.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>从0到1带你打电赛·小车电控篇(七)：PID 进阶——方向环、串级双环，和「不做就翻车」的工程补丁</title>
		<link>https://cloudlay.cn/nuedc-car-07-pid-advanced/</link>
					<comments>https://cloudlay.cn/nuedc-car-07-pid-advanced/#respond</comments>
		
		<dc:creator><![CDATA[云间辞]]></dc:creator>
		<pubDate>Sun, 14 Jun 2026 17:08:33 +0000</pubDate>
				<category><![CDATA[嵌入式]]></category>
		<category><![CDATA[串级PID]]></category>
		<category><![CDATA[工程实现]]></category>
		<category><![CDATA[抗积分饱和]]></category>
		<category><![CDATA[方向环]]></category>
		<category><![CDATA[智能小车]]></category>
		<category><![CDATA[电赛]]></category>
		<guid isPermaLink="false">https://cloudlay.cn/nuedc-car-07-pid-advanced/</guid>

					<description><![CDATA[📚 本文是 「从 0 到 1 带你打电赛 · 小车电控篇」 系列（共 12 篇）第 7 篇。 第1篇 · 拿奖 [&#8230;]]]></description>
										<content:encoded><![CDATA[<div class="ds-series" style="border:1px solid #4488ff33;background:#4488ff0d;border-radius:8px;padding:.8em 1.1em;margin:1.2em 0">
<p style="margin:0 0 .5em"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4da.png" alt="📚" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 本文是 <strong>「从 0 到 1 带你打电赛 · 小车电控篇」</strong> 系列（共 12 篇）第 7 篇。</p>
<ol style="margin:.2em 0 0;padding-left:1.4em">
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-01-how-to-score/">第1篇 · 拿奖逻辑：把比赛拆成小目标</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-02-history/">第2篇 · 赛题进化史与押题</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-03-build-and-architecture/">第3篇 · 整车搭建与代码框架</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-04-motor-power/">第4篇 · 电机驱动与电源地基</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-05-sensing/">第5篇 · 感知：灰度/电磁/编码器/IMU</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-06-pid-basics/">第6篇 · PID 入门：搞懂 P/I/D</a></li>
<li style="margin:.15em 0"><strong>第7篇 · PID 进阶：串级+工程补丁（本篇）</strong></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-08-pid-tuning/">第8篇 · PID 调参实战(核心)</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-09-advanced-control/">第9篇 · 进阶控制：几时该上</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-10-vision-comm/">第10篇 · K230 视觉与通信协议</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-11-architecture-fsm/">第11篇 · 状态机与整车软件</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-12-field-manual/">第12篇 · 现场作战+避坑+开源</a></li>
</ol>
</div>
<p>上一篇《PID 入门》里，我们把一个单电机的速度环从只有 P 开始，一步步调到能稳稳跟住目标速度。如果你已经跑通了那一步，恭喜——你已经摸到了控制的门。但单环只能让&#8221;一个量&#8221;听话，真正上赛道的车要同时管两件事：<strong>跑多快</strong>和<strong>往哪拐</strong>。这一篇，我们把单环升级成能上场的完整控制：先讲方向环，再讲串级双环，最后讲一套&#8221;不打就翻车&#8221;的工程补丁。</p>
<p>先说一句大实话：很多人调车调到崩溃，以为是 Kp/Ki/Kd 没拧到位，其实十有八九是少打了某个补丁。<strong>这些补丁往往比纠结那三个参数更决定成败。</strong> 这篇就是带你把它们一次配齐。</p>
<h2>方向环：偏差怎么变成&#8221;左右轮速度差&#8221;</h2>
<p>小车靠两个轮子转向。想右转，就让右轮慢一点、左轮快一点，车头自然就偏过去了——跟划船一个道理。</p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 大白话比喻</p>
<p>差速转向像划船：想往右转，就右手轻划(右轮慢)、左手猛划(左轮快)，船头就往右偏。方向环要算的，就是&#8221;该往哪边偏、偏多少力气&#8221;，然后左桨减、右桨加。</p>
</div>
<p>那&#8221;该偏多少&#8221;从哪来？来自一个<strong>偏差</strong>。这个偏差可以是： &#8211; <strong>循迹题</strong>：摄像头看到的赛道中线偏差，或灰度/电感传感器的左右差(差比和)； &#8211; <strong>方向保持题</strong>：陀螺仪测到的偏航角(Yaw)误差，比如&#8221;我想走直线，结果车头偏了 5 度&#8221;。</p>
<p>把这个偏差喂给一个 PID(方向环实际上多数只用 PD，下面会解释)，算出一个转向量 <code>turn</code>，再分配到左右轮：</p>
<p class="ds-math" style="overflow-x:auto">$$\text{左轮目标} = \text{base} &#8211; \text{turn}, \qquad \text{右轮目标} = \text{base} + \text{turn}$$</p>
<p><code>base</code> 是直行基础速度。这个加减号谁正谁负，取决于你电机和传感器的安装方向，调的时候试一下就知道。</p>
<p>它背后是差速车的运动学(给定线速度 $v$、角速度 $w$、轮距 $L$)：</p>
<p class="ds-math" style="overflow-x:auto">$$v_R = v + \tfrac{1}{2} w L, \qquad v_L = v &#8211; \tfrac{1}{2} w L$$</p>
<div class="ds-callout ds-callout-note" style="border-left:4px solid #448aff;background:#448aff14;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#448aff"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4dd.png" alt="📝" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 别把轮距搞混</p>
<p>这里的 $L$ 是<strong>轮距</strong>(左右轮中心间距)，不是前后轴距。代公式时别拿错尺寸。</p>
</div>
<p>平衡车里有个更直接的经典写法，是在 PWM 层直接把几路输出叠加，可以借鉴它的&#8221;共模/差模&#8221;思路：</p>
<pre><code class="language-c">// 直立项 + 速度项(共模,左右一样) ± 转向项(差模,左右相反)
Moto_Left  = Balance_Pwm + Velocity_Pwm - Turn_Pwm;   // 左轮
Moto_Right = Balance_Pwm + Velocity_Pwm + Turn_Pwm;   // 右轮

// 纯差速循迹小车去掉 Balance,在"目标速度层"做混合:
// Left_Speed_Goal  = base_speed - turn;
// Right_Speed_Goal = base_speed + turn;</code></pre>
<h3>方向环为什么常常只用 PD，不加 I？</h3>
<p>方向环里那个 <code>turn</code> 一般用<strong>位置式 PD</strong>(位置式、增量式的区别《PID 入门》讲过了)。入弯时偏差会突然变大，这一下主要靠 <strong>D 项</strong>来响应——D 看的是&#8221;偏差变化率&#8221;，偏差一跳它最敏感，能让车提前打方向。</p>
<p>那 I 呢？社区里有很强的共识：方向环<strong>通常弱化甚至不加 I</strong>。原因有两个：陀螺仪有零飘、车轮会打滑，数据本身就不太准，靠 I 去&#8221;消静差&#8221;意义不大；而且 I 会引入延迟，过弯后车身&#8221;拖泥带水&#8221;半天回不到中线。</p>
<div class="ds-callout ds-callout-warning" style="border-left:4px solid #ff9100;background:#ff910014;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff9100"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 这条不要绝对化</p>
<p>&#8220;方向环绝对不能加 I&#8221;是个<strong>偏教条</strong>的说法。准确讲：方向环<strong>以 PD 为主导</strong>；但如果你的车存在固定的机械/装配偏置——比如装得不正、走直线总是恒定地偏一点点角度——这时加一个<strong>很小、并且带积分分离和限幅</strong>的 I 来纠正这个恒定偏角，是合理且有用的(自动驾驶 PID 理论里，I 项正是用来消除转向系统的恒定偏置/steering drift)。结论是：默认 PD，需要纠恒定偏置时再谨慎补一点小 I；但高速动态循迹下 I 过大确实会带来滞后和超调。</p>
</div>
<p>这里有个真实的坑：有人调方向环手痒加了积分，结果回正迟钝、过弯后车身拖泥带水回不到中线；去掉 I 只留 PD 后转向立刻干脆了。(<a href="https://blog.csdn.net/qq_63306197/article/details/143493535" target="_blank" rel="noopener noreferrer">来源</a>)</p>
<h3>调方向环之前，先验极性！</h3>
<p>这是新手最容易栽的地方，而且一栽就是&#8221;参数怎么调都没用&#8221;。</p>
<div class="ds-callout ds-callout-danger" style="border-left:4px solid #ff1744;background:#ff174414;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff1744"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f525.png" alt="🔥" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 极性接反 = 正反馈 = 直接失控</p>
<p>方向环极性接反，就像方向盘装反了：你想往左打，车却往右拐，而且越打越歪。这是正反馈，再完美的参数也救不了。</p>
</div>
<p>验极性的方法极简单：给一个正的 Kp，然后<strong>用手去转车</strong>。 &#8211; 车<strong>反抗</strong>你、想转回来 → 负反馈，极性对 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> &#8211; 车<strong>顺着</strong>你越转越欢 → 正反馈，极性反了 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/274c.png" alt="❌" class="wp-smiley" style="height: 1em; max-height: 1em;" />，把符号取反，或交换电机线/陀螺仪安装方向</p>
<div class="ds-callout ds-callout-important" style="border-left:4px solid #00bcd4;background:#00bcd414;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bcd4"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2757.png" alt="❗" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 极性和增益要分两步调</p>
<p>先确认极性(符号)对，<strong>再</strong>调大小(增益)。把这两件事混在一起，你会把&#8221;符号错&#8221;当成&#8221;参数不对&#8221;在那瞎拧。换了电机接线或陀螺仪安装方向后，必须重新验一遍极性。</p>
</div>
<p>调 P 和 D 的口诀和单环一样：从 D=0、只加 P 开始，P 加到走直线/循迹基本能跟线、但弯道略冲；再加 D 抑制过冲和振荡。<strong>P 太大直道会画龙(蛇形摆)，D 太大对噪声敏感会高频抖舵。</strong> 一套能照抄的完整方向环调参步骤，留到《PID 调参实战》一篇细讲。</p>
<h2>串级双环：老板与员工</h2>
<p>单环 PID 自稳性还凑合，但一遇到负载变化——上坡、打滑、电池掉压——跟随就会滞后甚至失稳。串级(双反馈)PID 是控制赛道的标准答案，它的核心思想一句话：</p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 串级 PID 像老板和员工</p>
<p>外环是老板，只说&#8221;这个月业绩做到 100 万&#8221;(定目标)，不亲自跑业务；内环是员工，负责&#8221;今天这一单怎么签下来&#8221;(快速执行)。老板看大方向(慢、稳)，员工干具体活(快、勤)。<strong>老板的指令，就是员工的工作目标——这就是&#8221;外环输出 = 内环目标值&#8221;。</strong></p>
</div>
<p>具体到小车： &#8211; <strong>外环</strong>(方向/位置/角度)：负责&#8221;对不对得准、到没到位&#8221;。它的输出<strong>不直接驱动电机</strong>，而是作为内环的目标值。 &#8211; <strong>内环</strong>(速度/角速度)：负责让实际转速<strong>快速精确</strong>跟上外环给的目标，输出才真正变成 PWM。</p>
<p>偏差大时，外环给一个大目标速度让车快速逼近；快到了，外环把目标速度收小，避免冲过头。</p>
<p>为什么这样就更抗造？举个上坡的例子：上坡瞬间电机实际转速被拖下来，<strong>内环立刻发现&#8221;我没跟上目标&#8221;，马上加大 PWM 顶上去</strong>(粗调、快)，外环再慢慢保证最终到位(细调)。所以串级在变负载、高速时明显比单环稳，提速时不甩尾。(<a href="https://blog.csdn.net/dpc03/article/details/132001414" target="_blank" rel="noopener noreferrer">来源</a>)</p>
<figure class="ds-diagram" style="text-align:center;margin:1.3em 0"><img decoding="async" src="https://cloudlay.cn/wp-content/uploads/dianseiche/649838f28ae1.png" alt="电赛小车电控 · 示意图" loading="lazy" style="max-width:100%;height:auto;background:#fff;border-radius:8px;padding:6px;box-shadow:0 1px 6px rgba(0,0,0,.25)"></figure>
<h3>分工：速度内环用增量式 PI，方向外环用位置式 PD</h3>
<p>多数车队的搭配是： &#8211; <strong>速度内环 → 增量式 PI</strong>：输出是增量累加，电机不容易在正反转之间突跳，天然好处理饱和，只需输出限幅。 &#8211; <strong>方向外环 → 位置式 PD</strong>：偏差直观、响应快，不加(或只加极小)I。</p>
<p>速度内环的标准写法(左轮为例，偏差 = 目标 − 编码器)：</p>
<pre><code class="language-c">void Left_Speed_Control(void)
{
    float erro = Speed_Goal - Left_Encoder;            // 偏差 = 目标 - 编码器读数
    // 增量式: Δu = P*(e-e1) + I*e + D*(e-2*e1+e2)
    Left_Speed_PID.OUT += ( Left_Speed_PID.P * (erro - Left_Speed_Lasterro)
                          + Left_Speed_PID.I *  erro
                          + Left_Speed_PID.D * (erro - 2*Left_Speed_Lasterro + Left_Speed_Preverro) );
    Left_Speed_OUT = Range_protect((int)Left_Speed_PID.OUT, -9000, 9000); // 输出限幅
    Left_Speed_Preverro = Left_Speed_Lasterro;
    Left_Speed_Lasterro = erro;
}</code></pre>
<div class="ds-callout ds-callout-note" style="border-left:4px solid #448aff;background:#448aff14;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#448aff"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4dd.png" alt="📝" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 一个省事的小技巧</p>
<p>速度内环的反馈<strong>直接用编码器原始计数就行</strong>，不必费劲换算成&#8221;米/秒&#8221;这种真实物理速度——中间只差一个固定比例系数，会被 Kp 自动吸收掉。别为换算真实速度浪费精力。</p>
</div>
<div class="ds-callout ds-callout-warning" style="border-left:4px solid #ff9100;background:#ff910014;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff9100"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 上面代码里的 ±9000 不是&quot;万能经验值&quot;</p>
<p>这个限幅值强依赖你的定时器满量程(ARR)。正确的姿势是：<strong>输出限幅取 PWM 满量程的某个比例(比如 90%)</strong>，具体数字随你的 ARR 而定。同理，网上各种&#8221;方向环 Kp = 0.6&#8243;之类的数字，都和反馈量纲、陀螺量程(±250/500/2000 dps)强相关，<strong>只能当某次实现的参考，不能跨平台照搬</strong>。换了平台必须从小到大重新整定。</p>
</div>
<h3>内环要比外环跑得快得多</h3>
<p>这是串级的命门：<strong>内环周期必须远小于外环周期。</strong></p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻：手速要快，战略可以慢</p>
<p>内环快外环慢，像打游戏：微操(补刀、走位)必须每秒几十次；大局观(什么时候推塔)几秒决策一次就够。要是战略也每秒变几十次，只会自己乱了阵脚。</p>
</div>
<p>经验上，<strong>内环周期取外环的 1/3 到 1/10</strong>(等价于内环带宽是外环的 3~10 倍)。这是跨多个来源一致的核心规律——<strong>量级上</strong>把握住就行，不必死抠精确数字。代码实现很简单，用一个计数器分频：内环每次中断都算，外环每隔 N 次才算一次。</p>
<pre><code class="language-c">// 在同一个定时器中断(周期 T)里:
current_loop();                       // 最内环:每次都算
if (outer_ring_timer % 2 == 0)        // 速度环:每 2T 算一次
    speed_loop();
if (outer_ring_timer % 3 == 0)        // 位置/方向外环:每 3T 算一次
    position_loop();
outer_ring_timer++;</code></pre>
<p>野火的有刷电机三环例程就是这么干的：电流内环每 T、速度环每 2T、位置环每 3T。平衡车的经典分层大致是直立/角度环最快(约 5~10ms)、速度外环为它的若干倍周期。</p>
<div class="ds-callout ds-callout-note" style="border-left:4px solid #448aff;background:#448aff14;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#448aff"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4dd.png" alt="📝" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 别把这组数字背死</p>
<p>&#8220;平衡车一定是角速度 2ms / 角度 10ms / 速度 50~100ms&#8221;这种说法<strong>偏死板</strong>。很多实现把速度环和直立环放同一个中断、只做几倍分频。真正重要的不是这组具体数字，而是<strong>保持内环明显快于外环的频率分离</strong>。2024 电赛 H 题里很多队伍直接用一个 10ms 定时器中断(100Hz)跑完整套 PID，也照样跑得很好。</p>
</div>
<div class="ds-callout ds-callout-danger" style="border-left:4px solid #ff1744;background:#ff174414;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff1744"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f525.png" alt="🔥" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 一个常见的认知混乱：控制周期 ≠ PWM 频率</p>
<p>这俩差着几十上百倍，初学者最容易搞混： &#8211; <strong>PWM 载波频率</strong>(电机驱动)：10~20kHz，决定电机平滑度和噪声。 &#8211; <strong>PID 控制周期</strong>(定时器中断里跑 PID)：1~10ms，也就是 100~1000Hz。</p>
<p>这里要破一个常见误解：10kHz <strong>并没有真正&#8221;避开可听噪声&#8221;</strong>——人耳上限约 20kHz，10kHz 反而是明显的尖啸。10kHz 只是兼顾电机平滑度、开关损耗(发热)与噪声的一个<strong>够用的折中下限</strong>。<strong>要真正消除可听啸叫，得把 PWM 提到 20kHz 以上</strong>(超出人耳上限)，代价是开关损耗变大、对驱动 MOS 要求更高。所以更稳妥的做法是直接上 20kHz 左右。(选驱动芯片和具体频率取舍见《电机驱动与电源地基》一篇。)</p>
</div>
<h3>调参铁律：先调内环，后调外环</h3>
<div class="ds-callout ds-callout-important" style="border-left:4px solid #00bcd4;background:#00bcd414;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bcd4"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2757.png" alt="❗" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 这是新手最大的坑：千万别先调外环</p>
<p>调外环时，外环&#8221;看到&#8221;的对象其实是<strong>内环 + 电机这个整体</strong>。如果内环本身不稳，这个整体特性就是飘的，你在它上面调出来的外环参数毫无意义，一换工况就废。</p>
</div>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻：先教会司机开车，再规划路线</p>
<p>如果司机(内环)连油门刹车都控制不稳，你给他再完美的导航(外环)，车也开得东倒西歪。必须先把司机训练到指哪开哪、稳准快，路线规划才有意义。</p>
</div>
<p>正确流程： 1. <strong>先屏蔽外环</strong>(把外环运算注释掉，或给内环一个固定目标速度)。 2. 单独调内环：让车架空或直线低速跑，给一个突变的目标速度，看编码器波形——调到能<strong>快速、平滑、几乎不超调</strong>地跟上，受扰后不振荡。 3. 内环稳了，对外环来说它就近似成了一个&#8221;稳定快速的等效环节&#8221;。这时再像调普通 PID 那样调外环：先加 P，再加 D。</p>
<div class="ds-callout ds-callout-warning" style="border-left:4px solid #ff9100;background:#ff910014;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff9100"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 调某一环时，把其它环的运算先注释/置零</p>
<p>一个真实教训(2020 全国智能车直立组)：串级&#8221;一环套一环，出了问题根本分不清是哪个环&#8221;，整定极其耗时。这位选手三次整定分别花了 5~6 小时、2~3 小时、1 小时——熟能生巧没有捷径。所以一定要<strong>分环隔离、逐个整定</strong>，绝不要三个环一起调。(<a href="https://blog.csdn.net/weixin_44065323/article/details/107926155" target="_blank" rel="noopener noreferrer">来源</a>)</p>
</div>
<h2>工程补丁八件套：不打就翻车</h2>
<p>终于到了这一篇真正的&#8221;硬核私货&#8221;。下面这八个补丁，每一个都对应一类&#8221;调参怎么都调不好&#8221;的诡异现象。把它们配齐，你的车才算从&#8221;实验室能跑&#8221;进化到&#8221;赛场能扛&#8221;。</p>
<h3>补丁 1：积分限幅 + 补丁 7：输出限幅</h3>
<p>这俩是一对，一起讲。<strong>输出限幅</strong>是把最终 PWM 夹到 <code>[-Max, Max]</code>；<strong>积分限幅</strong>是单独给积分累加项设上下界。</p>
<div class="ds-callout ds-callout-warning" style="border-left:4px solid #ff9100;background:#ff910014;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff9100"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 最常见的错误：只限输出，不限积分</p>
<p>很多人以为夹了输出就万事大吉。错。如果你只限输出不管积分，积分项还会<strong>偷偷涨到非常大</strong>，等误差反向时它迟迟泄不掉，车冲过头才肯回头。</p>
</div>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻</p>
<p>输出限幅是&#8221;限制方向盘最多打到底&#8221;，积分限幅是&#8221;限制你心里那股较劲的劲儿别攒太多&#8221;。只管方向盘、不管心里的劲，松手时车还是会猛回弹。</p>
</div>
<p>顺序也是固定的：<strong>先有输出限幅，anti-windup 才有&#8221;是否饱和&#8221;可判断。</strong> 国一开源 Enterprise_E 里就是电机环积分限幅 <code>i_Max=1000</code>、转向环 <code>i_Max=400</code>，和输出限幅各自独立。</p>
<h3>补丁 2：积分分离</h3>
<p>专治起步/大阶跃时的猛烈超调。思路：<strong>误差大时关掉积分(只用 PD 快速逼近)，误差进入小范围才投入积分消静差。</strong></p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻：考试策略</p>
<p>离正确答案还很远时(大误差)别抠细节，先大刀阔斧往对的方向赶(只用 PD)；快接近了(小误差)再用积分慢慢抠掉最后那点零头(静差)。</p>
</div>
<p>可以做成三段式平滑过渡：</p>
<pre><code class="language-c">if (pid-&gt;errABS &gt; 50)         kiIndex = 0.000f;   // 大误差:关积分,纯 PD 冲
else if (pid-&gt;errABS &gt; 30)    kiIndex = 0.600f;   // 中误差:半投
else                          kiIndex = 1.000f;   // 小误差:全投,消静差
pid-&gt;outPut = pid-&gt;outPutP + pid-&gt;outPutI * kiIndex + pid-&gt;outPutD;</code></pre>
<p>实战反馈：智能车里<strong>积分分离比变速积分更直接好用、更干脆</strong>。(<a href="https://ittuann.github.io/2021/08/29/CarPID.html" target="_blank" rel="noopener noreferrer">来源</a>)</p>
<h3>补丁 3：抗积分饱和(anti-windup)</h3>
<p>这是积分类问题的总根源。<strong>积分饱和(windup)</strong>是指：误差长期同号 → 积分越累越大 → 输出顶到饱和 → 等误差反向时，积分要很久才泄完 → 造成大滞后、大超调。</p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻：上长坡一直深踩油门</p>
<p>坡(误差)一直在，你脚越踩越深(积分越累越大)；到了坡顶该松油门减速了(误差反向)，可你脚踩得太深，要抬好久车才肯减速——这段&#8221;反应不过来&#8221;就是饱和带来的大滞后。anti-windup 就是&#8221;看到油门踩到底了，就别再使劲往下踩&#8221;。</p>
</div>
<p>有两大流派。</p>
<p><strong>流派 A：遇限削弱(条件积分 / clamping)</strong>——输出已饱和时，只允许&#8221;会让积分往回退&#8221;的累加：</p>
<pre><code class="language-c">if (ABS(pid-&gt;outPutLast) &gt; outPutLimit) {
    // 仅当积分会被"反向"削弱时才累加(误差与积分异号才累加)
    if ((pid-&gt;errSum &gt; 0 &amp;&amp; pid-&gt;errNow &lt; 0)
     || (pid-&gt;errSum &lt; 0 &amp;&amp; pid-&gt;errNow &gt; 0)) {
        pid-&gt;errSum += pid-&gt;errNow;
    }
    // 同号(会让积分更饱和) → 本次不累加
} else {
    pid-&gt;errSum += pid-&gt;errNow;   // 未饱和,正常累加
}</code></pre>
<p><strong>流派 B：反计算(back-calculation)</strong>——饱和时把&#8221;饱和差&#8221;按一定速率反喂给积分器，主动把它拉回来。离散实现很干脆：</p>
<pre><code class="language-python"># 先算未饱和输出 op
if op[i] &gt; op_hi:        # 触上限
    op[i] = op_hi
    ie[i] = ie[i] - e[i] * delta_t    # 抵消本次积分增量
if op[i] &lt; op_lo:        # 触下限
    op[i] = op_lo
    ie[i] = ie[i] - e[i] * delta_t</code></pre>
<p>反计算有个跟踪时间常数 $T_t$，经验取 $T_t = \sqrt{T_i \cdot T_d}$，且满足 $T_d < T_t < T_i$；$T_t$ 越小，积分泄得越快。</p>
<div class="ds-callout ds-callout-note" style="border-left:4px solid #448aff;background:#448aff14;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#448aff"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4dd.png" alt="📝" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 增量式 PID 算不算&quot;天生免疫&quot;饱和？</p>
<p>入门篇说过增量式&#8221;天然规避积分饱和&#8221;——这话<strong>基本对，但别理解得太绝对</strong>。增量式确实没有&#8221;显式累加 Σe 导致数值无界膨胀&#8221;那种经典 windup；但当 <code>u(k)=u(k-1)+Δu</code> 的输出被限幅(比如 PWM 顶到 100%)时，<strong>仍会出现类 windup 的滞后/退饱和延迟</strong>。严重时增量式照样需要反算抗饱和。准确说法是&#8221;不易/天然规避显式积分饱和&#8221;，不是&#8221;绝对不会饱和&#8221;。</p>
</div>
<h3>补丁 4：微分先行 / 对测量值微分</h3>
<p>专治&#8221;设定值突变&#8221;。如果微分项是对<strong>误差</strong>做差分，那么设定值一阶跃(比如目标速度从 0 突然变 100)，误差瞬间巨变，微分项会蹦出一个巨大的尖峰冲击执行器——这就是 <strong>derivative kick(微分踢)</strong>。</p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻</p>
<p>微分踢像你正稳稳走路，突然有人把终点瞬移到很远——如果你对&#8221;目标距离的变化&#8221;做反应，会被吓得猛地一蹿。改成只盯<strong>自己脚步</strong>的变化(对测量值微分)，就不会被目标瞬移惊到。</p>
</div>
<p>解法：微分项改用 $-(PV_k &#8211; PV_{k-1})$，作用在测量值上而非误差上：</p>
<pre><code class="language-c">// 微分项用 -(PV变化) 代替 (误差变化),二阶形式同时抑制噪声
u_k = u_k_1
    + KP*(e_k - e_k_1)
    + KI*e_k*dt
    - KD*(PV_k - 2*PV_k_1 + PV_k_2)/dt;</code></pre>
<div class="ds-callout ds-callout-warning" style="border-left:4px solid #ff9100;background:#ff910014;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff9100"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 这只消了&quot;微分踢&quot;,没消&quot;比例踢&quot;</p>
<p>上面这个式子里，比例项还是 <code>KP*(e_k - e_k_1)</code>，设定值阶跃时它仍会让输出瞬间跳一下 <code>KP*Δsp</code>——这叫<strong>比例踢(proportional kick)</strong>。如果你的设定值会频繁大幅跳变、想把它也驯服，需要用<strong>设定值加权 / I-PD(二自由度)结构</strong>：让比例项也作用于测量值(或加权 <code>KP*(β*sp - PV)</code>)，只让积分项作用于误差。记住：仅对 PV 微分<strong>只解决 derivative kick</strong>，比例踢得另行处理。</p>
</div>
<h3>补丁 5：微分低通滤波(不完全微分)</h3>
<p>专治&#8221;加大 D 就抖/啸叫&#8221;。纯微分会把编码器、陀螺仪、ADC 的高频噪声放大成抖动甚至尖啸。</p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻：戴降噪耳机听节奏</p>
<p>不滤波时，旁边一点杂音(传感器噪声)都被你当成节拍剧烈摇头(抖动)；滤波后只跟真正的鼓点(真实趋势)走。</p>
</div>
<p>做法是给微分项串一个一阶低通：</p>
<pre><code class="language-c">thisError = setpoint - processValue;
integral += thisError;
// 关键: (1-α)*新微分 + α*上次微分
thisDev = Kd*(1.0f - alpha)*(thisError - lasterror) + alpha*lastdev;
result  = Kp*thisError + Ki*integral + thisDev;
lasterror = thisError;
lastdev   = thisDev;</code></pre>
<p>系数 $\alpha \in (0,1)$：$\alpha=0$ 无滤波、$\alpha=1$ 等于没微分。等价于工业界的微分滤波系数 $N$(典型 8~20，越小滤得越狠)。</p>
<div class="ds-callout ds-callout-important" style="border-left:4px solid #00bcd4;background:#00bcd414;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bcd4"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2757.png" alt="❗" class="wp-smiley" style="height: 1em; max-height: 1em;" /> D 项的两大坑，要一起堵</p>
<p>derivative kick(对误差微分)和噪声放大(不滤波)是 D 项的两大坑，分别用<strong>对测量微分</strong>和<strong>低通滤波</strong>解决。配齐这两个补丁，你的 Kd 才敢用得起来、敢加大。一个常见误判：Kd 过大引起的高频抖动，经常被当成&#8221;机械松动&#8221;——先确认是不是 D 没滤波，再去拧螺丝。</p>
</div>
<h3>补丁 6：电机死区补偿</h3>
<p>专治&#8221;低速/小误差时车原地哒哒抖，或干脆趴窝不动&#8221;。静摩擦加上 H 桥死区，会让占空比低于某个阈值(常见 5%~10%，或绝对值如 &lt; 65/1000)时电机根本不转——这时控制增益在死区内突然变 0，系统就极限环抖动或卡死。</p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻：太松的自行车链条</p>
<p>你蹬了一点(小占空比)链条还在空档没咬上，车不动；得先蹬过那段空档(死区补偿)，后面才线性使上劲。</p>
</div>
<p>补偿就是输出非零时，叠加一个符号相关的偏置把死区&#8221;跨过去&#8221;：</p>
<pre><code class="language-c">if (out &gt; 0)      out += DEAD_ZONE;   // 正向跨死区
else if (out &lt; 0) out -= DEAD_ZONE;   // 反向跨死区
// out == 0 时保持 0,避免零点附近来回跳</code></pre>
<div class="ds-callout ds-callout-warning" style="border-left:4px solid #ff9100;background:#ff910014;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff9100"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 别过补偿</p>
<p>死区补偿标定要准。补多了会在零点附近反复正反跳变，产生<strong>新的</strong>抖动。建议实测电机刚启动的最小占空比，再略加一点余量。另外，上闭环前先把电机中值/死区标定好——否则零点附近反复跳变，看起来像 PID 没调好，其实是死区在作怪。</p>
</div>
<h3>补丁 8：电池电压补偿</h3>
<p>这是&#8221;实验室调好、上场翻车&#8221;的隐形元凶。同一个占空比下，电机力矩正比于母线电压；电池从满电掉到欠压，等效 Kp 就<strong>悄悄变小</strong>了，高速时车会变软、摆头甚至失控。</p>
<div class="ds-callout ds-callout-tip" style="border-left:4px solid #00bfa6;background:#00bfa614;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00bfa6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 比喻：跑步时的体力</p>
<p>满电(刚出发)同样力气跑得快，没电(快到终点)同样力气跑得慢。补偿就是&#8221;累了就多使点劲&#8221;，让全程速度感一致——你练习时(满电)定的节奏，比赛后半程(亏电)也还成立。</p>
</div>
<p>补偿公式简单，但要 ADC 实测电池电压：</p>
<pre><code class="language-c">// V_NOMINAL 为标称/调参时电压, v_batt 由 ADC 实测
pwm_out = pid_out * (V_NOMINAL / v_batt);</code></pre>
<div class="ds-callout ds-callout-note" style="border-left:4px solid #448aff;background:#448aff14;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#448aff"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4dd.png" alt="📝" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 两个注意点</p>
<p>一是电压采样要滤波，否则电压噪声会反灌进 PWM；二是低于欠压保护阈值时应该<strong>限速</strong>而不是死命补偿。</p>
</div>
<p>一个真实战例：高速行驶时车突然失控摆头，排查半天发现是电池电量下降导致同占空比下力矩变小、等效 Kp 变软。加上电压补偿后，从满电到亏电表现终于一致了。(<a href="https://blog.csdn.net/2301_80317247/article/details/145358194" target="_blank" rel="noopener noreferrer">来源</a>)</p>
<h2>一张表，把八件套对号入座</h2>
<table>
<thead>
<tr>
<th>你看到的症状</th>
<th>八成是缺了哪个补丁</th>
</tr>
</thead>
<tbody>
<tr>
<td>起步给大目标，车猛冲过头(大超调)</td>
<td>积分分离 + 积分限幅 + anti-windup</td>
</tr>
<tr>
<td>误差反向后车迟迟不回头、退饱和慢</td>
<td>anti-windup(遇限削弱 / 反计算)</td>
</tr>
<tr>
<td>一改目标值，输出就猛地蹿一下</td>
<td>微分先行(对测量值微分)</td>
</tr>
<tr>
<td>一加大 Kd，车就高频抖/啸叫</td>
<td>微分低通滤波</td>
</tr>
<tr>
<td>低速/小误差原地哒哒抖或趴窝</td>
<td>死区补偿</td>
</tr>
<tr>
<td>满电调好上场，后半程变软/摆头</td>
<td>电池电压补偿</td>
</tr>
<tr>
<td>反向时积分泄不掉、冲过头</td>
<td>积分限幅(只限输出不够)</td>
</tr>
<tr>
<td>输出超过 PWM 量程</td>
<td>输出限幅(也是所有抗饱和的前提)</td>
</tr>
</tbody>
</table>
<h2>别忘了陀螺仪零飘</h2>
<p>方向环如果用陀螺仪 Yaw 做反馈，零飘是绕不开的。一个真实战例：2024 电赛 H 题某队原计划用编码器 PID 调速，却发现两个轮子性能不一致、达到恒速的时间都不一样，被逼着改用陀螺仪 Yaw 检测偏航角控直行；结果省赛前夜先误烧了十轴模块，又发现 MPU6050 的 Yaw 在漂，最后比赛前 6 小时才把应急模块移植成功。(<a href="https://blog.csdn.net/m0_74800695/article/details/140869823" target="_blank" rel="noopener noreferrer">来源</a>)</p>
<div class="ds-callout ds-callout-warning" style="border-left:4px solid #ff9100;background:#ff910014;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#ff9100"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 一个被广泛误传的数字</p>
<p>网上常说&#8221;MPU6050 的 Yaw 一秒漂 2 度&#8221;——这个<strong>严重高估</strong>了。经过一次性零偏校准后，MPU6050 的 Yaw 裸积分漂移大约是<strong>每分钟几度</strong>的量级；如果配上带零偏修正的姿态融合(如 Madgwick)，能降到约 <strong>0.5°/分钟</strong>(≈0.008°/s)。&#8221;每秒 2 度&#8221;更像是完全没校零偏时的瞬时表现。</p>
<p>但<strong>结论方向不变</strong>：Yaw 漂移确实需要处理。要么上电静止时采一次零偏并做软件纠偏，要么干脆换 HWT101/JY901 这类带磁/融合的专用航向模块。不处理的话，直行越走越偏、定角度转弯越转越不准。(零偏校准与互补滤波的具体做法见《感知：灰度/电磁/编码器/IMU》一篇。)</p>
</div>
<p>另外，左右电机/编码器往往天生不一致，<strong>最好左右各用一套速度 PID 参数分别整定</strong>，或在差速混合里加补偿，别指望一套参数包打天下。</p>
<h2>收个尾：补丁配齐，参数才有意义</h2>
<p>把这一篇捋一遍，你应该建立起这样一条心智：</p>
<figure class="ds-diagram" style="text-align:center;margin:1.3em 0"><img decoding="async" src="https://cloudlay.cn/wp-content/uploads/dianseiche/5f54c7d17132.png" alt="电赛小车电控 · 示意图" loading="lazy" style="max-width:100%;height:auto;background:#fff;border-radius:8px;padding:6px;box-shadow:0 1px 6px rgba(0,0,0,.25)"></figure>
<div class="ds-callout ds-callout-success" style="border-left:4px solid #00c853;background:#00c85314;padding:.6em 1em;margin:1.2em 0;border-radius:6px">
<p style="margin:0 0 .45em;font-weight:700;color:#00c853"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 这一篇的核心就三句话</p>
<ol>
<li><strong>先调内环、后调外环</strong>，分环隔离逐个整定，绝不三环一起上。</li>
<li><strong>内环周期远小于外环</strong>(1/3~1/10)，控制周期和 PWM 频率是两码事。</li>
<li><strong>八件套补丁往往比 Kp/Ki/Kd 更决定成败</strong>——它们才是&#8221;调好了上场不翻车&#8221;的真正保险。</li>
</ol>
</div>
<p>想看这套东西在真实比赛代码里长什么样，强烈推荐通读第十六届智能车国一开源 <a href="https://github.com/ittuann/Enterprise_E" target="_blank" rel="noopener noreferrer">ittuann/Enterprise_E</a>：它的 <code>pid.c</code> 把误差限幅、积分限幅、积分分离、专家 PID、前馈补偿全配齐了，注释也到位，是工程补丁落地的最佳样板；配套<a href="https://ittuann.github.io/2021/08/29/CarPID.html" target="_blank" rel="noopener noreferrer">博客</a>更是把抗饱和、积分分离、不完全微分讲透了。串级落地代码可以参考 STM32 的 <a href="https://gitee.com/xxpcb/stm32-motor-pid" target="_blank" rel="noopener noreferrer">xxpcb/stm32-motor-pid</a>、TI MSPM0 赛道(对口 2024 H 题)的 <a href="https://github.com/Szturin/M0G3507-TI-CAR" target="_blank" rel="noopener noreferrer">Szturin/M0G3507-TI-CAR</a>，原理教程则首推<a href="https://doc.embedfire.com/motor/motor_tutorial/zh/latest/improve_part/dc_motor_multi_loop_control.html" target="_blank" rel="noopener noreferrer">野火有刷电机多环控制</a>。</p>
<p>到这里，方向环、串级、补丁你都备齐了，但参数到底怎么从 0 一步步拧出来、波形该看哪些症状下哪些药——那才是真正的硬功夫。具体调参流程，我们留到下一篇 PID 调参实战，用一套能照抄的步骤和一张&#8221;波形症状→该调哪个参数&#8221;的诊断表，带你把这些参数一个个调到位。</p>
<div class="ds-series" style="border:1px solid #4488ff33;background:#4488ff0d;border-radius:8px;padding:.8em 1.1em;margin:1.2em 0">
<p style="margin:0 0 .5em"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4da.png" alt="📚" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 本文是 <strong>「从 0 到 1 带你打电赛 · 小车电控篇」</strong> 系列（共 12 篇）第 7 篇。</p>
<ol style="margin:.2em 0 0;padding-left:1.4em">
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-01-how-to-score/">第1篇 · 拿奖逻辑：把比赛拆成小目标</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-02-history/">第2篇 · 赛题进化史与押题</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-03-build-and-architecture/">第3篇 · 整车搭建与代码框架</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-04-motor-power/">第4篇 · 电机驱动与电源地基</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-05-sensing/">第5篇 · 感知：灰度/电磁/编码器/IMU</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-06-pid-basics/">第6篇 · PID 入门：搞懂 P/I/D</a></li>
<li style="margin:.15em 0"><strong>第7篇 · PID 进阶：串级+工程补丁（本篇）</strong></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-08-pid-tuning/">第8篇 · PID 调参实战(核心)</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-09-advanced-control/">第9篇 · 进阶控制：几时该上</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-10-vision-comm/">第10篇 · K230 视觉与通信协议</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-11-architecture-fsm/">第11篇 · 状态机与整车软件</a></li>
<li style="margin:.15em 0"><a href="https://cloudlay.cn/nuedc-car-12-field-manual/">第12篇 · 现场作战+避坑+开源</a></li>
</ol>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudlay.cn/nuedc-car-07-pid-advanced/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
