Computing stuff tied to the physical world

It’s a current source!

In Hardware on Nov 24, 2012 at 00:01

Let me answer yesterday’s question first: “Is this circuit actually useful for anything?”

You bet: this is called a Current source.

The circuit will deliver a constant current by varying the voltage drop, even when the load varies. You can see this in the fairly flat curve on the Component Tester screenshot included yesterday: no matter what level positive voltage you apply to this thing, it’ll draw about 2 mA (just ignore the negative end of the scale).

Actually, I cheated a bit. The real two-transistor current source circuit looks like this:

Curr source

By moving that 10 kΩ resistor away from the load, and tying it directly to “+” the circuit works even better. I’ve simulated it with an external power supply to drive that resistor separately, and get this CT screen:

SCR84

Totally flat! – And that 2 mA current level is set by the 330 Ω resistor, by the way.

One use for this could be a constant-current LED driver (although its efficiency would be very low – you really need a switching circuit with an inductor to get good efficiency).

So how does this mind-bending circuit actually work?

The key point to note, is that the emitter-to-base junction is essentially a diode (which is probably why transistors are drawn the way they are!). And it has a fixed forward-drop voltage of about 0.65V. As long as the base is less than 0.65V above the emitter voltage, the transistor will be switched off. As soon as the base is raised higher, current will flow through that forward diode and the transistor will start to conduct.

This is also why you always need a current limiting resistor: the base voltage cannot rise above 0.65V, it’ll simply conduct more current. Until the current limits are exceeded and the transistor is destroyed, that is…

First, imagine that the leftmost transistor is absent: then the 10 kΩ will pull up the base of the rightmost transistor and cause it to fully conduct. The circuit now essentially acts as the load in series with the 330 Ω resistor. With a maximum load (a short-circuit), the whole supply voltage will end up across that 330 Ω resistor.

But…

With the leftmost transistor in place, something special happens: as soon as the voltage over the 330 Ω resistor rises above 0.65V, the leftmost transistor will start to conduct, pulling the base of the rightmost transistor down. It will continue to do so until the voltage over the 330 Ω resistor has dropped to 0.65V again. Because at some point the base of the rightmost transistor will be pulled so low that it no longer fully conducts – thus reducing the current through the 330 Ω, and thus lowering the voltage drop across it.

You’re seeing a neat little negative feedback loop in action. These two transistors are going to balance each other out to the point where the 330 Ω resistor ends up having a voltage drop of exactly 0.65V – regardless of what the load is doing!

To get 0.65V over 330 Ω, we need a 0.65/330 = 1.97 mA current.

And so that’s what this circuit will feed to the load. As you can see in that last scope capture, the regulation is extremely good between 0.65 and 9V.

By simply varying the 330 Ω value, we can set any desired fixed current level.

The reason I’m bringing this up, is that this circuit is in fact used in the OpenTherm gateway – see this schematic (look for the upside-down PNP version). With some extra circuitry to set the resistor to either 100 Ω or 28 Ω (100 Ω in parallel with 39 Ω). So the gateway is driving either 7 mA or 25 mA through the thermostat.

Welcome to the magical world of electronics – it’s full of clever little tricks like this!

  1. I just wondered, how do you come up with these things…

    Does something like “software patterns” exist for electronics as well, and is this circuit part of it?

    Or is it just something you picked up on the way?

    • Heh – there is fascinating stuff all around us, not just nature – also technology! Because people have been inventing clever stuff forever. I’m just learning to see and appreciate these things again…

      I hope you like it. ‘Cause then I can keep on exploring and reporting them :)

  2. Not to mention that the software world is full of clever little tricks like this too.

    Electronics, software, biology, nature and much more is full of small little building blocks we can use to build something. It takes more than a lifetime to learn them all!

  3. @jcw Like it? I LOVE it! :-) So by all means, keep on exploring and reporting! It’s very much appreciated!

    B.t.w. You know of any good books that cover a lot of these kind of “basic building blocks”?

    • Great! There are many many books out there (and websites) – electronics has been around for a while, after all. Like “The Art of Electronics”, 2nd ed, by Paul Horowitz & Winfield Hill, Cambridge University Press, 1989.

      Hey, that might make a nice weblog post: where to find electronics info – I’ll add it to the list.

      How about the other side of the coin: anyone interested in software algorithm gems… Bayer-Moore searching, for example? Brilliant little idea, and there are tons of others.

  4. Tried it in a breadboard and it works fine. Just need to get my head wrapped around why it is stable.

  5. DIY constant current sources (in German): http://schaltplan.de.tl/LED_Konstantstromquelle.htm . The only thing I never understood: In theory changing the 330 Ohm resistor will determine the current but my attempts to set a current of 150mA or 350mA were unsuccessful (simulations with LTSpice) The current is not constant anymore. I tried beefier 2N2222 but to no avail …

  6. @MichelV: I can recommend this one: “Microelectronics Circuits” by SEDRA / SMIDTH, ISBN: 0-19-510369-6. I used this at courses in Engineering college, and I found it very usefull. It covers both simple R circuits, Transistor theory and OpAmps.

    But I am also sure you can find a lot of usefull websites out there

  7. @jcw yes, I would like to read about software algorithms gems in your discovery style…even that you know a lot on the subject, you can write about it as if you were just learning about it. There are a lot of clever tricks on software that could benefit this audience. Something on the style of what was tagged as “techniques” on this blog. Keep the good work! thanks.

  8. @Thomas Byrdal: Thanks for the tip! I’ll look around to see if I can get myself a copy of that one.

Comments are closed.