Thank you very much! When you say my design was limited by hFE, you mean that I should not use the beta value of the transistors? I am aware that it drifts a lot with temperature and other parameters.
Yes. For a given input (base) current, you have hFE times that, driving the output transistor bases, and hFE^2 total available output current. Now, for a saturated switch, having lots of available output current isn't necessarily a problem, but the uncertainty in the base currents is bad.
With at least a series base resistor (or a signal source with similarly limited output current, like a CD4000 series gate, perhaps), the input current will be limited to a modest value, but the drive current has that factor of hFE.
It also doesn't turn off very well, not just dynamically (taking >10us), but statically, too: the first transistor might draw a few nA of leakage current, typical, at room temperature; but, the datasheet gives a maximum of some uA, much more pessimistic. When multiplied by hFE, by the output transistors, this gives a max off-state leakage of perhaps 100s uA. That might not sound like much, but it's enough to dimly light an LED. And it's more when hot -- much more, perhaps mA, because hFE and leakage both rise significantly as temperature goes up.
That's the other thing Rb does -- sink leakage current, preventing the output transistors from turning on. That way, the output leakage is only the output transistors' leakage, no contribution from the driver.
Sorry for my ignorance but, how does Re limit the current though the transistor? What my intuition tells me, and I am probably mistaken, is that Rb and Re form a voltage divider when A is high? I've run a couple of LTSpice simulation on this circuit, changing values for Re (and optimizing the resistor for the current I want on the output), in order to understand how does it work. But I still do not get how Re sets the current. Could you enlighten me?
Yes, a voltage divider, on the low side. The voltage does not divide evenly, because the B-E junction gets forward-biased, pulling the divider node down to a maximum of about 0.7V.
If you imagine the NPN output transistor disconnected for a moment, the voltage divider will be unloaded, and you can calculate the Thevenin equivalent circuit. The output voltage is: (V(A or B) - Vbe) * Rb / (Rb + Re), and the output resistance is about (Rb * Re) / (Rb + Re) (i.e., the two resistors act in parallel).
This is because the drive transistor acts as an emitter follower, dropping Vbe (about 0.7V), and the rest of the input voltage appears across the divider. So, for a 5V logic input, 4.3V is applied to the divider.
For the values I gave, Vth = 1.34V and Rth = 68.7R. Now connect the transistor back up: it sees this driving the base, which rises to 0.7V and therefore draws (1.34V - 0.7V) / (68.7R) = 9.3mA. This base current is nearly independent of hFE, and linearly dependent on input voltage (which is as stable a current limit as you can hope for, without adding additional circuitry).
Meanwhile, the emitter follower is getting its current -- about 16mA -- from somewhere. That current is drawn through the collector, which therefore sinks the same current through the high side Rb and PNP transistor. Thus, high and low side are turned on equally well!
You want resistor values so that Vth ~ 1.2V, and Rth ~ 0.6V * hFE(sat) / I(load). Vth must be greater than 0.8V to turn on the output transistors at all, and it should be about 2*Vbe to ensure a good balance between turn-on and turn-off performance. (Higher causes more stored charge -- slower turn off -- but if you don't need fast switching speed, that saves you a few mA otherwise wasted in Rb.)
hFE(sat) is the saturated hFE -- note that hFE drops sharply as Vce goes towards Vce(sat), because there's simply no voltage left for the transistor to amplify with.
Normally, this is chosen to be 1/2 to 1/20 the linear-range hFE value. The datasheet usually gives a hint, here -- check the conditions used to test Vce(sat) or switching speeds. For example, 2N4401 might be measured at hFE(sat) = 10. (On the other hand, low-Vce(sat) transistors have quite good hFE, even at high currents, and can use much higher hFE(sat) values -- PBSS303NX is tested at hFE(sat) = 100 at 4A!)
You also need the input (V(A) or V(B)) to be greater than a couple Vbe's, otherwise little voltage is dropped across Re, and the circuit is sensitive to transistor parameter variations (in this case, mainly Vbe tempco -- expect a range of about 0.8 to 0.5V from cold to hot conditions). This means you should choose a different drive circuit for logic inputs below about 3V.
Tim