Micro controller based charging and discharging of Li-ion battery.

Thread Starter

Lavish Kumar Bansla

Joined Sep 1, 2017
Hey, guys please help here. It's urgent, Me and my friends are doing this project and the problem that we are facing is:
1- We needed a constant current source and sink that we have made (as shown in the figure) but now the current output from both of these is few mA like below 5-6mA but we need current outputs of almost Ampere or at least greater than 500mA so that the battery would charge and discharge quickly.
We have tried with LM317 but it was not working with Arduino(microcontroller).

So, please guys can u tell me what to do. What changes should I do to get high output current values?

I have to submit the project o 20 April 2018.

NOTE: We have removed that Voltage sensor and attached the 2.2Kohm resistance directly to Ao pin of Arduino.

The battery is of 3.7 V so we are providing a threshold of 3.2V above which charging would(that is constant current source circuit would start ) and below that discharging would start with a current sink.


Last edited:


Joined Jun 4, 2014
The maximum output current of the LM358 is around 40mA.
Also note that lithium batteries are prone to explode or catch fire if improperly charged or discharged so I would strongly suggest that you do not attempt to design such circuits when even the professionals get it wrong from time to time - Boeing, Samsung, etc.


Joined Mar 10, 2018
Expanded power current sinks, sources, covered here -


You could do this with a PSOC 4, it has a IDAC that can be used as a Vref, onboard
OpAmps (2), see attached -

What is the battery pack min and max V ?

It has the A/D and Vref to monitor battery pack V, and T, you add
a T sensor to it for the pack.

The board ($4) you would use is -

Here is an ap note using PSOC 5LP, you could port to 4 or use the
equivalent 5LP board, $ 10.


Regards, Dana.


Last edited:


Joined Mar 14, 2008
The AH rating of the battery gives a good indication of its charge rate.
Generally never exceed its AH rating in amps to charge it, i.e. a 2AH battery should not be charged at more than 2A.
Less is better.