im implementing single switched active cel balancing but the soc of both cells are not equal, what is the error in the logic of this code? function [s1,s2,s3,s4] = fcn(SOC1,SO
Show older comments
im implementing single switched active cel balancing but the soc of both cells are not equal, what is the error in the logic of this code? function [s1,s2,s3,s4] = fcn(SOC1,SOC2,P1,P2)
if SOC2<SOC1
s1=P1;
s2=P1;
s3=P2;
s4=P2;
elseif SOC1<SOC2
s1=P1;
s2=P1;
s3=P2;
s4=P2;
else
s1=0;
s2=0;
s3=0;
s4=0;
end
end

Answers (1)
Sabin
on 26 Apr 2026
0 votes
Looks like the wiring in the model is the problem not necesarly the function. Sure, the function can be improved since elseif branck is setting the same pulse order (you can re write it simple as if SOC1 ~= SOC2, pulses else zero pulses end). For an example about how to do switched capacitor balancing and how to wire the switches check this: https://www.mathworks.com/help/simscape-battery/ug/balance-battery-cells-with-switched-capacitor-method.html
Categories
Find more on Multiprocessor Architecture Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!