Thursday, May 3

Circuit VR: Sink or Swim with Current Sources

If you got your start in electronics sometime after 1980 your first project might well have been to light up an LED. Microcontroller projects often light up an LED, too, and a blinking LED is something of the “hello world” program for embedded systems. If you tried lighting up your LED with a 9 V battery directly — not that you’d admit to it — you found it would light up. Once, anyway. The excess current blows up the LED which is why you need a current-limiting resistor. However, those current limiting resistors are really a poor excuse for a current source or sink. In many applications, you need a real current source and luckily, they aren’t hard to create.

As always with Circuit VR, we’ll be using LT Spice to examine the circuits. If you need a quick tutorial, start here and come back after that. If you use Linux, don’t be dismayed. I run LT Spice under WINE and it works great. You can find all the Spice files on GitHub.

Source or Sink

An LED — to continue with that example — doesn’t actually care about the current limiting resistor. It cares about the current flowing through it. In general, the more current the brighter the LED. The simple resistor is cheap and easy, but it does have limitations. For one thing, the supply voltage will affect the brightness, too. We are spoiled by working on systems that have regulated power supplies, but a piece of gear that uses an unregulated supply like a car battery might have a wide-range of voltages under different conditions. What you’d like is a device that can source or sink a given amount of current regardless of the supply voltage.

Remember, in a single loop circuit, current is the same everywhere so often it doesn’t matter if you control the amount of current going in or coming out. Circuits that supply current (using positive current flow convention) are usually known as a current source and one that limits the current flow on the ground side is known as a sink.

LEDs aren’t the only thing that needs a current source or sink. A battery charger, for example, might use a constant current. A high-quality amplifier will often use a current source as a load resistor. Charging a capacitor with constant current results in a nice linear ramp instead of a curve like you get when you charge with a constant voltage.

Bipolar

Perhaps the simplest current sink is an NPN transistor like a 2N2222. The base-emitter junction looks like a diode so assuming you forward bias it, the emitter will have about 0.7 V less than the base has on it. That number actually varies a little with temperature and other factors but for a common silicon transistor, 0.7 V is close enough.

Assuming the transistor’s beta is high — and modern devices are usually pretty high — whatever current flows through the emitter will effectively flow through the collector, too. That’s a little oversimplified since it ignores the base current, but that can be very small so we’ll ignore it.

D1 is an LED with the usual limiting resistor. The forward voltage is about 2.7 V and the supply voltage is 12 V, so the resistor gets about 9.3 V across it. With the specified resistor, that means the resistor has about 20 mA through it and therefore so does the LED.

D2, though, uses a simple current sink. R3 and R4 divide the input voltage to about 1.7 V on the base of Q1. That means the emitter has about 1 V on it. If you do the math by hand, you might think R3 and R4 have values that don’t quite produce 1.7 V. I’ll tell you why in a minute, but for now just take it on faith (and, if you like, by running the simulation) that the base voltage is 1.7 V.

In fact, here’s the output of the spice simulation (with a little extra annotation):

--- Operating Point ---

V(vled): 2.74756 voltage      LED drops about 2.75V
V(n001): 12 voltage
V(vc): 9.25399 voltage        About 12-2.75
V(ve): 0.992536 voltage       About .7V below Vb
V(vb): 1.72943 voltage        Set (more or less) by R3/R4
Ic(Q1): 0.0197532 device_current     Because Ib is small, |Ic| is about equal to |Ie|
Ib(Q1): 9.74841e-005 device_current
Ie(Q1): -0.0198507 device_current    |Ie| = |Ic+Ib| (sign is because of direction)
I(D2): 0.0197532 device_current      LED current close enough to 20 mA
I(D1): 0.020114 device_current       LED current close enough to 20 mA
I(R4): 0.0101731 device_current
I(R3): 0.0102706 device_current
I(R2): 0.0198507 device_current      Set by Ve/R2 which sets Ie which sets Ic
I(R1): 0.020114 device_current
I(V1): -0.0501378 device_current

