# How do I provide a variable 4-20ma input?

I'm working on an embedded project that takes has an input that ranges from 4-20ma. This is normally provided by an external controller, but I'm working on a test bed.

Controlling voltage is easy - just stick a potentiometer in between the power supply and the input.

My first thought is to apply ohms law:

$I=\dfrac{V}{R}$

So assuming a 24 volt supply, we would use the following to get 4ma:

$.004=\dfrac{24}{R}$

$R=1.666667\Omega$

Assuming the same 24 volt supply, to get to 20ma:

$.02=\dfrac{24}{R}$

$R=8.333334\Omega$

I feel like I'm ignoring some key items such as the amperage of the incoming power. Am I anywhere close to being on track to using a potentiometer that (in combination with some other resistors) swings between 1.666667 and 8.333334?

• You're off by an order of magnitude on your resistors. 8 ohms over 24 volts will give you 3 amps. – Bryan Boettcher Mar 8 '13 at 21:27
• What is the input signal you have and how should it translate to 4-20mA? Using a simple resistor may very well defeat the advantage of using a current loop. – jippie Mar 8 '13 at 21:34
• In case you didn't realize it, the 4-20mA signal is an industrial standard for communicating sensor values. Also known as "4-20mA Current Loop". You can google for lots of docs, compatible components etc. Eg: en.wikipedia.org/wiki/Current_loop , ti.com/lit/ds/sbos344c/sbos344c.pdf etc – gwideman Mar 9 '13 at 0:51
• And this thread might be useful: electronics.stackexchange.com/questions/21250/… – gwideman Mar 9 '13 at 0:58
• I can't understand from the wording of your question if you are trying to implement an input or an output, or what a potentiometer has to do with what you want to achieve. – Phil Frost Mar 9 '13 at 3:17

OK, re-reading your question, it seems you just want a current source you can adjust with a knob. That is to say, the output should be a current which remains constant regardless of the voltage of the input that it's attached to (within some range)... and you get to adjust that constant current.

So what you need is an adjustable current source, which could be obtained as a chip as Gustavo notes, but it is easy to make from a couple of transistors and resistors, in the form of a "current mirror". See the schematic here: http://analoglib.net/2010-10-12/bilotti-jssc-75-june-noise-characteristics-of-current-mirror/

The transistors can be any small NPNs like 2N3904 or 2N2222, or if you want the output current to flow the other way, flip the schematic upside down (ground becomes V+) and use PNP transistors like 2N3906.

The idea is that you set the current at Ii (your Ii can be implemented via a variable resistor "Ri" to V+, say +12V), and the circuit will draw that same current into the collector of Q2. Calcs:

Assume V+ of 12V Choose RE = 50 ohm (as a starting guess).

20mA: Voltage drop across RE + Q1 VBE = 20mA * 50ohm + 0.7 = 1.7V.
We want Ri to drop 12-1.7V at 20mA, so Ri = 10.3V/20mA ~= 510 ohm.

4mA: Voltage across RE + Q1 VBE = 4mA * 50ohm + 0.7 = 0.9V We want Ri to drop 12-0.9V at 4mA, so Ri = 11.1V/4mA ~= 2.8k.

So a 2.5k pot in series with say 450 ohms would be a suitable resistance for the Ii leg, assuming 12V. Obviously you can calculate different numbers if you want to use a different V+, or larger or smaller RE values.

In the example where current flows into Q2 C, the range of voltages accomodated at Q2C will be from some high number that the transistor can withstand (say 40V), down to approximately the 1.7V calculated aboy, minus perhaps 0.4V -- so about 1.3V. If you need a lower range of voltages, substitute say -12V where ground is in the schematic shown here.

The upside down version with PNP transistors and a +12V rail follows the same logic -- highest voltage would be 12V - 1.3V = 10.7V, down to 12V - 40V = -28V.

Beware that you will often see current mirror circuits drawn without RE, that is to say, with the emitter connected to the rail (here ground). That is fine in an IC where Q1 and Q2 can be well matched. But using unmatched individual transistors the REs allow for some mismatch between the transistors -- the circuit no longer relies on a precise match of the VBE vs IC characteristics of the transistors.

Hope that helps.

For testing purposes, this is just fine. As for your power source, it needs to be regulated to provide 24 volts at all points in the amperage range (4-20ma).

As insta noted, you math is way off.

Better to look at as $R=\dfrac{V}{I}$

If V = 24V and I = .004A, then R = 6000Ω.

If V = 24V and I = .020A, then R = 1200Ω.

Therefore, your best bet is a 4.8K pot in series with a 1.2K fixed resistor. By the way, the fixed resistor needs to be at least a 1/2 watt. (P = V × I: 24V × .020A = 0.48W)

This assumes that your circuit's input is low enough impedance to not throw this off.

Take a look at the LT3092 from Linear. This is a current source capable of up to 200mA current source. Extremely simple to design, you can make it with a variable resistor so it sources 4mA to 20mA.

Note that if you want to test a 4-20ma receiver of yours, 4-20mA simulators do exist. This way you would have a trusted reference in your circuit.