Skip to content


Adjustable Current Sink

OpAmpTransistorSinkAnnotatedAn adjustable current sink is useful for testing power supplies and figuring out how much current an LED might need. I built up this circuit to test a new power supply I was working on and revived it after seeing a couple of related post at Keith’s Electronics Blog. He wants to build a handy LED tester that can determine what resistor you need to light the LED by allowing the user to vary the LED current for desired brightness. This application could make good use of an adjustable current sink to set the LED current.

I explain how the adjustable current sink works and how it could be configured for control and monitoring by a microcontroller. I show two possible circuits, one using a transistor as the primary component and another where an Op-Amp is included to overcome some minor issues. This article should be interesting for anyone interested in using transistors or Op-Amps. Of course, if you need an adjustable current sync…

An adjustable current sink simulates a load at some set current. You connect it directly to a power supply output and adjust the current to whatever level you want to run test at. For example I wanted to see my supply perform at 300mA with a 12V AC input and 5V output. I needed to check for supply ripple at this load and get a feel for how much capacitance the rectifying input would need.

I could have found a resistor to load the supply but I wanted to make measurements at several current levels and did not want the current to vary with the supply voltage. I wanted my current sink to maintain the fixed level of current regardless of the input voltage. This was important because the supply I was testing has a variable output voltage.

For an LED tester, keeping the current fixed would also be desirable as the voltage across the LED or the overall supply voltage could change. This might not be a large issue if a uC were measuring all the parameters. With a variable controlled current sink you could make the LED tester that Keith plans without the microcontroller. Just connect a DVM to the current sink’s shunt resistor to measure the current. You may also need to measure the voltage drop on the LED to get the information needed to set the LED on current in your ultimate circuit.

My original circuit uses an Op-Amp to control the current. A variable resistor was used to set the desired current as a control voltage to the Op-Amp. The Op-Amp would control a pass element transistor to force a matching voltage drop on a measurement shunt. This circuit worked fine for all my power supply testing. I wanted to simplify it a bit by removing the Op-Amp so I reconfigured the circuit to work with just a transistor as the controlling element.

OpAmpTransistorSinkAnnotated

This article has several terms which might not be clear to the new electronics hobbyist so I probably need to cover a few basics. If you are familiar with current shunts, transistors and Op-Amps you can skip to the bottom of the article. This will not be a complete coverage of the topics, just an overview. I will do more basic electronics articles if I receive comments requesting it.

Adjustable Current Sink
These circuits automatically adjusts their effective resistance to maintain a constant current. The current is set by the voltage output from a variable resistor. A transistor is used as the adjustable resistance to maintain the current. My first circuit uses an Op-Amp to drive the transistor so that the voltage on a measurement shunt matches the control input.

Current Measurement Shunt
Current measurement shunt is a common term used to describe a small value but accurately known resistor used to measure current. To measure current a resistor is placed in series with the current source and the voltage drop across this resistor is measured. Ohm’s law is used to get the current given the resistor value and it’s voltage drop.

Ohm’s law, V=IR is solved for current to give I=V/R. I use a 1-Ohm resistor as the current measurement shunt so the equation becomes I=V. In other words, 1-Volt drop on the 1-Ohm resister equals 1-Amp. I can connect a DVM to the shunt to measure current directly. I don’t need currents as high as 1-Amp but it is very easy to understand that 0.1V equals 100mA.

Pick a current measurement shunt that allows for the measurement you need while not greatly affecting the circuit under test. Ideally a current shunt is a low value resister that does not drop a lot of volts. If you used a large resistor to measure current then the large voltage drop might effect the circuit you were testing. Say for example I used a 1,000-Ohm (1K) resistor. If I were measuring very small currents this would be fine but the drop is 1-Volt per mA so I would need to drop 10-Volts to measure 10mA. This would be a big problem if I needed to make that kind of measurement in a system using 5V.

Variable current control
The first part of the current sink circuits I want to cover is the variable current control. This is basically a variable resistor that outputs a voltage which controls the desired sink current. I wanted the voltage to be 1-to-1 with current with 1-Volt equal to 1-Amp as I planned to use a 1-Ohm shunt so everything would match well. Since the variable resistor would be controlling the overall current it needed to be stable and not vary as the load was adjusted.

If the variable resistor (pot or potentiometer) was configured as a simple voltage divider, with one end at +V and the other at ground, the output could be adjusted on the tap but it would vary as +V changed due to the load applied. For example if the pot was set at 1/2 it’s range and the input supply was 5V then it would output 2.5V. This would cause the current set point to be 2.5-Amps. If this load pulled down or overloaded the supply, it’s voltage might drop to say 4V which would effect the pots output. It’s set for 1/2 so the output would now change to 2-Amps. I am not working at 1-Amp currents but the problem is still there, especially if your testing a circuit that will have a variable drop with the measurement current.

I also wanted to limit the max load current to a level that would not burn up my transistor or smoke by measurement shunt instantly.

OpAmpTransistorSink

