Voltage comparators can be simply build using an OPAMP or comparator by feeding the 2 voltages to the inputs of the OPAMP/comparator. The output of the OPAMP/comparator will go high or low depending on whether one voltage is higher or lower than the other. But what when we want to compare 2 currents, and we need an output that tells us whether one current is higher than the other.
Below is a circuit that compares 2 currents. I1 and I2, using transistors.
When I1 >= I2, Vout will be high.
When I2 > I1, Vout will be low.
How it works ?
Q4 and Q4 form a current mirror (see Current mirrors). Because of the current mirror action, Q5 will sink a current equal to I1 to ground. If we offer a current I2 to Q5 that is equal to I1, then I2 will be totally consumed by Q5, so (I2-I1) = 0. That means that Q3 does not get any base current, so it can not conduct. Thus, Vout will be "high" (+12V) when I2 = I1.
Q1 and Q2 create a current mirror that feeds the collector of Q3 with a constant current I3, that is determined by R3 and is about 2.2 mA = (12V - base emitter diode drop of Q2) / 5K. By using this kind of constant current source, which has a very high output impedance, we give Q3 a much higher voltage gain than could be realised with a simple collector load resistor. The voltage gain of the common emitter configuration is directly proportional to the collector resistor. But there is a limit to increasing the resistor value, because a higher resistor value will result in a lower collector current. When the collector current becomes too low, the transistor stops amplifying.
To get the highest possible gain, a constant current source is the way to go. A constant current source will always try to deliver a constant current and will have a very high resistance against changes in current. This very high resistance towards current changes translates to a big voltage change for small current changes. In other words : it will give the transistor a huge voltage gain. And that is exactly what we need, since we want Q3 to be as sensitive as possible to detect the slightest current difference. Using a constant current source instead of a resistor to load the transistor is also called an active load.
Ok, we know now that Vout will be high as long as I1 = I2.
But what happens when I1 > I2 ? Well, in that case, Q3 still does not get any base current, because (I2 - I1) will be negative. So Vout will still be high when I1 > I2.
And what if I2 > I1 ? In that case, (I2 - I1) will be positive and Q3 will receive base current. Because the gain of Q3 is very high, since it is loaded by a current source, it will start conducting with base currents in the order of 10s of microamperes. So when I2 is slightly higher than I1, Vout will go "low" (0V).
So, voila, we have a current comparator that compares 2 currents and outputs a high or low level depending on which current is higher.
Of course, we can create this kind of circuit using an OPAMP to compare the 2 currents.
Below is the circuit with a current mirror constructed with Q1 and Q2. I1 is mirrored to Q2, so Q2 sinks a current equal to I1 via its collector to ground. When current I2 is higher than I1, the remaining current (I2 - I1), that is not consumed by Q2, will cause the voltage on the inverting input of the OPAMP to rise higher than the non-inverting input. That means that the output of the OPAMP will be low.
When I2 < I1, all the current I2 will be consumed by Q2. But since I2 is lower than I1, the voltage on the inverting input of the OPAMP will be lower than the non-inverting input, so the output of the OPAMP will be high.