You are on page 1of 4

Generating Analog Voltage with Digital Circuit (I) http://dev.emcelettronica.


Your Electronics Open Source
Home > Blog > brumbarchris's blog > Contenuti

Generating Analog Voltage with Digital
Circuit (I)
By brumbarchris
Created 09/16/2008 - 19:50

Technology analog voltage DAC digital circuit microcontroller

We will detail the method of generating an analog voltage using digital circuit (what is called
the R/2R resistor network). This method requires having a number of microcontroller pins
available to be used for this specific task only. It is a very cheap method, as it only requires a
few resistors of two different values only. The circuit shown in Figure 1 depicts an 8-bit DAC
built around the available pins of the microcontroller using 2kOhm and 1kOhm resistors. To
simplify the Bill of Materials, you could also use only 1kOhm resistors, by using two of them in
series instead of each 2kOhm resistor.

Figure 1 – 8-bit DAC with resistor network

The advantage of this circuit, besides its very low cost, is the simple logic needed to operate
it. The 8 pins of the microcontroller used have the exact functions of the 8 bits of a DAC, with
the leftmost pin being the LSB and the rightmost pin being the MSB. The digital code applied
by the microcontroller at its pins represents the exact value needed by a legitimate DAC to

1 din 4 16.09.2008 18:10
Generating Analog Voltage with Digital Circuit (I)

generate the required voltage:





Using this particular configuration it is easy to increase/decrease the number of bits of your
DAC, by simply using more or less pins of the microcontroller and more/less R/2R branches.
The following images illustrate the simulated output value for some of the digital codes that
might be applied:

Figure 2 – 8-bit DAC with 1111.1111 digital code applied

2 din 4 16.09.2008 18:10
Generating Analog Voltage with Digital Circuit (I)

Figure 3 – 8-bit DAC with 0111.1111 digital code applied

Figure 4 – 8-bit DAC with 0000.0001 digital code applied

It must be noted though, that any desire to use the generated voltage for real application
would prompt the need of buffering it through a high impedance buffer. The reason for this is
that any additional load applied to the output of this DAC would disturb the intended behavior
of the R/2R network, thus introducing errors. A simple voltage repeater may be used as a

3 din 4 16.09.2008 18:10
Generating Analog Voltage with Digital Circuit (I)

buffer, but special care should be taken in order to use a rail-to-rail operational amplifier.
Using a regular operational amplifier would simply introduce errors towards the two extremes
of the scale, as the amplifier itself will not be capable of repeating its input voltage that is
being generated by this very simple DAC.

Although simple and cheap, this DAC can be use as any other conventional one. Applying
successive codes at its input with a fixed repetition rate, would allow us to generate basically
any type of analogue signal, its frequency only being limited by the sample rate at which the
used microcontroller can output digital codes.

Of course, as in any design activities, the result is not perfect, as it is only a trade-off between
advantages and disadvantages:

a) Although cheap and easy to use, this structure has disadvantages too: the finer the
resolution, the more microcontroller pins are needed.

b) Also the resistors in the network should be carefully selected (1% tolerance is preferred;
using 5% tolerance resistors might introduce unacceptable errors).

c) The higher the resolution of such a DAC the slower it gets, because of the large RC
constant of each added RC link.


Source URL:

4 din 4 16.09.2008 18:10