# 数字电源项目-pid代码有疑问

**URL:** <https://bbs.eeclub.top/t/topic/292>\
**Category:** 电力电子 / Power Electronics\
**Tags:** 电源, QA, SMPS, STM32\
**Created:** [2026 年3 月 16 日 12:21 UTC](https://bbs.eeclub.top/t/topic/292 "2026-03-16T12:21:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

作者： ![lin](https://bbs.eeclub.top/letter_avatar_proxy/v4/letter/l/13edae/32.png) [@lin](https://bbs.eeclub.top/u/lin)\
发布日期： [2026 年3 月 16 日 12:21 UTC](https://bbs.eeclub.top/t/topic/292/1 "2026-03-16T12:21:58Z")

</div>

[https://oshwhub.com/zeruns/ji-yu-stm32-de-buck-boost-xing-shu-zi-dian-yuan](https://oshwhub.com/zeruns/ji-yu-stm32-de-buck-boost-xing-shu-zi-dian-yuan) 正在复刻学习这个项目，其中代码里PID部分，有三个模式：BUCK，BOOST和MIX，但是我发现只有MIX模式里有IErr1 = IErr0;（电流环PID的历史误差更新）

 ![image](https://s3.eeclub.top/original/2X/0/0e8eb510ffbf3dc95cc16addc5a2037612dce085.jpeg)

（BUCK和BOOST模式的代码图，在备注（// 历史数据幅值）处没有IErr1 = IErr0;）

 ![image](https://s3.eeclub.top/original/2X/d/d98d86b10582b211402030defa98c18f98fea6ed.jpeg)

MIX模式代码图，在备注（// 历史数据幅值）处有IErr1 = IErr0;）这里不太理解为什么只有在MIX模式才做电流环的历史误差更新

---

<div class="post-metadata">

作者： ![lin](https://bbs.eeclub.top/letter_avatar_proxy/v4/letter/l/13edae/32.png) [@lin](https://bbs.eeclub.top/u/lin)\
发布日期： [2026 年3 月 16 日 12:44 UTC](https://bbs.eeclub.top/t/topic/292/2 "2026-03-16T12:44:24Z")

</div>

第一次发帖子忘记分类了不好意思

---

<div class="post-metadata">

作者： ![zeruns](https://bbs.eeclub.top/user_avatar/bbs.eeclub.top/zeruns/32/7_2.png) [@zeruns](https://bbs.eeclub.top/u/zeruns)\
发布日期： [2026 年3 月 16 日 13:43 UTC](https://bbs.eeclub.top/t/topic/292/3 "2026-03-16T13:43:55Z")

</div>

确实是漏了，你补上试试，不过我这电流环感觉写的不太行，不建议参考，电压环代码则是参考别人的
