# Can someone explain how this transistor comparator works?

I am looking to make a comparator using transistors and I stumble across this circuit claiming to be one:

Unfortunately, the description that came along with it leaves a lot to be desired, referencing components and points that aren't actually here - I assume due to typos but I can't actually work out how it is meant to work.

The purpose for this is I want to have a voltage reference of 1.8 - 2V, and then a supply rail connected to the other side. So long as the supply rail is higher than my reference voltage, it will allow power to be supplied to a component, but if not, it should remove power from it.

Any thoughts as to how this works and whether it is suitable for my application? Diagrams would help me to understand it more but any help would be appreciated.

Extra Information:

I want to use this 'comparator' in a circuit where I have a $\mu$C being powered by a current limited ~2V regulator. Currently, if the voltage output of this regulator drops below 2V the $\mu$C causes the rail to latch at 1.7V - 1.8V and won't allow it to rise to 2V again which is a bit of an inconvenience if anything. (How can I get this PMOS to turn off? is another question of mine which contains more information on the issue I am currently having)

I currently have a delay switch that will allow my reservoir capacitor to fill enough to be able to handle the initial start-up current of the $\mu$C. There are some problems with this and I just thought I might be able to replace it with a simple comparator, have a ~2V reference on one pin and the rail to the $\mu$C on the other and if this falls below my reference, it will simply cut off the power completely - this will prevent it from latching at ~1.7V and will allow the reservoir capacitor to fill up again in order to provide the needed start-up current again.

It isn't something that would happen a lot, and realistically, once fully designed and programmed, the circuit would never cause this rail to drop below 2V - however, there are some circumstances that might cause it to happen so it is a 'just-in-case' type thing.

• If that works as a comparator it is a very poor one. – Vladimir Cravero Apr 10 '15 at 9:06
• It's basically a small piece of an op-amp. This "supply rail" you talk about - is there anything else driving it? Is what you actually want an adjustable linear regulator? – pjc50 Apr 10 '15 at 9:18
• @pjc50 the supply rail is the output from a LDO 2V regulator (made of transistors) which is current limited to something like 50-100uA – MrPhooky Apr 10 '15 at 9:20
• See my answer. It would be VERY useful if you tell us as much as possible about your application. As shown vin min is Vbe or around 0.6V. You can build the same general cct with PNP transistors and "hang it" from Vcc, and Vin can now include ground with due care. You will almost always need input resistors and there is "some design": needed to get best results. – Russell McMahon Apr 10 '15 at 12:28
• This could be refined to suit your need BUT there are a large number of cheap easy to use power supply monitor ICs that do this sort of thing and/or an LM324 (quad) or LM358 (dual) op amp package is cheap and would do this and more easily. By the time you hav added "glue" parts around a basic discrete cct it will often be as costly as using a cheap op amp. (LM324 is an opamp but works more than well enough as a comparator in roles like this. It's companion true comparator (LM339, LM393) is less nice in several ways as a general purpose solution). – Russell McMahon Apr 14 '15 at 16:58

The circuit is a comparator and can be remarkably useful more or less as shown.

I have used a circuit essentially the same as that in production equipment to meet a requirement which was difficult to meet easily and cheaply by other means.

There are several ways to look at the circuit. The circuit does not care which way you look at it - but one or other visualisation can help your understanding.

This is known as a "long tailed pair" but in this case the "tail" is not very long in the sense originally meant. In an ideal version of this circuit the Re leg is a constant current source, always sinking current Ie.

Call lh transistor Q1 and rh transistor Q2

Call base voltages Vi1 and Vi2 OR Vil and Vir

Call collector voltages Vcl / Vcr or Vc1/Vc2

Call emitter voltage Ve (shared by Q1 & A2)

For now, assume that the combination of Ie, Re & Vee form an ideal constant current source of current Ie - this assumption can be revised later if desired - but makes it easier to follow operation initially and in many real world cases the assumption is "good enough.

RC1 = RC2 in most basic cases. In fact a special and useful case occurs when RC1 is substantially different to RC2 BUT for the basic differential amplifier assume they are equal. If "almost equal" with differences due to production tolerances it STILL works but with non-idealities. Assume identical for now.

Ideally Q1 and Q2 are matched in characteristics but, for many purposes they can just be two of the same type. Assume transistors are matched to start with. This also can be revisited and is NOT essential.

In most cases Ie and Rc are arranged so the transistors do not saturate when both are at about the same current - even this is not hard and fast BUT start with it so.

Operation:

(1) Version 1:

Imagine that Vb1 = Vb1 and > Re such that current Ie divides in 2 equally (as transistors are matched) and Ie/2 flows in each transistor.

Vc1 = Vc2 as resistors and currents are equal.

Now increase Vb1 slightly. Q1 draws more current by say dIe. But as total current is constant Q2 must decrease current by dIe. Vc1 will fall by dIe x Rc1 and Vc2 will rise by an equal amount.

In practice the internal emitter resistance of Q1 falls with increasing current (Re ~= 26/Ima) and this effect increases the current gain of Q1 and reduces the gain of Q2 and increases the voltage difference BUT this does not need to be taken into account directly to understand operation (although the following paragraph is closely related).

If transistor action was linear with Ie ~+ Ic proportional to Vbe then a slowly increasing base voltage on Q1 would ramp up Iq1 and decrease Iq2 linearly. However, Ic increases exponentially with Vbe, without delving into transistor models a standard model states.

Essentially this can be reduced to saying that Ic is proportional to Vbe (as above) plus a constant based on other "factors" which are not relevant here. (One of the "constants" is temperature which matters muchly in the real world but here can be ignored.)

The result of this is that for smallish increases of Vb1 relative to Vb2, Ic1 changes exponentially, decreasing the current flowing via Q2 and so causing Vc1 to dop and Vc2 to rise.

Plug the changes for typical voltages and currents into the above equation and you can plot gain and voltage swing.

For largish increases in Vb1, say tenths of a Volt. It can easily be arranged that Q1 saturates as Ib_Q1 x beta_q1 is > Ie. At this stage Q1 takes all the current, Q1 is turned hard on and Q2 turns off and Vc2 rises to Vcc. A surprisingly effective comparator can be achieved.

If Re/Ie is not a current source then increasing Vb1 increases I_Q1 so V_RE rises due to increased current. This reduces Vbe Q2 as Vb2 is constant and Ve has risen - so current share swings towards Q1 and Reinternal Q1 drops and Reinternal Q2 rises (which is part of another way of looking at the exponential VBe/Ic relationship) and differential action still happens.

More can (easily) be said but that's enough for niw.

(2) Version 2.

Q1 is an emitter follower.
RC1 does not strictly matter ecept that it helps maintain transistpr performance matching.
When Vb1 = Vb2 then the voltage drop "down from Q1b to Q1e matches the step up from Q2e to Q2b.
As Q1 is an emitter follower it will control Ve with Ve = Vb1 - Vbe1.
An increase in Vb1 raises Ve by the same amount (if Vbea remains constant(which is a good enough approximation for small Vb1 rises)).
Ve rising reduces Vbe2 by the same amount so reduces Ic2 as Ic1 increases due to exponential effect of increased Ic1 on gain. And ...

1. Version 3. This is another look at version 2 (and 1 2 3 are, of course, all the same in reality)

Q2 is a common base amplifier with base held at Vb2 and input voltage = Ve.
Changes in Ve caused by changes in Q1 emitter follower action are amplified in common base mode. (This is in fact essentially the same as common emitter mode but you stand in a different place to look, as it were).
Some playing with the above transistor equation and plugging in Boltzman's constant (k above) produces the astounding-to-many result that gain of Q2 = 38.4 x (Vcc-Vc2)
ie gain is 38.4 x drop across the collector resistor. As we vary Ve by say 0.1V then if V_RC2 initial = say 5VDC then Vc2 will change by 38.4 x 5V x 0.1V input change = 19.2V.
IF the supply is 10V say then a change of 19V cannot happen and Q2 will turn off and Q1 will turn fully on with much less than 0.1V change in Vb1.

This real world result is so contrary to common sense and what most people think that they know about transistors that putton on flame suits about now may be a good idea :-).

