Author Topic: adding offset to comparator: LM311 doesn't work the way I expect  (Read 15904 times)

0 Members and 1 Guest are viewing this topic.

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
adding offset to comparator: LM311 doesn't work the way I expect
« on: November 27, 2020, 01:57:10 pm »
Hello my friends,

I often need a comparator/opamp with some predefined offset. Such as a current limiter, for example (see screenshot from lt1575 datasheet, showing shunt sense comparator). I thought I found an ingenious idea: using a compator with offset/balance pins. With two or three resistors I could define an offset, awesome! I include the picture of the schematic and simulation that I used to test my idea. Basically, I made a unity-gain buffer, and measured offset voltage between IN+ and IN- pins. Why I think I can use it in linear mode: the datasheet provides a few linear circuits. It seems to be working in sim, but not in reality. On screenshot you can see a ~50mV offset that roughly remains the same despite chaning input (I apply a sine-wave to input and measure difference between inputs).

The LT1011 part in simulator is kinda expensive, so I bought a venerable LM311P from TI. And it doesn't work :(. The first problem is that it wildly oscillated on my breadboard until I added an output capacitor (0.1u because that was the capacitor I had at hand). The next problem is offset voltage goes crazy. Even without any balancing, it is ~38mV (datasheet says 10mV max). Worse yet, after compensation it drifts a lot (tens of mv) with common-mode voltage.

I suspected a broken part, so I replaced one LM311 with another LM311P, but it behaves the same way. I suspected oscillation, but adding/changing capacitor on supply pins didn't change anything.

Any ideas what's wrong with this circuit?
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 17264
  • Country: de
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #1 on: November 27, 2020, 02:19:45 pm »
The offset voltage set by the compensation pin is usually quite temperature sensitive - kind of a simple PAT (proportional to absolute temperature) circuit.
So the offset trim pins are usually mainly to compensate the OPs / comparators own offset.

The LM311 is already quite fast and thus prone to oscillation on the breadboard.
Comparators are also missing the compensation that OPs have, so they easily oscillate when used with feedback. The circuits shown are kind of OK (still the drift) for an OP, but not a comparator.
 
The following users thanked this post: exe

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14132
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #2 on: November 27, 2020, 03:26:10 pm »
As the comparator is designed to to have a very high gain and fast slew rate, although its internal circuit has some similarities to an OPAMP, as Kleinstein has pointed out, its uncompensated, and *DOES* *NOT* provide access to the internal nodes required to add compensation.    Unity gain stability is particularly challenging to achieve for a fast OPAMP, so as the high gain and slew rate would put it in in that category if it was internally compensated,  it may be worth trying configuring your LM311 as a x10 non-inverting amplifier rather than as a unit gain buffer, so you can add some capacitance (say 100pF) from COL OUT to IN- to roll-off the HF gain. YMMV!  :popcorn:

I'm also dubious of the merits of slugging the HF response with a large capacitor on the output.  This works when its a comparator because, in conjunction with the limited output current, it acts as a glitch filter, but when configured as an OPAMP, in conjunction with the effective output impedance (dominated by the pullup resistor) it adds an undesirable extra pole in the frequency response, which tends to decrease the stability.  Its likely that its unstable even though you think its stable, and is acting as a class D PWM amplifier!  If you don't have a fast current probe, add a small resistor (say 10R) between EMIT OUT and ground, and probe it as a proxy for the current sunk by COL OUT, using a 50MHz or better bandwidth scope, to check for HF oscillation.

Also, I wouldn't even try to use a fast OPAMP, or a comparator as an OPAMP, on a breadboard without a 100nF decoupling cap directly across its supply pins!
 
LT's appnote 'Does Your Op Amp Oscillate?' may be of interest.
 
The following users thanked this post: exe

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #3 on: November 27, 2020, 03:44:42 pm »
Huh, I see the issues. Let me explain the application, may be I'm doing it wrong. I wanted a reasonably fast comparator to enable down-programmer in a power supply when output goes, say, +50mV above the set voltage. I don't need precision here, +-10mV variation is fine over the whole temperature range (say 25-50C). What do you think about using comparator with offset? I wanted to do it this way because of low component count.

BTW, I wanted to use LP311DR, which is a slower comparator, and it might help with stability. I ordered it about a week ago, but it will only arrive in a week or two (ordered from lcsc using cheap delivery, so I have to wait now).

An alternative could be, for example, lift the reference voltage with an instrumentation amplifier, but then I'd need a 50mV low-impedance reference to drive REF pin. But that would add quite a few parts: reference, reference buffer, instrumentation amp... I think there was an opamp or in-amp with a buffered reference pin, but can't find it now and it seems to be an exotic part.

PS I'll test the circuit with 10x gain and report results here. I'm curious to see the result.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 19228
  • Country: us
  • DavidH
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #4 on: November 27, 2020, 04:24:44 pm »
I'm also dubious of the merits of slugging the HF response with a large capacitor on the output.  This works when its a comparator because, in conjunction with the limited output current, it acts as a glitch filter, but when configured as an OPAMP, in conjunction with the effective output impedance (dominated by the pullup resistor) it adds an undesirable extra pole in the frequency response, which tends to decrease the stability.  Its likely that its unstable even though you think its stable, and is acting as a class D PWM amplifier!

That method works to implement dominant pole compensation; even with the extra phase shift, the gain drops below 1 before enough phase shift is present to cause oscillation.  It works with slower parts like the LM393/LM339 but probably not with an LM311 which might not even be stable in its linear range.  Using an LM311 in this way would require careful attention to power supply decoupling and layout.

Regulators often rely on dominant pole compensation because it produces low AC output impedance but it does severely limit bandwidth.

« Last Edit: November 27, 2020, 04:26:16 pm by David Hess »
 
The following users thanked this post: Ian.M

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #5 on: November 27, 2020, 05:49:23 pm »
I tried with 9:1 output divider and results are... inconsistent, including supply current and offset. I'm not sure what I'm doing wrong, it might wrong wiring or unstable contact, but I think I'll try to use it as a comparator. It's a bit more tedious to measure offset, but should be less prone to user errors.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 19228
  • Country: us
  • DavidH
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #6 on: November 27, 2020, 08:55:07 pm »
I tried with 9:1 output divider and results are... inconsistent, including supply current and offset. I'm not sure what I'm doing wrong, it might wrong wiring or unstable contact, but I think I'll try to use it as a comparator. It's a bit more tedious to measure offset, but should be less prone to user errors.

As was mentioned earlier, if you are trying this with the 311 on a solderless breadboard, you may be doomed to fail because of the high parasitic elements of the solderless breadboard.  The 311 is already prone to oscillation with less than ideal construction.

Check out the appendix of Linear Technology application note 13 "High Speed Comparator Techniques" for a discussion of this.
 

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #7 on: November 27, 2020, 10:06:12 pm »
Yeah, by using it as a compator I get more consistent results. Still, it's easy to make it oscillating even in this configuration. The measured offset is about 2-3mV or thereabout.

I'll stop experimenting with this one, and continue with lp311 when it arrives (a slower low-power version of lm311).
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22458
  • Country: gb
  • 0999
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #8 on: November 27, 2020, 11:19:01 pm »
I'm confused. You're talking about the LM311, but your schematic shows it configured as a unity gain op-amp. Comparator ICs, such as the LM311 are not designed to be used as linear amplifiers. You should use an op-amp IC if you want a linear amplifier, such as a unity gain buffer. The only reason for using a comparator as a linear amplifier, is when there's one spare in a package, i.e. the LM339, you need a linear amplifier and want to save cost/space.

The site linked below has a tool to assist designing an op-amp gain stage with a set amount of gain and offset.
http://earmark.net/gesr/opamp/
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 8066
  • Country: pl
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #9 on: November 28, 2020, 08:58:30 am »
Why not µA741, LM101, TL071 or similar?
They also have offset trim, they are opamps proper, they probabyl don't cost any more than LM311.
 

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #10 on: November 28, 2020, 10:41:28 am »
You're talking about the LM311, but your schematic shows it configured as a unity gain op-amp.

That was only to measure offset voltage. The attempt was unsuccessful :). In a feedback configuration I can measure offset with a dmm. Otherwise, I think, I need an oscilloscope that is set to trigger on output change, which seemed to be more work to setup and less precise.

Why not µA741, LM101, TL071 or similar?
They also have offset trim, they are opamps proper, they probabyl don't cost any more than LM311.

Thanks, I'm ordering TL071/TL051. The reasons they are a second choice are phase reversal and saturation recovery. That's why I wanted to use a proper comparator. I still want to try them, may be those issues are not issues. Tonight or tomorrow I'll try to use TL072/TL052 as a comparator (I don't have any ICs with trim pins apart from LM311). May be it will work well.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22458
  • Country: gb
  • 0999
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #11 on: November 29, 2020, 05:58:44 pm »
You're talking about the LM311, but your schematic shows it configured as a unity gain op-amp.

That was only to measure offset voltage. The attempt was unsuccessful :). In a feedback configuration I can measure offset with a dmm. Otherwise, I think, I need an oscilloscope that is set to trigger on output change, which seemed to be more work to setup and less precise.
Measuring the offset voltage of a comparator is tricky. It can be done without an oscilloscope, with just a DVM and a triangle wave generator.

If the comparator has no offset, then if one input is 0V and a symmetrical triangle wave is applied to the other input, the output should have a 50% duty cycle.

You can measure the offset voltage by applying a symmetrical triangle wave input to one input and looking at the duty cycle of the output. For example, if inverting input is held at 0V and the non-inverting input has 1mV of offset and a 10mV peak triangle wave is applied to it, the duty cycle of the output will be 55%. If the power supply is +/-10V and the output swings from rail-to-rail, the average output voltage will be 1V.
 
The following users thanked this post: exe, Ian.M

Offline magic

  • Super Contributor
  • ***
  • Posts: 8066
  • Country: pl
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #12 on: November 29, 2020, 06:51:36 pm »
What's supposed to be wrong with simply applying a test voltage of a few mV to the input and watching the output? :-//
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22458
  • Country: gb
  • 0999
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #13 on: November 29, 2020, 07:00:37 pm »
What's supposed to be wrong with simply applying a test voltage of a few mV to the input and watching the output? :-//
Noise could make that tricky to do in practice.
« Last Edit: November 29, 2020, 09:39:06 pm by Zero999 »
 

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #14 on: November 29, 2020, 10:34:07 pm »
What's supposed to be wrong with simply applying a test voltage of a few mV to the input and watching the output? :-//

I did that, it was surprisingly unstable. The voltage was applied via a trimpot which I slowly rotated. There was quite a big "deadband" when it was oscillating. I know that because I connected a led to the output (with 27kOhm pull-up resistor), there was +-a few mV when led was dim or even visibly oscillating. So, I'm saying that offset is no more than 2mV because that's the smallest change on input that reliably switches output from one state to another. So, definetely not a noob-friendly device :/.

PS ordered tl071 lp311, I'm eager to see how they perform, esp how stable offset vs temperature is.
PPS Natsemi's datasheet says "The LP311 is quite easy to apply without any oscillation". Will see, he-he.
« Last Edit: November 29, 2020, 10:35:57 pm by exe »
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 8066
  • Country: pl
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #15 on: November 30, 2020, 08:00:33 am »
I might need to try it myself, I can't believe it's that bad :scared:

Did you try with the trimpot across the rails and divided down with something like 10kΩ:10Ω?
 

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #16 on: November 30, 2020, 09:28:54 am »
I have a single 15V rail, a reference voltage somewhere in the middle of supply, and a 10 kOhm trimpot. I also added 0.1u capacitor from trimpot output to ground, this helped a little bit.
 

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2500
  • Country: mx
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #17 on: November 30, 2020, 05:27:24 pm »
In the original National Semi datasheet, there was a full page devoted to techniques to avoid comparator oscillations.
Unfortunately, TI decided to delete that information on the current datasheet.

However I found the OnSemi datasheet still includes it, page 7.
 
The following users thanked this post: exe

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22458
  • Country: gb
  • 0999
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #18 on: November 30, 2020, 09:21:47 pm »
In the original National Semi datasheet, there was a full page devoted to techniques to avoid comparator oscillations.
Unfortunately, TI decided to delete that information on the current datasheet.

However I found the OnSemi datasheet still includes it, page 7.
Here's a the classic National Semiconductor data sheet.
I have a single 15V rail, a reference voltage somewhere in the middle of supply, and a 10 kOhm trimpot. I also added 0.1u capacitor from trimpot output to ground, this helped a little bit.
Regarding biasing the LM311 in its linear region, to measure the offset voltage. Have you tried using the emitter output (pin 1) for the output? A capacitor between pin 5 and 1 might also help. Try a high gain inverting configuration, which should also make it more stable. Bear in mind, the functions of the inverting and non-inverting inputs reverse, if pin 1 is used as an ouptut.
 

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #19 on: December 01, 2020, 11:22:03 am »
Regarding biasing the LM311 in its linear region, to measure the offset voltage. Have you tried using the emitter output (pin 1) for the output? A capacitor between pin 5 and 1 might also help. Try a high gain inverting configuration, which should also make it more stable. Bear in mind, the functions of the inverting and non-inverting inputs reverse, if pin 1 is used as an ouptut.

Thanks for the datasheet.

I'll try high-gain configuration if I have time till Thursday. On Thursday I expect LP311 and TL071 to arrive, so I continue with those parts. Dang, time is at premium this week :(.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 19228
  • Country: us
  • DavidH
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #20 on: December 02, 2020, 03:11:55 am »
Its likely that its unstable even though you think its stable, and is acting as a class D PWM amplifier!

