Skip navigation
Electronic Design

Microcontroller Interface Delivers Standard 4- To 20-mA Output

Voltage-to-current converters that feed grounded loads are common in industrial measurement and control applications. The conventional "textbook" circuit uses both positive and negative supply rails.

An earlier article by this author titled "Voltage-To-Current Converter Works From A Single Supply Rail" (Electronic Design, Feb. 17, 2003, ED Online 2985) described a circuit that could power grounded loads and needed only a positive supply rail. In a microcontrollerbased application, a designer can use a digital-to-analog converter (DAC) to convert the digital data into an analog voltage and use it to create a 4- to 20-mA current output.

But Figure 1 shows a better way to generate an industry-standard 4- to 20-mA current output from 8-bit data (00â??FF) in a microcontroller-based system. This simple circuit uses a digital potentiometer (AD5260) driven by the microcontroller's serial peripheral interface (SPI) output.

Under ideal conditions, the voltages at the LM124 op amp's inputs (inverting and non-inverting) are the same:

where i is the current through the ground-referenced load; I is the current through the digital potentiometer as set by constantcurrent source; and RV is the potentiometer resistance between the wiper and one end.

Solving for i:

In the example, I is selected as 0.08 mA, R1 is 100 Ω, and R2 is 5000 Ω. Also, the AD5260 digital potentiometer's total resistance is 20 kΩ.


Using a routine in the microcontroller, load 00 to the digital potentiometer through the SPI, which drives the wiper to one end so that RV is zero.

That makes:

Load FF into the digital potentiometer and the wiper goes to the other end so that RV is 20 kΩ. Therefore:

As a result, for the data 00 to FF, the load current varies linearly from 4 mA to 20 mA.

However, the digital potentiometer's wiper resistance is significant even when RV is low, which introduces an error. To eliminate this error, the digital potentiometer is connected as a voltage divider, with the wiper resistance in series with the op amp's non-inverting input.

If a 0.08-mA current source isn't readily available, you can use a National Semiconductor LM134 three-terminal adjustable current source and a potentiometer (VR1) to precisely set I at 0.08 mA (Fig. 2). Similarly, if a precise 5000-Ω resistance is unavailable for R2, a 10-kΩ multi-turn potentiometer can be employed.

The advantage of this circuit is its simplicity and the fact that it uses only three of the microcontroller's port lines (SPI), unlike a DAC, which requires eight port lines for the 8-bit data. The circuit uses only a positive supply rail for operation. Digital potentiometers also are available with I2C interfaces, with integrated op amps, and with different resistance values. Designers can adapt this circuit for use with these digital potentiometers.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.