Username:    Password: Remember me

8-bit Digital to Analog converter(DAC)
Using R/2R resistor network
By Ibrahim Kamal

Last update: 5/5/08
Learn how to build an Analog to digital converter using the same simple technique explained in this page. click here.

Overview

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.

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
D0, D1, D..:
Data lines
Analog: Continuous electrical signals
Digital: Method of representing information using "1" and "0" (usually 5v and 0V)
LSB: Less significant bit.
MSB: Most significant bit.


The R/2R resistor network.
The digital data entering thought the 8 lines (D0 to D7) are going to be converted to an equivalent analog voltage (V out) 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 2 values, with one of them double the other (example 10K and 20K), in on of my circuits I used 1M ohm and 470K ohm resistors, which is quite near to the R/2R ratio, and this small difference didn't cause any detectable

Follow the colors on the schematic and on the description text respectively, it can help!
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

Follow the colors on the schematic and on the description text respectively, it can help!


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 2 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 V1
which is equivalent to the weight of the binary number on the lines (D0 to D7). Now that this is a resistor network, if we apply any load on the output of the 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 V1 from the final output V2, while always keeping the voltage V2 at the exact same value of V1. This is what we call a voltage buffer. for the voltage buffer we use an opamp with the output connected to the inverting input (this special configuration of the Op Amp is also called Voltage Follower). The most important things to note are:

1
No current (almost 0A) will flow from the point V1 into the opamp, so we wont be disturbing the resistor network configuration
2 V2 will always equal V1 (theoretically, see the rest of this document)
3 The current going out from the point V2
to any other stage is sourced from from the power supply of the OpAmp.



The most encourted problem & some solutions
A quick look on those 2 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 2 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.


Join the Mailing List
Let us get in touch with you when we upload new interesting content.
Name:
Email:
Subscribe  Unsubscribe 



Related links
Analog to digital conversion, using an R/2R DAC.

Discussion (Last 15 posts preview...)
Preview of the last 15 messages discussing this page. Messages are sorted from the newest to the oldest.
Posted by:
User avatar
ikalogic

