# Can a voltage comparator be constructed from NPN BPJ transistors and resisitors alone?

I'm working though some basic logic circuits with my niece and nephew and wanted to implement elements with transistors before we get more complex and replace modules with ICs. I know this is trivial with an OP Amp, but this is a teaching exercise.

I've seen the following circuit,

But I don't understand how it works and I think it requires both a positive rail, negative rail and ground, which is a complexity I'd rather not add to our experimentation. In the application I have in mind, all voltages I'm comparing will be positive relative to ground.

This stepping stone is to allow us to build a 555 timer, as, with help from SE, we've managed to put together a D flip-flop and I think we just need the voltage comparator to get a working 555.

• Yes, it can. What you have here is a simple low-performance comparator/amplifier of a type called a long-tailed pair. This is used as an input stage on all op amps that I'm aware of, though usually with a simple current source instead of $R_E$. Commented Jul 19, 2020 at 18:17
• Really, this circuit is too complex for a newbie. I suggest you start your experiments with its simplest initial version - just a transistor. Connect the one (positive) voltage source to the base and the another (positive) voltage source to the emitter. Of course, connect a collector resistor and take the collector voltage as an output. To see the result of comparison, you can connect a LED in series to the resistor. If you are not satisfied of the result, try to improve the circuit... In this way, you will gradually "invent" the differential pair above. This is the best way to understand it. Commented Jul 19, 2020 at 18:33
• @Circuitfantasist Hell no. I've never taken a single college course. Not possible. I have taught as a professor at the largest University in my state, though. Achieving that was interesting.
– jonk
Commented Jul 19, 2020 at 18:38
• The 555 (bipolar version) full schematic with resistor values is available and would not be too complex to implement, in my opinion, however it uses PNP transistors. The ones with two collectors can be replaced with multiple discrete transistors. Similarly, the LM339 full schematic is available, however it uses both PNP transistors and a JFET. The JFET can be replaced by a resistor if you know the power supply voltage in advance. Commented Jul 19, 2020 at 18:50
• @SpehroPefhany I was teaching undergrad at the 2nd and 3rd year level for a number of years as an adjunct professor. Class sizes of 75, typically. It was a lot of fun. Just didn't pay well. But I did it because I enjoyed it and because it helped them out, too. They needed the extra capacity at the time. I also had the recommendations from several Ph.D. teachers from the university. That helped a lot, of course. The funny thing was that they were proving, by hiring me, that their degrees weren't quite as valuable as they'd like them to sell as.
– jonk
Commented Jul 19, 2020 at 23:59

I took the story below from my answer to a similar curious question and edited it a bit...

1. Base-emitter input. The only way we can control a transistor is by applying input voltage (about several hundred millivolts) to its base-emitter junction. For some reason, most frequently, we present this voltage as a small difference between two relatively high single-ended (referenced to ground) voltages. Thus the base-emitter junction is floating and we have a few ways to control the transistor.

To investigate them in the laboratory, my students mount a universal circuit setup - Fig. 1, where the two input voltages are "produced" by 1 k potentiometers… and the collector current is visualized by an LED. Moving the potentiometer sliders, they have the feeling that the base and emitter (voltages) "move" up and down.

Fig. 1. A set-up for investigating various transistor stages on the blackboard (Vcc = 12 V). Voltages are visualized by bars (in red) with proportional height; current paths are visualized by loops (divider currents in green, base current in blue and collector current in violet) with proportional thickness.

I suggest you mount the circuit on a prototyping board - Fig. 2, and reproduce the next experiments. It is preferable to use (geometrically and electrically) linear potentiometers. If you have two more multimeters (voltmeters) besides V1 and V2, you can connect them in parallel to Rc and to the output OUT (Vc). Of course, you can insert an ammeter(s) too.

Fig. 2. A set-up for investigating various transistor stages on the prototyping board