That actually is a valid way to find the input offset voltage of a comparator.  Somewhere I have seen an application note where a comparator is placed into a negative feedback loop to sample and then hold the input offset voltage correction.
 

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #21 on: December 05, 2020, 08:18:26 pm »
My friends, I only managed to do a small set of tests for tl071. I think I managed to fry one (balance pin was connected to output held at ~Vcc because I left a small jumper on the breadboard :/ ). The current was limit to 10mA on power supply, but I'm still not sure if chip is fine, even though, according to the circuit, blancing pins are connected to internal 1k "pull down" resistors.  So re-doing experiments on the second chip.

On fresh tl071, I tested only "static" characteristics. I wanted to see how wide is common-mode voltage and what is power consumption. So, at 15V single supply useable common mode in buffer (unity-gain) configuration is Vee+3 to Vcc-1. Outside this window offset noticeably changes, esp. at around Vee+2.5 or thereabout it goes phase reversal, wee :). Offset voltage is very good, imho, remains less than 100uV in range 4V-14.2V. It is also stable with temperature, heating up to 70C (heated with heatgun, crudely controlled with a thermocouple) didn't change it much.

Next is to check dynamic characteristics, adding offset and hysteresis.  That's for tomorrow or later.

PS forgot to mention power consumption. It normally consumes ~2.1mA, and only when input voltage is above 14.3V it goes to "typical value from datasheet" of 1.4mA. That's a bit weird to me.
« Last Edit: December 05, 2020, 08:22:13 pm by exe »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22458
  • Country: gb
  • 0999
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #22 on: December 05, 2020, 09:40:58 pm »
My friends, I only managed to do a small set of tests for tl071. I think I managed to fry one (balance pin was connected to output held at ~Vcc because I left a small jumper on the breadboard :/ ). The current was limit to 10mA on power supply, but I'm still not sure if chip is fine, even though, according to the circuit, blancing pins are connected to internal 1k "pull down" resistors.  So re-doing experiments on the second chip.

On fresh tl071, I tested only "static" characteristics. I wanted to see how wide is common-mode voltage and what is power consumption. So, at 15V single supply useable common mode in buffer (unity-gain) configuration is Vee+3 to Vcc-1. Outside this window offset noticeably changes, esp. at around Vee+2.5 or thereabout it goes phase reversal, wee :). Offset voltage is very good, imho, remains less than 100uV in range 4V-14.2V. It is also stable with temperature, heating up to 70C (heated with heatgun, crudely controlled with a thermocouple) didn't change it much.

Next is to check dynamic characteristics, adding offset and hysteresis.  That's for tomorrow or later.

PS forgot to mention power consumption. It normally consumes ~2.1mA, and only when input voltage is above 14.3V it goes to "typical value from datasheet" of 1.4mA. That's a bit weird to me.
How do you know whether it's the common mode range, or output stage which is limiting the voltage range of the unity gain buffer? You'll find the TL071 will normally work with its inputs all the way up to the positive rail, so it's probably the output stage which is the limiting factor there.

Another thing to note is that when the inputs are too close to the negative rail, the bias current shoots up, as the J-FET gate junctions become forward biased.
 
The following users thanked this post: exe

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #23 on: December 11, 2020, 09:43:42 pm »
How do you know whether it's the common mode range, or output stage which is limiting the voltage range of the unity gain buffer?

Trap for young players :). Yes, that was the case.

So far I measured only tl071 with no offset. I'm attaching the picture of measurements. Yellow line is difference between IN+ and IN-, common voltage is 4V. Blue line is output, loaded with 10k resistor and a red led. Power supply is 15V, average current consumed by the circuit is 2.8mA, input is 10kHz wave. Key observations: raise time is 7us, virtually no delay before input starts changing. Fall time is 5us, with 3us of overload recovery. Output swing is 12.7V. This gives rising speed of 1.8V/us, and falling 2.5V/us (measured from 0 to 100% of change), which is well below advertised slew rate of 20V/us. I'm not sure what I'm doing wrong. Even if I only take into account raise time of output change 10% to 90%, it's still slow.
 

Online exeTopic starter

  • Supporter
  • ****
  • Posts: 3041
  • Country: nl
  • self-educated hobbyist
Re: adding offset to comparator: LM311 doesn't work the way I expect
« Reply #24 on: December 13, 2020, 04:02:04 pm »
Here is tl051. I expected it to show same performance as tl071 as I suspected it's the same IC, but no, it's slightly better. It consumes +0.5mA more in my test scenario. It's a bit faster: 3us vs 3.5us rise time*, 2.4us vs 2.7us fall time, and recovery is marginally better (2.2us vs 3.1us). Loading input with led (adds +0.6mA on average) doesn't really change output, except makes output swing slightly shorter at positive rail.

I'm still puzzled by slew rate, much slower than I expected. Might it be that slew rate is, say, a "small signal" parameter, or only applicable with negative feedback?


* Rise and fall times are measured by waveforms (software). It seems it only measures time between ~10% and ~90% of "final value".
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->