Comparator hysteresis issues - Page 1
Forum section: electronics / projects

author: Pentoad
author_rank: Regular Contributor
timestamp: November 02, 2019, 03:36:37 pm
content: I am using an LM239DT comparator in a project and can't get hysteresis to work at all. I have followed various design guides and used calculators but I can't stop it from transitioning rapidly as the input voltage approaches the threshold voltage. Adding in hysteresis resistors only has the effect of changing what voltage this fast transitioning occurs at. I have properly terminated the unused comparator in the chip as previously advised and this improved things a bit. Although not shown, the comparator has a 100nf capacitor on its supply and it's positive supply is connected to K14 which is just the output of a relay.

author: SiliconWizard
author_rank: Super Contributor
timestamp: November 02, 2019, 03:48:44 pm
content: Hysteresis needs positive feedback, not negative feedback.

author: Pentoad
author_rank: Regular Contributor
timestamp: November 02, 2019, 04:15:43 pm
content: I never knew that. I swapped the inputs around and now hysteresis appears to be working as it should. I won't be able to use a P channel mosfet anymore though because the comparator output pulls down to ground when triggered.

author: MagicSmoker
author_rank: Super Contributor
timestamp: November 02, 2019, 04:24:05 pm
content: More specifically, the feedback resistor for hysteresis always goes to the Non-Inverting input, and if the reference also connects to that input then it needs to be through a resistor so that summing can occur.

author: StillTrying
author_rank: Super Contributor
timestamp: November 02, 2019, 04:30:34 pm
content: I won't be able to use a P channel mosfet anymore though because the comparator output pulls down to ground when triggered.Use the spare comparator as an inverter?R1 and R5 should be supplying just the feedback voltage not the gate drive?

author: duak
author_rank: Super Contributor
timestamp: November 02, 2019, 06:02:04 pm
content: I would also connect the right hand end of R13 directly to the output (U1A-2) because the drive signal transition times are far slower right on the FET. The value of R13 can also be increased to reduce the width of the hysteresis band.

author: Pentoad
author_rank: Regular Contributor
timestamp: November 02, 2019, 06:14:02 pm
content: I've managed to get an N channel mosfet working and this is how it's looking now. In regards to hysteresis, is resistor R12 really needed? The circuit still works without it and that means the only resistor I will need to play around with is R13.This whole thing is part of a cell balancing module which will be placed on each cell of a lithium ion battery. The balance voltage is adjustable. The only way I will know if the design is any good is to get a few of them made and see if they can keep the pack within a few millivolts.

author: StillTrying
author_rank: Super Contributor
timestamp: November 02, 2019, 07:46:23 pm
content: "This whole thing is part of a cell balancing module which will be placed on each cell of a lithium ion battery."The low impedance of a battery as input to the comparator will mean the R12 100k is needed, probably a much lower value to give a very much smaller hysteresis, surely you'd want it to switch on and off over a very small voltage range such as 4.18V and 4.20, with the mid 4.19V being adjustable."The only way I will know if the design is any good is to get a few of them made"You should be able to simulate something of a ladder of 3 or 4 cells, I simulated something similar myself using a string of resistors toevenlydivide the ~12.8V charging voltage between the cells.I think the R5 pull up should be directly on the LM239 output.

author: Benta
author_rank: Super Contributor
timestamp: November 02, 2019, 07:50:42 pm
content: There are several issues with your circuit.1: The LMx39 has an open-collector output (as most comparators), meaning it needs a pullup resistor at its output. In your circuit, this is implemented with R20 + R5. It works, but is not optimal.2: With R12 and R13 you have an immense hysteresis, namely half the supply voltage. I'm not certain if this is what you want.3: You give no indication of what voltage is present at "K1 4". This makes it difficult to help.4: Yes, you can eliminate R12. The combination of R21, R22 and R3 will give you hysteresis, but it will vary with the position of R3.Several issues are unclear here, but your circuit is really not good.

author: Pentoad
author_rank: Regular Contributor
timestamp: November 02, 2019, 08:10:57 pm
content: I'm aware of the hysteresis issue with R12 and 13, this will definitely be experimented further with and rectified. I'm only wanting about 10mv of hysteresis at most.This is how the power supply is arranged, I've designed the system such that it can be totally turned off using the relay if the battery is to be unused for a long period of time. The relay is powered by an external source of 5v.The pullup arrangement was mentioned as not being optimal. Is there a better way to drive my mosfet? Perhaps using the spare comparator in the chip in an inverter arrangement?If the circuit is not good at all, is there a better way of going about this?

author: StillTrying
author_rank: Super Contributor
timestamp: November 03, 2019, 01:30:06 pm
content: You don't show how the cells are connected in series, or not, that's quite an important bit in getting each cells supply and reference to work.https://forum.allaboutcircuits.com/threads/battery-charging-cutoff-using-tl431.137944/https://320volt.com/en/balancing-li-ion-li-polymer-batteries-battery-balancing-circuit/https://sound-au.com/articles/lithium-charging.htm

author: Pentoad
author_rank: Regular Contributor
timestamp: November 03, 2019, 01:52:43 pm
content: Each cell has one of these circuits on it and the cells are connected in series. B- is cell negative and B+ is cell positive. K1 4 is just the output of the relay which will be on each module so K1 4 is connected through the relay to B+ when the relay coil is energised using an external 5v source. The comparator and all other electronics in the module are powered by the cell and the modules are not connected to each other in any other way. I will add the full diagram later today.

author: StillTrying
author_rank: Super Contributor
timestamp: November 03, 2019, 02:07:37 pm
content: "The comparator and all other electronics in the module are powered by the cell"Makes sense.If powering the LM239 from the 3V-4.2V cell voltage, you'll have to make its ref voltage and its cell voltage inputs about half(or less) = 1.5V-2.2V because the LM239's inputs don't work within 1.5V of its VCC.http://www.ti.com/product/LM239

author: Pentoad
author_rank: Regular Contributor
timestamp: November 03, 2019, 04:06:45 pm
content: I was a bit concerned about that. I am using a 2.048v LM4040 so that's a bit close. Looks like I will have to find one of a lower voltage as one of the comparators is being used for low voltage cutoff detection as low as 2.5v if the module is to be used on lifepo4. This appeared to work in my tests however but will probably be unstable as the reference is too close to the supply voltage in this condition.