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 MIX mode is there the line IErr1 = IErr0; (updating the historical error for the current-loop PID).

(The code for BUCK and BOOST modes, where at the comment “// 历史数据幅值” (“historical data magnitude”)) does not include IErr1 = IErr0;)

(Code for MIX mode, where at the comment “// 历史数据幅值” (“historical data magnitude”) includes IErr1 = IErr0;)

I don’t quite understand why the update of the current-loop PID’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.