**28 Feb***27*

*This article aims to introduce to beginners and intermediate readers a simple solution to build a digital to analog converter, based on the famous r/2r resistors network. This article also discuss a problem encountered by many beginners while trying to build their own DAC, and proposes some very simple solutions to that problem.*

**Learn how to build an Analog to digital converter using the same simple technique explained in this page.**

Through this article, I am going to explain how to build an 8-bit digital to analog converter with parallel input. If you don’t know what this means, well its simply a circuit that will take as input a digital 8-bit number from 0 (00000000) to 255 (11111111), and output the relative value on a scale from 0 to 5v.

The maths that describe this process is very simple, an 8 bit converter will divide the 5 volts into 255 steps, each step having a value of:

**5/255 = 0.019 V**

Then the output voltage for the converter should be equal to the binary input multiplied by the step value, e.g. for an input of 129 (1000 0001 in binary) the output voltage should be:

**129 X 0.019 = 2.451V**

Here is a simplified functional diagram of an 8-bit DAC.

Some vocabulary:

* DAC*: Digital to Analog converter.

**: Data lines.**

*D0, D1, D..**: Continuous electrical signals.*

**Analog***: Method of representing information using “1” and “0” (usually 5v and 0V).*

**Digital***: Less significant bit.*

**LSB***: Most significant bit.*

**MSB**### The R/2R resistor network.

The digital data entering thought the 8 lines (**D _{0}**

**to**

**D**) are going to be converted to an equivalent analog voltage (

_{7}**V**) by the mean of the R/2R resistor network. Actually a lot of commercial Digital to Analog converter ICs are based on this same principle. The R/2R network is build by a set of resistors of two values, with one of them double the other (example 10K and 20K), in on of my circuits I used

_{out}**1M ohm**and

**470K ohm**resistors, which is quite near to the R/2R ratio, and this small difference didn’t cause any detectable errors in most applications. However, if you want to build a very precise DAC, be precise when choosing the values of the resistors that will exactly match the

**R/2R**ratio.

Note that you can build a DAC with any number of bits you want, simply by enlarging the resistor network, by adding more **R/2R** branches (like the one shaded in green), BUT you must keep the **2R** resistance connected to ground (shaded in light red)

*Going through the mathematical proof for the operation of this converter can be a pain for some of us, and I am only intending to keep things simple.*

Now, in order to use this Resistor Network (*also called R/2R Ladder*) for real applications, you will have to build a very simple voltage buffer circuit, which will be explained in the next section.

### The applied circuit

All the components are labeled on the circuit, so i’ll start directly to explain how it works. To simplify this task, i’ll split the circuit into two main stages: **the Digital to analog converter** and **the Voltage buffer stage**.

##### Stage 1: the Digital to analog converter (The R/2R network)

This part have been explained in detail in the previous section, its purpose is to create the voltage **V _{1}** which is equivalent to the weight of the binary number on the lines (

**D**

_{0}**to**

**D**). Now that this is a resistor network, if we apply any load on the output of the

_{7}**first stage**, this load will be considered as an additional resistor in the network, and thus will disturb the network which will no longer provide the correct & desired output voltage. Therefore, to overcome this problem, we need a voltage buffer, here is where the next stage comes…

##### Stage 2: the voltage buffer

This stage will isolate the point **V _{1}** from the final output

**V**, while always keeping the voltage

_{2}**V**at the exact same value of

_{2}**V**. This is what we call a voltage buffer. for the voltage buffer we use an opamp with the output connected to the inverting input (

_{1}*this special configuration of the Op Amp is also called*). The most important things to note are:

**Voltage Follower**- No current (almost 0A) will flow from the point
**V**into the OpAmp, so we wont be disturbing the resistor network configuration._{1} **V**will always equal_{2}**V**(theoretically, see the rest of this document)._{1}- The current going out from the point
**V**to any other stage is sourced from the power supply of the OpAmp._{2}

### The most encountered problem & some solutions

A quick look on those two graphs can be sufficient to understand the problem: the output of the op-amp is not linear on the full 0-to-Vcc scale. actually an OpAmp, depending on its type, will deliver a maximum voltage of (Vcc – 0.5V), where Vcc is the supply voltage of the OpAmp. So, in our application, the OpAmp will only deliver 4.5V even if theoretically it should deliver 5V.

You may think this caused by the resistor network, but it’s not! this is a limitation in the op-amp itself.

Lets get a little deeper into the problem, the actual output curve in **red** should be linear, but actually it begins loosing its linearity beginning from 3.9 volt. (*Again this depends on the type of OpAmp, those results a based on my own tests on a LM350 OpAmp*) The red ‘Error zone’ is where the output of the DAC no longer math the relative binary input.

