In the following circuit, I've intentionally boxed up the circuit so that it appears to have three pins. There is a good reason for this choice, as will become clearer later on (if not already.)
The circuit requires a GND pin, of course. This needs to be connected as the lowest voltage of the three pins and should be tied a low-impedance node so that the current can sink to that node without moving the node voltage around. This is typically attached to the overall circuit ground reference node.
The SINK pin is controlled such that the current specified by RSET is sunk at this pin. A load may be attached between this pin and a positive voltage supply (relative to whatever the GND pin is tied to, anyway.) I show an LED here. But this could be other kinds of loads, as well.
The burden voltage for the SINK pin, relative to GND, is at least 1V. (The circuit can often be designed to tolerate some saturation of Q1, so that its VCE can be as little as 300mV.) But for some designs this may be somewhat higher -- perhaps as high as around 1.6V in some more extreme cases with high sinking currents set by RSET.
The ENA pin is usually connected to the same positive voltage supply (relative to GND) that the load uses. This "enables" the circuit. But using the positive supply directly need not be the case here, as I'll discuss a little later towards the very end, below. It may also be connected to an MCU and used to turn the circuit ON and OFF. For this reason, I show it as a separate pin and call it ENA to signal that this is an active-HI enable pin, of sorts. You can tie it HI (as shown above) or you can use an I/O pin to control it. (As I said, more on that later on.)
OPERATION
Let's first look at the circuit to see how it does what it does.
The main idea is to use the fact that a silicon BJT has a relatively stable VBE≈700mV. (Assuming the temperature of Q2 isn't moving around -- more on that, later.) All of the current sinking into the SINK pin, plus a little more from the base of Q1 and less a little bit that goes into the base of Q2, is driven through RSET and therefore develops a voltage across it. If Q1's collector were to try and increase the current it was sinking (Early Effect?) then this added collector current would cause the voltage across RSET to exceed the nominal VBE of Q2. In response, Q2's collector will sink more current (its collector current is controlled by its base-emitter voltage.) This added Q2 collector current has to come through RB and therefore must increase the voltage drop across it. This lowers the voltage at the base of Q1, which therefore lowers its emitter voltage. In effect, the overall response of the circuit to an attempted increase in the current through the load (LED?) is to oppose that change and return the base voltage of Q2 to the nominal VBE≈700mV. Similar logic also applies should the collector current of Q1 decline. The circuit response to a lowering in Q1's collector current is to raise the base voltage of Q1 and therefore oppose that decline.
There is negative feedback in this system to oppose changes in the sinking current at the SINK pin. And the sinking current is nominally:
ISINK=700mVRSET
This entire circuit works to control the voltage at the collector of Q1 by observing the current sinking into the collector of Q1. Other than the voltage across RSET and across the load (the LED in this case), all of the rest of the voltage difference between the positive supply and GND is taken up by the VCE of Q1. But this detail is under management by the circuit so that the load's voltage is just what is necessary for the current set by RSET.
A DESIGN
You must be sure that you have enough extra voltage for the positive supply. It must be at least the burden voltage of the circuit's SINK pin plus whatever burden voltage is required by the load. For a typical LED that uses somewhere from 2V to 3.5V, this means that the positive supply voltage must be at least 5V. But if you are using a red LED with, say, 1.9V and if you can accept a design with a little saturation in Q1, then you could get away with as little as 3V for the positive supply. (There is no hard and fast rule here and there are many tradeoffs to consider.)
So let's assume that VCC=5V and that this is a red LED that is to be operated at ILED=20mA. (Also, obviously, we will use VENA=VCC.)
We could assume that VBE1=VBE2=700mV and that is what most folks would do. Feel free to do that, in fact. But if you want to be a little "techy" about it, you might realize that I'm going to set the collector current of Q2 to be 110th the value of ILED. (You can see that much in the above equations, if you are sly about reading them.) That means there will be a 60mV difference in the base-emitter voltages between the two BJTs. Also, because we are dealing with 20mA and since I happen to know that VBE in small signal BJTs is roughly 700mV when the collector current is somewhere in the vicinity of 3mA, I can work out the fact that:
I'm doing this to illustrate a few things. One is about the fact that VBE isn't actually constant. (We are still ignoring temperature.) Instead, it does depend on the currents involved. So if you choose very different currents than I show here, you may need to know this detail. Another is to show how little it really matters in the case of dealing with an LED. We could just assume and be "close enough." It helps to see it done both ways to make that point.
Designing this for a low burden voltage of 1V (Q1 going into saturation, so let's say β1=20) and assuming a semi-worst case β2=100, we find that
RSET≈33ΩRB≈1.8kΩ
And you will find that both those values are true whether or not you use my fancy calculated values for the base-emitter voltages or not. Either way, the results are very much the same. (So this points out one reason why the base-emitter voltages of BJTs can often be taken as a given value.)
TEMPERATURE AND THE EARLY EFFECT
I've avoided these topics until now. But they are both important enough that it is time to bring them up. One of the huge benefits of this circuit is that it solves both these problems (to a reasonable degree) by adding Q2.
Q1 suffers from the Early Effect in a circuit like this, because the VCE voltage can vary widely depending upon variations where the load drops different voltages. BJTs have, in effect, a resistor that goes from their collector to their emitter. This resistor is sometimes called ro and its value is ro=VA+VCEIC, where VA is the Early Voltage for the device. This is often around 100V but it can be quite a bit less (the D45H11 can be as little as 10V.) For ILED=20mA, this value might be as little as 5kΩ and, unchecked, would increase the current in the LED.
Q1 also suffers from heating. It's the work-horse device here and it may have to dissipate power and, in the process, heat up. If we were depending upon its VBE voltage as a way of programming the LED current, we could be in some trouble because this voltage changes by somewhere between −1.8mV∘C to −2.4mV∘C. With some BJTs in TO-92 packages with thermal resistances of 200∘CW, you can easily see a fairly large change in the base-emitter voltage due to heating caused by their normal operations.
But this circuit moves both problems away from Q1.
First, Q2 operates with a nearly fixed VCE in this circuit and therefore the Early Effect on Q2 doesn't change as the circuit operates. But more importantly, the Early Effect on Q1 is neutralized because Q2 will adjust its operations to automatically compensate for such variations by observing the voltage drop across RSET. If Q1's Early Effect attempts to make any changes in the LED current, Q2 will immediately adjust its own collector so as to counter it. The result is that the Early Effect in Q1 is neutralized by the same negative feedback loop that is controlling the LED current in the first place.
Second, since Q2 is the BJT measuring the LED current, it's important that Q2 base-emitter voltage remain as constant as possible. But also, because Q2 is operating with far less current (on the order of the base current needed by Q1) and because it has a very small VCE voltage, the dissipation in Q2 is very modest. This means it is only barely affected by heating and this helps to ensure that its base-emitter voltage is only depending on the ambient temperature for operation; without the additional problems caused by having to dissipate the far greater power being handled by Q1. So this helps to minimize temperature effects.
It doesn't completely eliminate them, since the ambient temperature of the circuit will still have an effect. But it does help to separate these problems into two devices.
So using the 2nd BJT here is helping in two ways: nullifying the Early Effect in Q1 and removing the self-heating portion of the problem in Q1 from impacting the programmed current.
FINAL NOTES
There is another use for this circuit I'd mentioned earlier. The ENA input can be managed by an MCU I/O pin, instead of tying it to the positive supply. If so, the value of RB might be adjusted per the VCC of the MCU itself (which may be different than that used by the load.) This allows ON/OFF control of this circuit.
So it's really quite a useful circuit pattern to know about and use.
As if that weren't enough already, the above circuit can also be modified to use a MOSFET:
Here, the value of RSET is set up much the same way as before. However, as the MOSFET doesn't require any base current, the value of RB can be much higher -- say 22kΩ or still more, if desired. One impact of setting RB higher or lower will be the collector current of Q2 and therefore will have some effect on the voltage across RSET. Also, there is a threshold voltage required for the MOSFET (NFET), and this voltage requirement must be met by whatever voltage is supplied to ENA.
For example, the BSS123 has a threshold voltage of about 1.7−2.0V. This is added to the already needed base-emitter voltage for Q2. So the voltage difference across RB will be ≈VENA−700mV−1.7V. From that, you can work out the collector current for Q2.
So there are a few slightly different calculations involved in this new pattern using an NFET with an NPN BJT. But this also shows the versatility of this pattern, too.
Appendix
Start with the usual equation for a BJT collector current when in active mode:
IC=ISAT(eVBEηVT−1)
Solve for VBE:
VBE=ηVTln(ICISAT+1)
At this point, we can simplify the above equation, removing the +1 term, because ISAT is many orders of magnitude smaller than any practical IC. So, without any harm we can re-write it as:
VBE=ηVTlnICISAT
Now. Suppose we happened to take a reference measurement of VBE0 at a collector current IC0. What would we then expect for a new VBE1 at a new collector current, IC1?
For a small signal BJT, it is almost always the case that η≈1 and at room temperature VT≈26mV. This is where I got the "See appendix" equation, above.
If you are only interested in small scale changes rather than large, non-linear changes, then you can take a differential approach instead (sometimes called "local linearization about a point.") Below, I'll use a differential operator approach:
At this point, you may notice that the first two factors in linearized are very similar to the right-side of non-linear Shockley. The difference, the −1 term, isn't important enough to worry about, as the exponential value is almost always huge (≫1.) So this means we can re-write (without any loss of generality) linearized as:
dIC=IC⋅dVBEηVT
Solving for dVBE:
dVBE=ηVT⋅dICIC(small signal VBE change)
The interpretation of dICIC, its meaning in effect, is the "infinitesimal percent variation of the collector current." Compare the above small signal VBE change with what was developed still earlier above:
ΔVBE=ηVT⋅lnIC1IC0(finite VBE change)
There is a difference, as you can see. If all you want are nearby change estimates, all you need to worry about is estimating the %-change in the collector current and you can easily get the estimated change in the base-emitter voltage without having to worry about taking the logarithm of the current ratios.
If you remember 1st year calculus, then you may remember seeing that dlnx=1xdx. This means that dlnIC1IC0=IC0IC1⋅dIC1IC0=dIC1IC1. And now you can easily see, in broad daylight, the relationship between small signal VBE change and finite VBE change.