Lets start by looking at the simpler current set control used for the Op-Amp version. R1, RV1 and D1 make up this circuit in the diagram below. R1 pulls up on D1 so that it has a typical voltage drop of about 0.5V. D1 is a small Shockley signal diode so it typically has about a 0.5V forward voltage drop. This is important as this diode is acting as a reference for the control voltage output. It sets the max voltage for RV1 and also acts as a regulator so that the overall supply voltage does not cause the output of RV1 to vary. There will be some variation as the diode current will be a function of the supply voltage but the voltage drop is fairly constant so it should work well.

RV1 is connected across D1 so that its adjustment range is from 0V to the 0.5V drop on D1. Since I use a 1-to-1 voltage to current control the max voltage of 0.5 means 0.5 amps max. which is reasonable safe. Using the Shockley diode this way was an easy solution that solved both the voltage sensitivity and the max current limit. RV1 can now fully cover the range of 0 to 0.5V giving a nice control voltage.

D1 could have been a common silicon diode but the voltage drop would have been closer to 0.7 volts, setting the max current at 700mA which was more then I wanted to support. Even 500mA is a bit too much but it works OK for me.

Pass Element Transistor
The transistor in each of the current sink circuit serves as the variable resistor that will pass our desired set current. Basically, the transistor is controlled via Its base to act as a resistor with whatever resistance is needed to get the desired current to flow though the 1-Ohm measurement resistor. In this case I believe the Op-Amp circuit is easier to explain so I will start there.

Q1 in the Op-Amp circuit is controlled
from U1 an Op-Amp. The Op-Amp supplies current to the base of Q1 so that the voltage drop on the 1-Ohm resistor R4, has the same voltage as is set by RV1. Op-Amps are designed to make it easy to implement control systems such as this. They are most often used as amplifiers but in this circuit the gain is 1. The output of the Op-Amp must drive the transistor so that the same voltage drops across R4 as it sees on it’s positive input.

The really nice thing about the Op-Amp in this circuit is that it will output what ever is necessary to the base of our transistor to get the voltage drop correct on R4. The current gain on the transistor is not very important as long as it’s enough. Most transistors have a current gain (Beta) of at least 100 so one mA would turn on the transistor to pull 100mA. But we don’t have to worry about this as the Op-Amp will do what is necessary.

If we wanted to measure the current gain of our transistor this circuit would do that as well. We could measure the current in R3 with a known current in R4. The ratio of the too is the current gain of the transistor.

This Op-Amp controlled current sink works well and is easy to breadboard. In the picture below I have annotated the components. The desired current is set with RV1 and I used a DVM to measure the current at R4. The pass element transistor Q1 and R4 were discussed in this article about scrounging . At the higher currents around 300mA the transistor would heat up a bit but I was able to run the load at about 250mA over night in a long test I ran on the power supply prototyped on the same breadboard.

The power supply pictured is made from a LM317 with a bridge rectifier. The input is from a12V AC wall wart. I have another neat circuit driving an LED in that supply which I may cover in a future article.

Using the current sink to check LEDs
I built the Op-Amp current sink to test a power supply but it could just as easily be used to control the current though an LED. Just put the LED where Rload is on the schematic. You would want to adjust the max current to something that would not instantly fry an LED, say 60mA as most LEDs have a max of about 30mA. If R4, the current shunt was changed to 10-Ohms the circuit would have a 0-50mA range instead of 0-500mA. The voltage across the shut would be 10 times the current in that case so a set voltage on RV1 of 0.1V would cause 0.1V on the 10-Ohm shunt or 10mA. Just by changing the shunt resistor, R4, we can change the operating range of the circuit. Again, the transistor will be controlled by the Op-Amp so the circuit should be very flexible.

Choosing an Op-Amp
The schematic diagram shows the Op-Amp as a TL071. I’m sure that part would work fine but I used a MC34071 as you can tell by reading the 8-Pin part in the picture. Just about any Op-Amp will work here as long as it can pull its output near the negative rail and has a low offset voltage. Oh and it has to work from a single supply. All of these requirements are met by a great number of Op-Amp parts.

Removing the Op-Amp

To simplify the circuit I wanted to remove the Op-Amp. Transistors can be used as amplifiers. You could just feed a base current into the transistor and let it multiply by its beta to get your desired output current but this would be problematic. The beta on transistors varies greatly between parts and over temperature.

If the current were measured and the transistor controlled from a uC the varying current gain might not be an issue. The Op-Amp in the previous circuit dealt with all these issues but we can configure the transistor circuit so that it also works largely independent of beta variations.

TransistorSink

I have reconfigured the circuit as shown in the schematic above without the Op-Amp. It works well on the breadboard. The current set point is a bit sensitive and I had to change the pot to a much lower value (5K vrs 50K). This is because the variable resistor has to supply the base current for the transistor. With the Op-Amp that current was supplied as necessary by the Op-Amp output.

The transistor acts as a controlled amplifier by forcing the emitter voltage to equal the base voltage minus the base emitter drop. The base emitter voltage drop is typically around 0.7V so we could compensate for this with a silicon diode in the control circuit. Basically if I add the base emitter drop to the control voltage I should get the transistor to bias with the correct voltage across the measurement shunt.