This is the error we will be trying to overcome in the next part, through two very simple solutions.

### Solution 1 :

The first solutions – shown in the red shading – is to increase the supply voltage of the Op-Amp, as shown in the schematic. This will totally solve the problem, and, whether you are supplying 6.5 volts or more, you will get neat linear output from 0V to 5V.

### Solution 2 :

The second solutions – shown in the red shading – is to reduce the range of the input to [0 to 127] from the original range of [0 to 255]. This will result on a voltage swing of 0 to 2.5 volt at the output, which will be in the linear operating area of the Op-Amp (*this done by attaching the MSB line to ground, this way you only control the 7 other lines, and a 7 bit value can swing from 0 to 127*).

*I hope this introduction was interesting, and that it will help you to build simple but reliable DACs to suit your application.*

[…] resistors and an LM358 opamp to buffer the output. This part of the circuit is borrowed from the 8-bit digital to analog converter circuit over at […]

It is possible to use single transistor or even singe jfet voltage follower to make a buffer. So you gonna get 0v-4.8V swing with bjt and something like 0v-4,95V with jfet if proper load resistor is chosen.

Sorry, for confusion. With BJT you gonna get 0v-4,3v only. My bad… But jfet gonna be just fine.

I’ve simulated with 741, and the results are not great for higher frequencies. I could see the signal distortion at already 15kHz. LM386 is also poor op amp.

Can i use this way to design a 11 bit DAC in CMOS 0.5u process? In this process the VDD voltage is 5 volts. U want to know is this way applicable to design a 11 bit DAC?

The frequency is not high. For example its about 50 MHZ. Can i use this method?

For 50MHz, i would really consider using a dedicated DAC chip… Or if you had to use this circuit, you should use small resistor values and excellent quality op-amp.

I have tried this schema on a breadboard, but the lm358 gives a lot of noise, getting fm radio interferences once its output gets amplified

is there another equivalent low noise one singe supply op amp i could use ?

hmmm… well any other opamp will do just fine. Also, you may want to use smaller resistor (to increase current and reduce noise).

well, i been searching on the web and not all opamp are suitable

ua741 is to old and lot linear under certain values, tl072 requires a bias unput voltage

the thing here is that i setup a lm386 on its own, without the r2r ladder

and as i amplyfy it with any ampli, i get radio signal

i tied the input to the groudn, same problem, i think it comes from the loop between out and inverting input, thought maybe i would use a resistor there, but i am not familiar to opamps, and people advise not to use lm386 cos it is cheap in any ways

I agree. It’s cheap, and far from being a “good” opamp. what are you trying to do exactly? It’s hard to advice you on a suitable choice if i don’t know what is the final aim…?

will this decode 4800khz

It all (mainly) depends on the OpAmp, if it can respond fast enough, you can do 4800KHz. But then, you may also want to make sure there is no parasitic capacitance in the R/2R circuit

I planned on using the LM741.

mhh.. worst opamp ever (in my opinion), but will do the job 🙂

Is the LM358 better? What do you suggest?

I realized I was asking about the wrong frequency. It should be 48kHz.

Then it’s even better, there shoudn’t be any problems.

However, if you want to do audio.. there much much much better audio DACs, at a fraction of the cost. TI does some cool audio DACs

What DAC would be appropriate? Can you recommend one that is both cheap as you say and has 16 bit rather than 8? Or are you talking about a serial DAC? I fear the 16-bit will be more expensive than 33 resistors but if you have better advice, please do let me know. Is it true that you can find a 16-bit DAC that is cheaper than the 33 resistors that this R2R would require? I have been trying to source such a DAC for a long time, and that is why I am exploring R2R to begin with – for lower cost. Thanks. This is a helpful site.

My tech knowledge is somewhat limited. The baud rate is 4800/9600, is this the same at 4.8 kHz?

You have a D/A converter which works as a gradated voltage divider. Then a 200 kHz sinusoidal signal is to be converted. What clock rate do you have to operate the DA converter at least?

The theory that governs CD rate is called the Nyquist Frequency, and to represent a sinusoid you need a frequency of at least 2x the frequency of the sampled signal. If you use exactly 2 times you get what is called “aliasing” if my memory serves me on what all this means, and that means you get unintended representations of the frequency, in other words other related frequencies that do not exist in the original signal. So plain answer, 200kHz requires somewhat over 400kHz sample rate.

You can also use a rail-to-rail op-amp to overcome that problem. For example, LMC660 will do from 0V to Vcc.

Which help me lot

nice work man!

Hi,

Above document is really helpful to me. Thank you.

Can you provide more detail on DAC IC and their circuit theory. SO that it would be help full.