Author Topic: Comparator hysteresis issues  (Read 1159 times)

0 Members and 1 Guest are viewing this topic.

Offline PentoadTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: gb
Comparator hysteresis issues
« on: November 02, 2019, 03:36:37 pm »
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.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Comparator hysteresis issues
« Reply #1 on: November 02, 2019, 03:48:44 pm »
Hysteresis needs positive feedback, not negative feedback.
 

Offline PentoadTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: gb
Re: Comparator hysteresis issues
« Reply #2 on: November 02, 2019, 04:15:43 pm »
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.
« Last Edit: November 02, 2019, 04:18:34 pm by Pentoad »
 

Offline MagicSmoker

  • Super Contributor
  • ***
  • Posts: 1408
  • Country: us
Re: Comparator hysteresis issues
« Reply #3 on: November 02, 2019, 04:24:05 pm »
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.

 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Comparator hysteresis issues
« Reply #4 on: November 02, 2019, 04:30:34 pm »
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?
.  That took much longer than I thought it would.
 

Offline duak

  • Super Contributor
  • ***
  • Posts: 1048
  • Country: ca
Re: Comparator hysteresis issues
« Reply #5 on: November 02, 2019, 06:02:04 pm »
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.
 
The following users thanked this post: Pentoad

Offline PentoadTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: gb
Re: Comparator hysteresis issues
« Reply #6 on: November 02, 2019, 06:14:02 pm »
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.


 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Comparator hysteresis issues
« Reply #7 on: November 02, 2019, 07:46:23 pm »
"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 to evenly divide the ~12.8V charging voltage between the cells.

I think the R5 pull up should be directly on the LM239 output.
.  That took much longer than I thought it would.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6420
  • Country: de
Re: Comparator hysteresis issues
« Reply #8 on: November 02, 2019, 07:50:42 pm »
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.

 

Offline PentoadTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: gb
Re: Comparator hysteresis issues
« Reply #9 on: November 02, 2019, 08:10:57 pm »
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?

« Last Edit: November 02, 2019, 08:13:57 pm by Pentoad »
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Comparator hysteresis issues
« Reply #10 on: November 03, 2019, 01:30:06 pm »
.  That took much longer than I thought it would.
 

Offline PentoadTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: gb
Re: Comparator hysteresis issues
« Reply #11 on: November 03, 2019, 01:52:43 pm »
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.
« Last Edit: November 03, 2019, 01:56:38 pm by Pentoad »
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Comparator hysteresis issues
« Reply #12 on: November 03, 2019, 02:07:37 pm »
"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
« Last Edit: November 03, 2019, 02:09:47 pm by StillTrying »
.  That took much longer than I thought it would.
 

Offline PentoadTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: gb
Re: Comparator hysteresis issues
« Reply #13 on: November 03, 2019, 04:06:45 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf