The Tricky LM311 - The "Output" Pin (Pin 7) is the Collector of an Internal NPN Transistor - It Sinks Current

Thread Starter

brockrwood

Joined Oct 23, 2016
89
Getting the output pin of the LM311 comparator IC to do anything was a head scratcher for me until I saw this website that shows the simplified internal organization of the LM311:

https://diyodemag.com/education/the_classroom_the_lm311_voltage_comparator

The output pin, pin 7, is NOT the output of the op-amp inside the LM311. The output of the op-amp inside the LM311 is connected to the base of an internal NPN transistor. The collector of the transistor is connected to pin 7. The emitter of the transistor is connected to pin 1. When the voltage on the inverting input (pin 3) is higher than the voltage on the non-inverting input (pin 2), the internal op-amp sends an output current to its internal output.

That internal output of the op-amp is connected to the base of the NPN transistor and turns on the NPN transistor.

That let's a current flow from pin 7 (the "output" pin - badly named), through the transistor, to pin 1, the "ground" pin. Remember, the emitter of the transistor is connected to pin 1.

So, when the op-amp turns on, it basically flips on a "switch" between pin 7 and pin 1.

So, pin 7 is SINKING current. It is the collector of the internal NPN transistor which is acting as a "low side" switch. Connect a load to pin 7 and the load is connected to ground through pin 1 when the op-amp turns on.

The internal NPN transistor can handle up to 50 mA of current. So, for low current, single supply type projects, just connect the load to the positive supply rail and then connect the other side of the load to pin 7. Connect pin 1 and pin 4 to ground.
 

Alec_t

Joined Sep 17, 2013
14,310
What you are describing is known as an "open collector output". Many comparators (and other ICs) have this arrangement. This output would normally be used with a load resistor connected between the collector and the positive supply rail.
 

Thread Starter

brockrwood

Joined Oct 23, 2016
89
What you are describing is known as an "open collector output". Many comparators (and other ICs) have this arrangement. This output would normally be used with a load resistor connected between the collector and the positive supply rail.
Thanks!

I have created this schematic of the LM311 for myself to remind me how to use it!

IMG_9491.jpg
 

dl324

Joined Mar 30, 2015
16,896
I have created this schematic of the LM311 for myself to remind me how to use it!
It's unnecessary. The original integrated voltage comparators were all open collector. Some of the newer comparators have totem pole outputs, but they can't always be substituted for older designs.

From Fairchild datasheet:
1703966887392.png
R4 makes it unsuitable for some applications.
 

Alec_t

Joined Sep 17, 2013
14,310
The symbol you have labelled "not true" is in fact used for various open-collector comparators. The transistor you show is part of the circuitry represented by the triangle. See e.g this datasheet for the LM293.
 
Last edited:

Thread Starter

brockrwood

Joined Oct 23, 2016
89
The symbol you have labelled "not true" is in fact used for various open-collector comparators. The transistor you show is part of the circuitry represented by the triangle. See e.g this datasheet for the LM293.
Sadly, I am just an electronics hobbyist and my knowledge is incomplete and inaccurate in many, many areas. I assumed (you know what happens when you ASSUME) that a pin labeled "output" would SOURCE current. Not true. Live and learn.

So, if I want the LM311 to control more than 50 mA, I connect a pull-up resistor (value? 10K?) to pin 7 and then use pin 7 to control an external transistor (PNP?) that controls the load?
 

dl324

Joined Mar 30, 2015
16,896
Sadly, I am just an electronics hobbyist and my knowledge is incomplete and inaccurate in many, many areas. I assumed (you know what happens when you ASSUME) that a pin labeled "output" would SOURCE current. Not true. Live and learn.
As such, you're not likely to discover anything that many haven't already discovered.
So, if I want the LM311 to control more than 50 mA, I connect a pull-up resistor (value? 10K?) to pin 7 and then use pin 7 to control an external transistor (PNP?) that controls the load?
It would be helpful if you posted a schematic. Without knowing what you have in mind, I'd just swap the comparator inputs and put an NPN on the output.

Another option is to use a split Darlington configuration on the output:
1703969111477.png
R17 (just a number left over from the schematic I used) needs to be sized appropriately. Current in Q1 needs to be about 10% of the current in Q2. Since the datasheet doesn't give a typical value for R4, I guess it's around 25ohms.
 

Ian0

Joined Aug 7, 2020
9,764
LM311 is different from the other open-collector comparators. All the others (LM393, LM339) have the emitter of the output transistor connected to the negative supply.
Because LM311 doesn't have an input common mode voltage that extends to the negative supply, it has to have separate ground and negative supplies.
Does anyone (except @brockrwood ) still use the LM311? There are so many more modern comparators that don't have its problems!
 
Last edited:

dl324

Joined Mar 30, 2015
16,896
So, if I want the LM311 to control more than 50 mA, I connect a pull-up resistor (value? 10K?) to pin 7 and then use pin 7 to control an external transistor (PNP?) that controls the load?
Note that I used a split Darlington configuration in post #10 instead of the more typical configuration with the collectors tied together. Splitting the collectors allows the external transistor to saturate.
 

MrChips