Does it work:

I wished to measure the rotor speed of an exercise bicycle which used a 3 phase alternator as load - using alternator waveforms alone. This saved the client the cost of a reed or hall sensor and wiring and connection. Not vast, but worthwhile IF it could be done very cheaply. I used connections to 2 of the phase windings. (Using one only proved non viable). I used 2 x BC337 transistors with 1M (AFAIR - about 14 years ago) to each base and maybe 1k as Re and RC = ? (1k, 10k?) Cct can be dug out if needed.
I fed in up to 200 VAC from 2 phases of an alternator (2 phase exercise bicycle) with 20 kHz PWM resistive loading. Alternator frequency I forget but probably hundreds of Hz depending on user pedalling rate. Suffice it to say the variable voltage and frequency, variable load, 20 kHz PWM, saturating laminations as speed increased, sinusoidal to trapezoidal waveform change and more made the input "a bit of a mess". Out of this with minimal filtering the "long tailed pair" extracted a beautifully clean rotor speed proportional signal. Transistors were not matched and bases had no resistors to ground - the 2 x 1M acted as current sources and each transistor in turn got less or more drive.

This was an extreme case - but the circuit is useful elsewhere. The various non-didealiries I mentioned above tend to show up mainly as input offset voltage - one bases will be at a higher voltage than the other when the system is "at balance". If this is tolerable, and it often is, the result can be excellent.

A long tailed pair is far closer to an opamp than almost anything else you can do cheaply and easily without ICs.
Almost magic :-).

"Hyperphysics" Transistor Operation

How to Calculate the Collector Current of a Transistor

• Mighty impressive answer... Thanks. So, I think I got from that, it wouldn't work like a comparator as the output would be analogue? Not on or off depending on which input is highest>? – MrPhooky Apr 10 '15 at 14:03
• @MrPhooky: Yes, technically it's analog, but the linear region is so small that it might as well be a comparator. Basically like an IC opamp. If you want it to be stable with roughly equal inputs, you can add some positive feedback to produce a bit of hysteresis or "memory". That'll also yank it all the way through the linear region about as soon as it starts, making the output even more "digital". – AaronD Apr 10 '15 at 16:49
• @MrPhooky - The answer to your question is "Tangerine with shadings of Octarine". Knowing what you are actually wanting and trying to do would help immensely in answering your questions and providing a solution that suits. It's a real comparator. Analog comparators are linear devices optimised to make use of the high available gain. Within its necessarily limited abilities this cct too can be optimised to meet the requirement IF we know what it actually is. As noted above, at Vcc = 10V this will slew 19.2V (more than available) with a 0.1V change of input - ... – Russell McMahon Apr 10 '15 at 18:57
• ... or 5V from centre position to high or low rail with about 25 mV change (roughly). That may meet your need in spades or be far from good enough - depending what your unknown need is. We can add positive feedback and hysteresis and apple-pie and motherhood, should the spec require them. So far ... ? – Russell McMahon Apr 10 '15 at 18:57
• @RussellMcMahon Please see my edit to the question for information on what I am trying to do with this - it will essentially be acting as a isolator(?) in that it will cut off the power should it drop below a threshold, and reapply once it has risen again. – MrPhooky Apr 14 '15 at 8:00