EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: t1d on December 27, 2019, 06:08:14 am

Title: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 06:08:14 am
I built this circuit on a breadboard. See schematic. I substituted a LED and 1K resistor to represent the e-load.
(https://www.eevblog.com/forum/beginners/comparator-odd-behavior-in-circuit/?action=dlattach;attach=897276)

I used an op amp tester to verify that the comparator functions properly. This schematic is provided, also.
(https://www.eevblog.com/forum/beginners/comparator-odd-behavior-in-circuit/?action=dlattach;attach=897272)

I have verified that all of the proper voltages are present on the comparator’s physical pins.

The voltage of +IN is one volt greater than the voltage of -IN, so OUT should go high. It does not. Please remember that this same chip tests as good.

I have done all of the typical troubleshooting that I know to do. I am stumped.

Thoughts and suggestions, please and thank you.
Title: Re: Comparator - Odd behavior in circuit
Post by: floobydust on December 27, 2019, 06:11:10 am
LM339 has open-collector output, so you need pullup resistor there to source current. I'd also add a little hysteresis resistor so it doesn't oscillate.
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 06:19:59 am
Thank you, floobydust, for the amazingly fast response. I will have to google your instructions, to understand what needs to be done, but I very much appreciate you pointing me in the correct direction.
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 06:37:33 am
Okay, floobydust... Open Loop means no feedback loop... Got it.

I think this is what you want for the pull up resistor, correct?
https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html (https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html)
(https://www.eevblog.com/forum/beginners/comparator-odd-behavior-in-circuit/?action=dlattach;attach=897306)

So, the comparator output is a sink, not a source. The pull up resistor holds the pin high, until the sink pin turns on and grounds out the MOSFET gate voltage, correct?

Thank you for your help and support.
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 06:43:50 am
I'd also add a little hysteresis resistor so it doesn't oscillate.
Umm... To add hysteresis, don't I use an inductor? If so, what value? If not, please explain what you mean. Thank you.
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 06:54:25 am
Corrected circuit. Will this do?
For hysteresis, do you mean an extra low value resistor on the pot, to always have some current limitation on that leg, even when the pot is set to zero?

(https://www.eevblog.com/forum/beginners/comparator-odd-behavior-in-circuit/?action=dlattach;attach=897314)
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 06:56:09 am
No, that change can not work... Give me a minute more...
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 07:01:51 am
Okay... This will accomplish setting the reference and holding the pin high. But, I still don't know about the hysteresis...
(https://www.eevblog.com/forum/beginners/comparator-odd-behavior-in-circuit/?action=dlattach;attach=897328)
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 07:14:25 am
Hmm... Seems that to address the hysteresis issue, I need to add a feedback resistor loop from the output pin to the battery voltage reference pin. The formula is shown. This article also suggests adding a cap across the feedback resistor, I think... I only scanned the article... If the cap is a good idea, what value? Am I on the right track?
https://www.analog.com/en/analog-dialogue/articles/curing-comparator-instability-with-hysteresis.html# (https://www.analog.com/en/analog-dialogue/articles/curing-comparator-instability-with-hysteresis.html#)
(https://www.eevblog.com/forum/beginners/comparator-odd-behavior-in-circuit/?action=dlattach;attach=897334)
Title: Re: Comparator - Odd behavior in circuit
Post by: floobydust on December 27, 2019, 07:35:38 am
I don't know the whole circuit, it has a few traps that I can see.
You are on the right track. You don't want the comparator to chatter or oscillate at the trip point. It is customary to add a hysteresis resistor ~1M-10M from LM339 output to (+) input to give positive feedback and cause it to switch solid. But your R1 1k resistor is small to allow that - how much hysteresis you need kind of depends on the battery voltage under test. I would increase your R1 to 10k with a 1M hys. resistor as a start.

Chatter will be a problem here in another way - once a battery's voltage drops and the comparator shuts off the MOSFET, the battery's voltage will creep up with no load and then circuit turns on the load and then off and then on, you see it hiccup. A latch is usually added so the MOSFET stays off once the comparator trips.

I think the MOSFET switch might not work as you intend. MTP3055VL would like at least 3.5V VGS for over 8A.
If you add a 1k-10k pullup resistor from the LM339 output to VREF_PS (+5V), the gate can go to +5V... but you do not have the source grounded, instead it goes to the load. So the source could be up a volt or two or three? In which case 5V on the gate is not enough to turn the MOSFET fully on as a switch, and it will run hot. The LED and its resistor are no good for a pullup because the LED drops a couple volts. You might want to consider a P-ch MOSFET or moving the load to the drain-side of the N-ch MOSFET if that is possible, the load not minding not being connected to the GND.
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 08:10:50 am
Thank you, floobydust. I will study this information and try to apply it.

I was trying to keep my opening question to the point. But, here's my objective... I have a lot of low voltage equipment - walkie talkies, GoPro camera, etc. - that doesn't get used all that often. I want to cycle the batteries to help keep them fresh. And, I have an electronic load. I am trying to build a Low Voltage Cutoff switch to interface the batteries with the e-load. Any suggestions are appreciated.
Title: Re: Comparator - Odd behavior in circuit
Post by: t1d on December 27, 2019, 08:48:19 am
I don't know the whole circuit,
Here is the whole schematic, with some of the changes you suggest. Please advise.

it has a few traps that I can see.
You are on the right track. You don't want the comparator to chatter or oscillate at the trip point. It is customary to add a hysteresis resistor ~1M-10M from LM339 output to (+) input to give positive feedback and cause it to switch solid. But your R1 1k resistor is small to allow that - how much hysteresis you need kind of depends on the battery voltage under test. I would increase your R1 to 10k with a 1M hys. resistor as a start.
Done. Please review changes.

Chatter will be a problem here in another way - once a battery's voltage drops and the comparator shuts off the MOSFET, the battery's voltage will creep up with no load and then circuit turns on the load and then off and then on, you see it hiccup. A latch is usually added so the MOSFET stays off once the comparator trips.
Excellent point! I will add a latch, but not tonight.

I think the MOSFET switch might not work as you intend. MTP3055VL would like at least 3.5V VGS for over 8A.
If you add a 1k-10k pullup resistor from the LM339 output to VREF_PS (+5V), the gate can go to +5V... but you do not have the source grounded, instead it goes to the load. So the source could be up a volt or two or three? In which case 5V on the gate is not enough to turn the MOSFET fully on as a switch, and it will run hot. The LED and its resistor are no good for a pullup because the LED drops a couple volts. You might want to consider a P-ch MOSFET or moving the load to the drain-side of the N-ch MOSFET if that is possible, the load not minding not being connected to the GND.
I moved the MOSFET as you advised and added a note to the supply that regulator should not be less than 5 volts.

I must stop, now, but I look forward to continuing with you. My many thanks!
[/quote]
(https://www.eevblog.com/forum/beginners/comparator-odd-behavior-in-circuit/?action=dlattach;attach=897414)