Joined Oct 2, 2009
30,779
There are a number of things they don't teach you in school.
This is simply just another one of them that is likely to trip up newcomers to the field.
This is why we have sites like All About Circuits where we learn from those who have been there, seen it, done that!

Here is another one of those gems to remember.
2N2222 and P2N2222 pinouts are different.

1703971520422.png
 

Thread Starter

brockrwood

Joined Oct 23, 2016
89
As such, you're not likely to discover anything that many haven't already discovered.
It would be helpful if you posted a schematic. Without knowing what you have in mind, I'd just swap the comparator inputs and put an NPN on the output.

Another option is to use a split Darlington configuration on the output:
View attachment 311286
R17 (just a number left over from the schematic I used) needs to be sized appropriately. Current in Q1 needs to be about 10% of the current in Q2. Since the datasheet doesn't give a typical value for R4, I guess it's around 25ohms.
The schematic:

IMG_9498.jpg

I am charging a 12V NiCd battery pack using a very simple constant current charging circuit built around the LM350 voltage regulator IC.

I want the LM311 to sense when the voltage at the battery is 14.5 volts (full charge) and turn on an LED to tell me it is time to take the battery off of the charger.

Now that I understand what an "open collector" output is, I think the circuit above will do what I want.

No?

Just FYI, the 19.56VDC power rail supply comes from the same power adapter that powers the LM350 battery charger circuit.
 
Last edited:

dl324

Joined Mar 30, 2015
16,896
The schematic:
We don't draw schematics that way. What you've drawn is more like a wiring diagram and does little to convey circuit intent.
1703976590759.png
Some "purist" will be by momentarily to point out missing decoupling capacitors. They are assumed, as are power connections for symbols that don't have explicit pins.

There's a book called Make: Electronics by Charles Platt. He uses horrible color coded wiring diagrams that he passes off as schematics. They look like they were drawn by a child; albeit a neat one.

EDIT: this is from "Make: more Electronics". He dropped the red and blue wires.
1703978456732.png
 
Last edited:

Thread Starter

brockrwood

Joined Oct 23, 2016
89
We don't draw schematics that way. What you've drawn is more like a wiring diagram and does little to convey circuit intent.
View attachment 311305
Some "purist" will be by momentarily to point out missing decoupling capacitors. They are assumed, as are power connections for symbols that don't have explicit pins.

There's a book called Make: Electronics by Charles Platt. He uses horrible color coded wiring diagrams that he passes off as schematics. They look like they were drawn by a child; albeit a neat one.

EDIT: this is from "Make: more Electronics". He dropped the red and blue wires.
View attachment 311307
This is great! Thanks!

The LM350 has .1 uF, 1 uF, and 1,000 uF filter capacitors on the IC input. Is that overkill? It doesn’t seem to hurt anything.
IMG_9501.jpeg
The 10 ohm resistor in series with the output makes the current steady at .125 amp.

Man don’t show this to my girlfriend. It looks like a fire hazard. I bet it violates one of her HOA rules.
 
Last edited:

dl324

Joined Mar 30, 2015
16,896
The LM350 has .1 uF, 1 uF, and 1,000 uF filter capacitors on the IC input. Is that overkill? It doesn’t seem to hurt anything.
1000uF is overkill. If the input is a switching regulator rated at several amps, it probably won't cause problems. Otherwise, you might be concerned about the initial charging current.

If you use pliers to rotate the leads of devices in TO-220, it'll be easier on the breadboard sockets. I twist them right at the standoff portion:
1703982058762.png
I use two pairs of needle nose pliers. One to support the standoffs and the other to twist the leads.

Lead diameter on the power resistor is probably a bit more than the breadboard was designed for.
 

Thread Starter

brockrwood

Joined Oct 23, 2016
89
1000uF is overkill. If the input is a switching regulator rated at several amps, it probably won't cause problems. Otherwise, you might be concerned about the initial charging current.

If you use pliers to rotate the leads of devices in TO-220, it'll be easier on the breadboard sockets. I twist them right at the standoff portion:
View attachment 311311
I use two pairs of needle nose pliers. One to support the standoffs and the other to twist the leads.

Lead diameter on the power resistor is probably a bit more than the breadboard was designed for.
Thank you!
 

Thread Starter

brockrwood

Joined Oct 23, 2016
89
It works! Yay!

I used a green LED to indicate full charge voltage. The red LED is just a “power on” indicator.

IMG_9555.jpeg

Now to add a yellow LED to indicate that the battery is still charging. I am wondering if I can adapt the part of this circuit with the 4011 NAND gate based flip flop to switch between a yellow LED (charging) and a green LED (fully charged) indicator.

https://www.electronicsmaker.com/em/admin/pdf/construction/TEMPERATURE CONTROLLED BATTERY CHARGER.pdf

The CD4011 is rated at 20VDC maximum supply voltage. My supply voltage is 19.56 VDC. That’s just under the max voltage for the 4011 IC. Too close. I guess I could put a 12 volt voltage regulator into the circuit to lower the voltage to the 4011, but that is adding a lot of complexity just to add one more LED indicator light to the circuit.

Wait! I can just add a second LM311 for the yellow LED! Just with the inputs backwards! I think…
 
Last edited:
Top