# Help understanding BJT voltage comparator

I'm trying to understand how a transistor voltage comparator works. For example I've been studying this LM339:

comparator circuit diagram http://lc.fie.umich.mx/~a0686696c/Materias_files/Lab.Elect.Analog_files/Voltmetro/Comparators_files/ComparatorGuts.GIF

My questions are:

1. What are the current sources for and how would those actually be implemented if for example I wanted to bread board this circuit

2. How can the circuit differentiate between inputs of say 1.5V or 2V? I must be wrong but my understanding is that if the voltage on a transistor exceeds a certain threshold the transistor will turn on. So I don't understand how inputs of (3V, 4V) and (4V, 3V) for example are any different.

3. If INPUT+ is at 0V and V+ is at say 12V then wouldn't 12V be shorted to 0V at the base of Q2?

Basically a walk-through of what happens with this circuit for different inputs would be great.

• What @jippie says plus, the diagram is very much simplified. The current sources are probably made by current mirrors so follow jippie's advice about researching those. I'd also add that it may be a tad more beneficial to understand op-amps first - comparators and op-amps are very similar but i'd so go down the op-amp learning curve 1st. – Andy aka Apr 12 '13 at 20:53

(Partial answer) Your assumption (2) is not right; BJTs are current-operated devices. They can also be partly on, in what is called the linear region.

That leads to (1); the current sources are there to operate the transistors in the linear region and never turn them on fully.

The basic operation is by "steering" current away from bases of transistors to reduce their on-ness. For full detail, put it in a simulator.

The circuit you find in a datasheet is usually a simplified version of reality, the actual circuit is much more complicated. On top of that transistors on a single chip can be extremely well matched, whereas if you build the circuit on a breadboard transistors will have huge tolerances and those will vary between each part.

You are way in over your head if you want to understand this circuit all at once. Start by understanding a simple dual BJT differential amplifier. Check this wiki article: https://en.wikipedia.org/wiki/Differential_amplifier

The other concept you want to understand are current mirrors: https://en.wikipedia.org/wiki/Current_mirror

For purposes of understanding the circuit, think of the current sources as being resistors. The processes that make ICs are very good at making current sources within them (even better than they are at making resistors), and using current sources rather than resistors will reduce the required margin between the input voltages and V+, but for purposes of understanding resistors will work fine. The exact values don't particularly matter. Note also that for purposes of the following discussion, transistors will be regarded as having a base-emitter drop of exactly 0.7 volts. In reality, the Vbe can vary, though similar on the same chip exposed to the same conditions should exhibit similar behavior.

Each of the PNP transistors will try to draw current into its emitter, sending about 2% out the base and 98% out the collector, to pull the emitter and collector toward voltages that are 0.7 volts apart. For Q1 and Q4, the effect of this is that the emitters will be 0.7 volts above the inputs; about 2% of the current the emitters have to draw will go out the inputs, and the rest will be sunk to ground.

Suppose the + input is at 1.0 volts and the - input is 1.1 volts. Then the base of Q2 would want to be at about 1.7 volts and the base of Q3 at 1.8 volts. Q2 will draw enough current through its emitter to pull it down to about 2.4 volts (0.7 volts above its base). Since Q3 will only have 0.6 volts between its emitter and base, it won't have to pull anything through its emitter.

Thus, of the current supplied by the 100uA current source near the top, nearly all of it will go into the emitter of the left transistor, and about 98% of that will go through to its collector. The Q5/Q6 circuit is called a current mirror; Q5 will gobble up all the current it's offered and Q6 will be willing to gobble up either as much current as is flowing into Q5, or as much current as is necessary to pull its collector to ground. In this case, Q3 will be passing through almost nothing, so Q6 will pull its collector to ground. Q7 will have nothing on its base, so its collector won't gobble anything. About 100uA will thus be available to flow into the base of Q8, turning it on.

Suppose the input voltages were switched. Then Q2 would have nothing between its emitter and base, but Q3 would have 0.7 volts. In that scenario, no current flows into the left side of the current-mirror circuit, so the right side isn't willing to gobble anything. Thus, most of the 100uA from the top center flows into the base of Q7. That turns it on and makes it gobble up the current from the right-side source leaving nothing for Q8.