As promised, Ve is just about 1 V. That makes the emitter resistor, R2, similar to the LED current limiting resistor. It has 1 V across it and therefore consumes 20 mA as you can see in the output. Because Ic is within 100 microamps or so of Ie, the LED — D2 — also has 20 mA through it.

Is that Better?

You may wonder why that is better. We have several extra components and get essentially the same result. The truth is, as I have it drawn here it really isn’t much better. That’s because the base voltage, which sets the current is fixed and depends on the supply voltage. But it doesn’t have to be that way.

For example, I could change out R3 and R4 for a resistor and a Zener diode or even a few regular diodes and get a voltage that didn’t depend on the supply voltage. I can also vary the base voltage and control the amount of current through the LED or other load devices.

However, for some loads, even this circuit might be an improvement over a simple resistor. Suppose you had a black box instead of an LED. Because of lightbulbs or motors or something inside of it, it appears to be a resistor that changes in value. In other words, if you put a battery across it, it might start off looking like a 1 Ω resistor but after a few seconds, it looks like a 20 Ω resistor. This isn’t uncommon to have something that exhibits an inrush current on startup.

With a limiting resistor, the amount of current such a varying load draws will change as the effective resistance changes. But with our simple transistor circuit, 20 mA will always flow. Well. Sort of.

A Matter of Compliance

Practical current sources have a certain range of compliance because they can’t provide an infinite voltage. Let’s look at another simulation to see how that works.

In this circuit, a PNP transistor sources current. The base voltage is about 0.7 V less than the emitter voltage. So with 10.3 V on the base, the emitter has about 11 V and R1 sees about 1 V across it. That sets the current, but this time the load goes from the collector to ground.

When the load resistor is low, it is easy for the circuit to supply the roughly 100 mA required. After all, a 10 Ω resistor only needs 1 V across it to get there. But the circuit can only get the collector to around 11 V. So it stands to reason that somewhere after 100 Ω, things will go bad. You can see that in the chart from the simulation where I stepped the load resistor from 1 Ω to 150 Ω:

The blue trace (the one that starts in the lower left, for the color blind) is the voltage required to generate the 98 mA through the resistor. The green trace is flat until you get to the 11 V point. Then it drop dramatically as the circuit can supply no more voltage.

All Your Base Voltage

To keep that example simple, I just put a perfect voltage source on the base. But in the first example, I used a voltage divider with a 1 kΩ and 170 Ω resistor. If you did a little math you’d see that 170/(170+1000)=0.15 (about). So with a 12 V supply, you’d think that divider produces 1.8 V. Yet the actual base voltage in that example is about a 1/10th of a volt less.

The reason is simple. R4‘s value is really in parallel with the emitter resistor (R2) times the beta of the transistor. Since R4 is small and R2 times beta is probably pretty big (at least 50,000, I’d guess), the effect is small. However, if R4 were large this could have a serious effect.

By the way, I’m not being lazy about estimating the effective resistance. A transistor’s beta is not a very stable parameter, so whatever the nominal value is, it will vary quite a bit based on current, temperature, and even from device to device.

But Wait, There’s More…

These simple current sources and sinks are pretty useful. However, there are some limitations and there are circuits we will look at in the future that try to mitigate those limitations. For example, FETs can do this quite well, with a bit more math. It is also common to use more than one device to mirror a current — that is, take a reference current and reproduce it. That doesn’t sound useful but think of it as the same as an emitter follower for voltage. The source voltage sees a light load and produces an output voltage that can supply more current than the original source. Same for a current mirror. The reference current might not have a wide range of compliance voltages or — like a resistor — be sensitive to the load. The mirror will present a stable load while providing a more robust output current.

If you want to try an experiment, replace the load resistor on the PNP circuit with a capacitor and run a transient analysis. Just be sure to set the UIC option on the analysis command line (check the box that says skip initial operating point solution). Have a look at the voltage on the capacitor. By varying the current-setting resistor and the capacitor value you can create different straight line charging times. You can find my solution online.

No comments:

Post a Comment