on: 28 Aug 2008
Re: R-2R based DAC
['Quote ]

Quoting randykayc: hey Ika

just wondering if you can help with the finding how the Thevenin theorem applies here.

randykayc


It should... why don't you try out and tell us? :)
Posted by:
randykayc
on: 27 Aug 2008
R-2R based DAC
['Quote ]
hey Ika

just wondering if you can help with the finding how the Thevenin theorem applies here.

randykayc
Posted by:
wand23
on: 23 Aug 2008
Re: R-2R based DAC
['Quote ]
yes..i already read that article...i'll try to design first..thanks a lot ika...
Posted by:
User avatar
ikalogic

on: 22 Aug 2008
Re: R-2R based DAC
['Quote ]

Quoting wand23: hello ika..i'm new member at this forum...i need your help and also your opinion..my final project title is to design 12-bit DAC..i need to design the schematic diagram and then continue with layout design..so can u help me how to design the schematic diagram of 12-bit DAC?


Welcome to ikalogic,

i guess you've read this article right? http://www.ikalogic.com/dac08.php

It explains how to build any N-bit DAC... jest add as many branches as you want..
Posted by:
wand23
on: 21 Aug 2008
R-2R based DAC
['Quote ]
hello ika..i'm new member at this forum...i need your help and also your opinion..my final project title is to design 12-bit DAC..i need to design the schematic diagram and then continue with layout design..so can u help me how to design the schematic diagram of 12-bit DAC?
Posted by:
User avatar
ikalogic

on: 27 May 2008
Re: R-2R based DAC
['Quote ]

Quoting ias_aca: very good explanation..gud job,ibrahim!

if u dont mind, please make the same article about 8 bit ADC...would u?
thanks a lot


It is already there: [link]
Posted by:
ias_aca
on: 27 May 2008
R-2R based DAC
['Quote ]
very good explanation..gud job,ibrahim!

if u dont mind, please make the same article about 8 bit ADC...would u?
thanks a lot
Posted by:
winnie
on: 09 May 2008
R-2R based DAC
['Quote ]
really you hav a gud website ya! thnaks
Posted by:
boobka
on: 09 May 2008
R-2R based DAC
['Quote ]
Nice article.
BUt I would suggest that for beginners it would be of help
if you could give some hints of the Thevenin equivalent of the network
..and thereafter discuss how the LM358 act as the voltage follower I guess... :wink:
Posted by:
User avatar
ikalogic

on: 08 May 2008
Re: R-2R based DAC
['Quote ]

Quoting nura100: Hello Ika,

Thanks alot for providing us with such a wonderful tutorial !

i want your opinion on the two kinds of DACs

1) Voltage output type
2) Current output type

Where will the Voltage type be used and where will be the current output type used

iam trying to reproduce some sound from 8051 using 8 bit Parallel DAC - but not sure which type to use volatge or current type .

Please Help


Arun


The most natural, simple, and usable solution is voltage output type, like the one produced on that page :) good luck with your project, and let me know how it turns out.
Posted by:
nura100
on: 07 May 2008
R-2R based DAC
['Quote ]
Hello Ika,

Thanks alot for providing us with such a wonderful tutorial !

i want your opinion on the two kinds of DACs

1) Voltage output type
2) Current output type

Where will the Voltage type be used and where will be the current output type used

iam trying to reproduce some sound from 8051 using 8 bit Parallel DAC - but not sure which type to use volatge or current type .

Please Help


Arun
Posted by:
User avatar
ikalogic

on: 28 Feb 2008
Re: R-2R based DAC
['Quote ]
Contribution from Chris :
Quote: Brill tutorial, but...
I think your circuit would divide the input voltage into 256 steps going from 00000000=0v to 11111111=4.98v (if input voltage is 5v). I don't think 5v is achievable.

Formula:
Vdigitalinput / 2^no of bits * digital value = Vout?

examples:
11111111 -> 5 / 2^8 * 255 = 4.98v (3sf)
10101010 -> 5 / 2^8 * 170 = 3.32v (3sf)
00000000 -> 5 / 2^8 * 0 = 0v

Okay, it's very close and is even less significant for more bits, but it might help someone if they've got a small error and can't figure out where it's coming from. (For a four bit DAC the output is about 4.7v; the error gets larger for less bits.)
Chris.

Posted by:
User avatar
ikalogic

on: 28 Feb 2008
Re: R-2R based DAC
['Quote ]

Quote: Thanks for this guide. I had a feeling this sort of solution was possible and this is exactly what I was looking for. Nice intro.

Two points you may like to improve:
1. Low end non linearity can be even more important than the top end that you explain well. Worth adding a comment.

2. The simplest most practicle solution is to use a more recent rail-to-rail op-amp like the LM2902. They are dirt cheap (0.20 euros for a quad op-amp package) and save the inconvenience of split suppies.

Finally a question. What is the cause of the minimum of 1k for R?

I have some digital outputs that already have 1k current limitting resistors. I would be great to have this as half the component count and use R=500 ohm. Looks like this would draw about 5mA for a 4 bit DAC which is fine by me.

Is the power drain the only reason for the limit ?

TIA.

Exactly, the power drain IS the reason for the 1k limit.

Thanks a lot Ike for your contributions.

i'll work on the low end non linearity problem... i think it's time to update this article.. it hasen't changed for 5 monthes..
Posted by:
User avatar
ikalogic

on: 28 Feb 2008
Re: R-2R based DAC
['Quote ]

Quote: i have a question regarding DAC. i am a student working on a project where i am using a microcontroller that creates a PWM signal as a function of a certain transfer function. normaly if i where to use an AC motor i would not need to do anything else since the engine would just take the average voltage of the PWM signal. but in my case i need to output a DC value (an average voltage value of the PWM voltage) since i have to make a battery emulator. as i said i am actually outputting the PWM on only one pin. how would you advise i do the DA conversion here so that i am outputing an average of voltage of the PWM?
i thank you for your time and hope to hear from you soon.



Hello, You don't need DA conversion to control the speed of DC motors. changing the duty cycle of the PWM on one pin works perfectly to control DC motors. Actually in PWM, you do not want to send an average voltage, you let the motor do that as it acts as an inductor with it's coil...
Posted by:
User avatar
ikalogic

on: 28 Feb 2008
Re: R-2R based DAC
['Quote ]

Quote: If it's a volt reference source,and how can output current over 200 mA?


A simple NPN transistor in common emitter configuration (emitter attached to groud)

a 2N2222 BJT will give you up to 800mA, a TIP122 will give you up to 5A.
You have to be a member to post replies.
Username: Remember me
Register now! it only takes an instant.
Forgot your password?
ikalogic.com: Electronics and Robotics related projects.
All content on this site is provided as is and without any guarantee of any kind. We cannot be held responsible for any errors, omissions, or damages arising out of use of information available on this web site.
Creative Commons License
IMPORTANT COPYRIGHT NOTE: Electronics and Robotics Articles by Ibrahim KAMAL are licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.