2. Base input. First, you can set (by the help of the potentiometer P2) constant voltage Ve at the emitter and then vary (by the help of the potentiometer P1) the base voltage Vb. Only be careful to keep Vb with a few hundred millivolts above Ve. You will see that when increasing V1, the LED gradually begins to glow (Ic increases)... VRc increases… but Vout decreases. The name of this arrangement is "common-emitter stage".

Maybe you notice that Ve slightly varies in the same direction with Vb because the emitter current changes and P2 is not a perfect voltage source (its Thevenin's resistance is not zero). Here it is undesired effect but later we will use it. To make Ve "stiff" enough, connect a big (> 1000 microF) "bypass capacitor" in parallel to P2 output (between the emitter and ground)... and observe the result when quickly wiggle P1 slider. As they say, the emitter is "AC grounded".

3. Emitter input. But with the same success, you can set (now by the help of the potentiometer P1) constant voltage Vb at the base and then vary (by the help of the potentiometer P2) the emitter voltage Ve. Now be careful to keep Ve with a few hundred millivolts below Vb. Now you will see that when increasing V2, the LED gradually begins to glow dimmer (Ic decreases)... VRc decreases… but Vout increases. The name of this arrangement is "common-base stage".

Here you may notice that Vb slightly varies in the same direction with Ve because the base-emitter junction conveys Ve variations... and the emitter "pulls down" the base through the base-emitter junction. As above, to make Vb "stiff" enough, connect a big "bypass capacitor" in parallel to P1 output (between the base and ground)... and observe the result. Now the base is "AC grounded".

4. Both base and emitter input. If you are curious enough, continue with these exciting experiments by varying both Vb and Ve. First set such a difference Vb - Ve that the LED glows with a dim light (around 650 mV). Then grab the potentiometer sliders with both hands and start moving them simultaneously:

...in the same direction, with the same rate. Very interesting - both voltages simultaneously change but their difference Vb - Ve, Ic, VRc and Vout do not change. They name this "common mode" and, as a rule, introduce it when explaining op-amps. But you met it right now, at transistor circuits. Indeed, you could get to know it even from the bridge circuits (the so-called "balanced bridge").

...in the opposite directions, with the same rate. Now both voltages simultaneously change and their difference Vb - Ve, Ic, VRc and Vout vigorously change. They name this "differential mode" and also introduce it when explaining op-amps but you could meet it when investigating bridge circuits ("unbalanced bridge"). This circuit is the prototype of the OP's transistor differential stage (aka "differential pair" or "long-tailed pair").

It is interesting that, in the circuits above, when Vb - Ve > 0.7 V, the base-emitter junction practically connects (like a bridge) the two input voltage sources that can cause interesting effects. If Vb - Ve <= 0, the base-emitter junction is cut off and there is no any connection between them.

5. Both base and buffered emitter input. The problem of the simple 1-transistor comparator above is that the big emitter current flows through the input voltage source connected to the emitter. We can solve this problem by connecting (another) emitter follower between the input source and emitter... and so we get the famous circuit of a 2-transistor differential amplifier (comparator)...

I hope my story would be useful to you not only with its content but also with the way circuit ideas are presented. With it I wanted to show that circuitry can be entertaining and fascinating... and not just a boring craft...

• Cheap multimeters from Action? I have 3 of the same.
– Bart
Commented Jul 20, 2020 at 10:10
• The principle here is "cheap but a large number of meters" inserted at any point in the circuit. Sometimes, there is a problem with the 20 mA range - if there is a short circuit, the internal SMD current-sensing resistor burns out before the (500 мА) fuse blows. Commented Jul 20, 2020 at 11:49
• I think I had that same problem with this type of multimeter. No noticable damage but a wrong current reading.
– Bart
Commented Jul 20, 2020 at 12:11
• Just replace the 500 mA fuse with smaller (e.g., 300 mA). The problem is in these small SMD resistors. Commented Jul 20, 2020 at 12:16

The circuit you have will work just fine as long as the voltages you want to compare are more than the transistor VBE drop (about 0.7 V) above ground. In a 555 application running at 5 V, the comparator voltages are 1.67 V and 3.33 V, so you'll be fine.