I have added D? to add a voltage drop to the control range of RV2. I used a Shockley diode here to insure that the transistor is actually turned off at the minimum setting on RV2. I am really not adding enough voltage to fully overcome the base emitter forward drop but it does work to give me a good control range on the pot. I should point out that the output voltage of the control is not exactly the voltage that will be present on the resistor, it has the base emitter voltage and some drop in RV2 because there is current flowing into the base of the transistor. In the Op-Amp circuit, the input did not load the control voltage significantly. Due to this extra current, I had to adjust R2 and RV2 to a lower resistance. You may need to play with these values, depending on the beta of your transistor.

Adding a microcontroller
I did not use a microcontroller for these projects but I believe you could interface one very easily. To measure the current, you would read the voltage on the current shunt with an A/D input. I marked this location on both schematic diagrams where the current label is on the Kicad schematic.

If you were testing LEDs or needed to know the voltage drop across the test load, you need to measure both sides of the load. I labeled these connection points as "Voltage Drop" on the schematic. If you knew the supply voltage you could skip the voltage measurement of the input supply voltage.

Assuming you did know the supply voltage, you could connect an A/D channel to the measurement shunt and to the collector of the pass element transistor. If you don’t need to measure high currents and can afford the voltage drop, the shunt could be higher in value then the 1-Ohm I used. This way you have some resolution to measure over.

The LED tester application
Lets work though Keith’s LED tester application. We want to measure the current and voltage drop for an LED under test. The user can vary the current to get the desired brightness. The microcontroller measures the current and voltage drop to determine the series resistor to use when lighting the LED. For normal LEDs we can limit our max current to 50mA. Most can only support 30mA but we can push it for our example.

For this first pass, lets use the Op-Amp current sink. The user will connect an LED where Rload is shown on the schematic, then adjust RV1 to get the desired brightness.

Measuring voltage drop
To get the voltage drop, the reading at Q1’s collector is subtracted from 5V. In this case we start with a regulated 5V supply, so we do not need to measure the input voltage, we know it’s 5. to find the voltage drop we just subtract the voltage measurement at the Q1 collector from 5 volts.

Measuring the current
The microcontroller measures the voltage at the measurement shunt (R4) and calculates current using Ohm’s law.

We need to increase the voltage drop for 50mA on R4 by increasing its value. Using a 1-Ohm measurement shunt will not give us very good reso
lution. The voltage drop would be 0.050V max which is not much to measure with an A/D designed to operate from 0 to 5V on its input. We have some room to allow a higher voltage drop so we can safely increase R4.

We know that LEDs need at least 2 Volts of drop to operate and we need about a volt for the transistor so that leaves us with about 2 volts we can drop across the measurement shunt. Using Ohm’s law again, we calculate the resistor to get 2 volts drop at 50mA is 40-Ohms. We can use a standard value of 39-Ohms for our current shunt.

The microcontroller would measure the voltage across R4 then use Ohms law to find the current. I=V/39. The resolution of a 10-Bit converter working from 0-5V would be about 5mV and in this circuit that would be about 0.13mA. More then adequate for the task at hand.

Microcontroller controlled current.

Now the microcontroller can measure the current and voltage drop on an LED with the brightness set by the user. What if you wanted to microcontroller to set the current? We could use a PWM output to set the desired current. Just put a good filter on the PWM to make an analog voltage and drive the Op-Amp input from it. Use a voltage divider to set the max current for when the PWM output is at 100%.

Interesting options

This circuit could be used to test transistors. If another A/D channel was connected to the Op-Amp output you could find the base current for the transistor. You know the emitter current already so now you can find the transistors beta. In fact, you could make this a curve tracer by varying the current and measuring the base current over a range of collector emitter currents.

By including a photo detector connected to an A/D input you could measure an LEDs output at various currents. Once calibrated this could be used to verify performance on an LED or even to plot a brightness vrs current curve to find the efficiency.

I would use the Op-Amp circuit for the current shunt but the transistor circuit shown would work also. You would have to play with the PWM filter if you tried to control the current from the microcontroller as there would be a load on the filter. Be careful as you can blow a transistor, LED or smoke a resistor very quickly.

Comments please

  • I am very interested in the LED checker Keith’s plans to design. What do you think of this idea? Would it make a nice kit or piece of home lab equipment?
  • Should the LED tester have a microcontroller. The basic circuits shown here will allow you to measure LED current using a DVM. Just keep the 1-Ohm shunt and prototype up the simple transistor current source.
  • Any other ideas to consider? I know a FET could have been used for these circuits, I used a transistor because I had them lying around.
  • Any errors or typos I need to fix?

Posted in Development Tools, Discovering, Ideas, Microcontroller, Projects, Workshop Tools.


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. rsbohn says

    I like the simplicity of using a DVM, but the idea of a curve tracer is also appealing. It’s good to have the basics presented so clearly, with pointers on how to build something more advanced. Now I just need to find a precision 1 Ohm resitor!

  2. dfowler says

    rsbohn,

    You can probably get by with the standard 5% resistor. That would give you up to a 5% error but modern production practices probably yeild better then 5% accuracy. Also, you could calibrate the resistor with a DVM.