Comparator Oscillation

Thread Starter


Joined Oct 11, 2011

I am working on a project using Lithium Ion batteries. From what I understand you cannot charge and discharge a battery at the same time. You can do either but not both at the same time. To that end I opted to have two 12.6v Li-ion batteries one being charged and one discharging (ie powering the system).

To switch between the batteries and whether it is charging or discharging I have chosen to use comparators Lm239p an N-Chanel Mosfets.

Basically i want to compare the voltage of the two batteries and if the voltage of one is higher that battery will activate the gate of the transistor to allow discharging. and it switches the battery between charging and discharging based on the output of the comparators which are connected to the gate's of the transistors.

My main question is how do I keep from oscillations when A is about the same as B i.e.

say Bat A= 12.6v drops to 11 v and Bat B which is 10 volts rises to 11v.

B may become higher but A is now charging which may quickly make A higher, and now we have quick oscillation between on and off.

Any ideas on a better design or how to prevent oscillations.

Thanks in advance.

The overall purpose is to manage which battery is charging and which battery is discharging.


Joined Jul 17, 2007
Hello cris242,

To keep a comparator from oscillating, you need to add a characteristic called "hysteresis".
Hysteresis is the basis for a Schmitt trigger:

Here is an online design tool that will help you in determining components for comparator circuits with hysteresis:

Rob Paisley has a good page on understanding how comparators work: