Digital Power Supply Project - Questions about PID Code

https://oshwhub.com/zeruns/ji-yu-stm32-de-buck-boost-xing-shu-zi-dian-yuan I’m currently replicating and studying this project. In the code’s PID section, there are three modes: BUCK, BOOST, and MIX. However, I noticed that only in the MIX mode is there the line IErr1 = IErr0; (update of the current loop PID’s historical error).

(Code snippets for BUCK and BOOST modes—note that at the comment “// 历史数据幅值” (historical data magnitude), the line IErr1 = IErr0; is missing.)

(Code snippet for MIX mode—here, at the comment “// 历史数据幅值”, the line IErr1 = IErr0; is present.) I don’t quite understand why the update of the current loop’s historical error is performed only in MIX mode.

Sorry for forgetting to categorize my first post.

Indeed, that was missed. Try adding it back. However, I feel my current loop implementation isn’t very good and shouldn’t be used as a reference. The voltage loop code, on the other hand, was based on someone else’s work.