# Battery Simulator

#### sham1810

Joined Nov 21, 2015
6
Hi,

I have an assignment to implement a battery balancing simulator. I am assuming a two-step linear discharge curve for the battery. For this assignment i will only consider the discharge cycle. I want to use a simple algorithm that balances based on voltage difference between the batteries, such that if the difference is more than a specified threshold the battery with lower voltage is switched off. But when i calculate the current sourced from each battery the battery with the maximum voltage supplies all the current and other batteries receive current even when the difference is below threshold. It makes sense that this would happen but then how does a battery pack work if there is a minor difference in the voltages in the batteries and the cell with highest voltage supplies all the current? Any suggestions on how can i improve the algorihtm is also welcome. Thanks.

#### Alec_t

Joined Sep 17, 2013
11,801
But when i calculate the current sourced from each battery the battery with the maximum voltage supplies all the current and other batteries receive current even when the difference is below threshold.
You have nothing in your circuit to define a threshold.
Welcome to AAC!

#### sham1810

Joined Nov 21, 2015
6
You have nothing in your circuit to define a threshold.
Welcome to AAC!
Thanks for the reply. By threshold I meant any randomly selected value (for ex if if its 1V). If the voltage difference is more than 1V the battery with lower voltage is switched off.

#### Alec_t

Joined Sep 17, 2013
11,801
If randomly selected, you will need a comparator to determine if the voltage difference exceeds the threshold or not. If you were happy with a fixed threshold of about 0.6V to 0.7V you could use NPN or PNP transistors to switch the battery on/off. However, with a voltage difference as great as that the batteries would not be balanced properly. Ideally there should be only a few mV difference in their voltages.

#### MikeML

Joined Oct 2, 2009
5,444
I dont understand what you are trying to do?

Are you trying to compare the voltages of the batteries pair-wize? If so, you have three pairs.

If A>C and B>C, then obviously you should be taking the load from B????

Because internal resistance of the battery carrying the load causes the output voltage to drop the instant a load is connected, then that screws up the comparison, so you will be building an oscillator...

#### Alec_t

Joined Sep 17, 2013
11,801
Simply closing all three switches in your post #1 circuit will tend to equalise the batteries. The one with the higher voltage will drive the load and charge the other batteries.

#### sham1810

Joined Nov 21, 2015
6
I dont understand what you are trying to do?

Are you trying to compare the voltages of the batteries pair-wize? If so, you have three pairs.

If A>C and B>C, then obviously you should be taking the load from B????

Because internal resistance of the battery carrying the load causes the output voltage to drop the instant a load is connected, then that screws up the comparison, so you will be building an oscillator...
I have to write a program that switches the batteries on and off to keep them balanced. For that i'm using a battery balancing algorithm which switches off a battery if its voltage drops below a specified theshold when compared to other batteries. Ideally as Alec mentioned above the difference should be in mV. In this scenario the battery with the highest voltages ends up sourcing all the current for load and charging other batteries. Is this also the case with real battery packs? Because i thought batteries were connected in parallel to share the current load which doesn't seem to be happening.

#### JoeJester

Joined Apr 26, 2005
4,390
Those three resistors in series with the three switches, are they representing Ri of the respective batteries?

If they are NOT, you can sample the Voltage drop across them representing the current supplied by each battery. The battery would be "isolated" from the load, making the determination of which battery is truly lower than the other two.

#### sham1810

Joined Nov 21, 2015
6
Those three resistors in series with the three switches, are they representing Ri of the respective batteries?

If they are NOT, you can sample the Voltage drop across them representing the current supplied by each battery. The battery would be "isolated" from the load, making the determination of which battery is truly lower than the other two.
Yes they represent the internal resistance of the batteries.

#### WBahn

Joined Mar 31, 2012
26,398
I have to write a program that switches the batteries on and off to keep them balanced. For that i'm using a battery balancing algorithm which switches off a battery if its voltage drops below a specified theshold when compared to other batteries. Ideally as Alec mentioned above the difference should be in mV. In this scenario the battery with the highest voltages ends up sourcing all the current for load and charging other batteries. Is this also the case with real battery packs? Because i thought batteries were connected in parallel to share the current load which doesn't seem to be happening.
Batteries are connected in lots of different configurations for lots of different reasons. I had a dual battery system in my truck, in part so that I could run comms all night long out in the field with the truck engine off and not have to worry about draining both batteries so that I couldn't start the truck in the morning. But I also needed to power some basic things, such as the clock and the control circuits for the battery isolators, continuously regardless of which battery was at the higher state of charge and without letting one battery drain the other, so I simply put a diode in series with each battery to that circuit. Yes, I lost some power across the diode, but that was acceptable and it worked perfectly.

It seems like one thing you might be looking to do is have more than one battery engaged at a time so as to get the higher total current draw possible from the paralleled configuration. If so, then what you probably need is a way of monitoring the current direction in each battery (assuming you don't want to use a diode -- but you can get very low voltage drop "diodes") and shutting off batteries that are back feeding.