# Passive Cell Balancing Simulation In Matlab Simulink

Hello guys, welcome back to my blog. In this article, I will discuss passive cell balancing simulation in Matlab Simulink, I will also share Matlab function code, components details, circuit diagram, and working of the circuit.

If you require an article on some other topics then comment us below in the comment box. You can also catch me @ Instagram - Chetan Shidling.

## Passive Cell Balancing Simulation In Matlab Simulink

The image shows a circuit diagram of passive cell balancing. The battery pack is 12 volts and 2.6AHh. It consists of three lithium-ion cells connected in series. Each cell is connected to the load resistance through Mosfet.

Passive cell balancing means equalizing the state of charge of each cell by wasting or dissipating energy through a resistor. In passive cell balancing, all each state of charge value will be brought to the one cell value which has a low state of charge. As you can see in waveforms below.

### Initial values of cell 01

The initial state of charge of the lithium-ion cell is 15%.

### Initial values of cell 02

The initial state of charge of a lithium-ion cell is 35%.

### Initial values of cell 03

The initial state of charge of a lithium-ion cell is 50%.

The state of charge of each cell is different when the passive cell balancing will be applied, the state of charge of each cell will come to 15% because the cell 1 has a low state of charge compared to others.

The circuit consists of components such as;

01. Resistor - To dissipate the energy, the resistor is used at each cell.

02. MOSFET - It acts as a switch. when all cells state of charge becomes equal, the MOSFET is turned off and the circuit will become open.

03. Lithium-ion cell - Which stored energy. We are applying passive cell balancing for the lithium-ion cells.

04. Goto - By using goto, we are passing the state of charge value to from and then to Matlab function.

05. From - It is input to the Matlab function which holds the value of the state of charge.

06. Display - To display the value of the state of charge, I am using the display.

07. Scope - To see the waveform of state of charge, I am using the scope.

08. Matlab function

Code which I am using, hope it works for you.

### Matlab Function Code

function [y1, y2, y3]= fcn(s1,s2,s3)
s1 = int16(s1);
s2 = int16(s2);
s3 = int16(s3);

a = min([s1 s2 s3]);
if(s1 == a)
if(s1 == a && s2 == a)
y1 = 0;
y2 = 0;
y3 = 1;
elseif(s1 == a && s3 == a)
y1 = 0;
y2 = 1;
y3 = 0;
elseif(s1 == a)
y1 = 0;
y2 = 1;
y3 = 1;
else
y1 = 0;
y2 = 0;
y3 = 0;
end
elseif(s2 == a)
if(s2 == a && s3 == a)
y1 = 1;
y2 = 0;
y3 = 0;
elseif(s2 == a && s1 == a)
y1 = 0;
y2 = 0;
y3 = 1;
elseif(s2 == a)
y1 = 1;
y2 = 0;
y3 = 1;
else
y1 = 0;
y2 = 0;
y3 = 0;
end

elseif(s3 == a)
if(s3 == a && s2 == a)
y1 = 1;
y2 = 0;
y3 = 0;
elseif(s3 == a && s1 == a)
y1 = 0;
y2 = 1;
y3 = 0;
elseif(s3 == a)
y1 = 1;
y2 = 1;
y3 = 0;
else
y1 = 0;
y2 = 0;
y3 = 0;
end
else
y1 = 0;
y2 = 0;
y3 = 0;

end

This code compares the state of charge of each cell and gives the respected output. Suppose, if the state of charge of cell 02 is low then it will give high output for MOSFET of cell 1 and cell 2.

Now, I will share values of state of charge and waveform after simulation. The simulation time it took was 2600 seconds.

### Working

Initially, the state of charge of each cell is different. The state of charge value is given to the Matlab function, where the code is written which will compare the state of charge of each cell and accordingly produces the output. The output is connected to the gate of the MOSFET, by which the circuit is controlled.

### Waveform Of Passive Cell Balancing

See the above waveform, state of charge of cells becoming equal.