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: 14 Apr 2010
Re: R-2R based DAC
['Quote ]
You are very close.

You need to keep the circuit (of ikalogic) as it is, and add to it that op amp non-inverting amplifier that you found. just hook the output of the first follower op-amp (the one of ikalogic's circuit) to the input of the non-inverting amp. adjust the gain with a potentiometer (this way you can easily vary it) and you're done. :)
Posted by:
calphool
on: 11 Apr 2010
R-2R based DAC
['Quote ]
Hello, I'm sort of an EE newbie, and still getting my brain around analog. I'm a software engineer.

I'm building an analog synthesizer (musical), and I'm using schematics from an old 1970s synth. The synth is 100% analog, including the keyboard, which apparently uses a string of resistors in series with each key being a tap point in that string. It also generates a "gate" signal as each key is pressed, which appears to simply be a +10v or +0v signal depending on whether any key is pressed or not.

I don't really have access to a keyboard that has these characteristics, so I'm planning to use a DAC tied into the inputs of the keyboard interface circuit. However, I need the DAC output range to be 0v - +10.7v in order to match the specs of the original design.

Since I'm kind of a newbie to all of this, I've tossed around a few different ideas on how to accomplish my goal of 0v - +10.7v via an 8 bit digital signal. One way that occurred to me was using an R-2R ladder tied to 8 mosfets, with the mosfets being driven by a regulated +12v signal (with each of their gates being attached to one bit of the digital bus, and their drains being connected to the input bits of the R-2R ladder). While this seems likely to work, it also seems like it might be overkill.

I was wondering if anyone knows if you could take the circuit described in this article, and change the op-amp configuration so that you tie pin 2 to ground through a resistor, and tie pin 1 back to pin 2 also through a resistor, having both resistors be the same value, and tie pin 8 to a +12v power source. Like this: http://en.wikipedia.org/wiki/File:Op-Am ... lifier.svg

My understanding is that this will multiply the input voltage by 2, so I'd achieve something close to +10v with a +5v digital level signal coming from the resistor ladder. I'm guessing that if I used pots I could get it to the +10.7v I need.

However, I'm very much a babe in the woods here, and I really have no idea whether that would work, or what side effects I could expect.

Thoughts?
Posted by:
ceerachanukya415
on: 23 Mar 2010
how to make a analog to digital converter
['Quote ]
hii ...

thanxs for giving me this oppurtunity

can u give me an idea to make a analog to digital converter (32 bit)

thanxx a lot
Posted by:
User avatar
ikalogic

on: 17 Dec 2009
Re: R-2R based DAC
['Quote ]
to preserve the analog voltage unchanged, maybe you need opamps....?
Posted by:
jonharrell
on: 16 Dec 2009
R-2R based DAC
['Quote ]
Hi Ibrahim,

great explanation of a simple cheap DAC. Wondering if you could offer some advise. I'm trying to toggle the digital input through 7 transistors (2n2222) as I am trying to capture the output of various sensors some of which need to be amplified first and inverted. I have tried simulating a circuit and also breadboarding the inputs but if I setup the 2n2222s as a switch they effect the output analog measurement. What would you do to setup a 7bit DAC with bit 8 to ground and each input D0-D6 received from a transistor switch?
Posted by:
dejan_kaljevic
on: 14 Mar 2009
R-2R based DAC
['Quote ]
from the way things look here, the audio output will have a DC offset of 2.5V, right? because the highest possible "value" (representing a positive peak) would be 5V, and the lowest (a negative peak) would be 0. so for most applications i suppose you would need a coupling capacitor. right?
Posted by:
aaritalo
on: 14 Feb 2009
R-2R based DAC
['Quote ]
Hi,
could you please give the Vout if our input is,for instance, (01000000)2 .
Posted by:
User avatar
ikalogic

on: 11 Jan 2009
Re: R-2R based DAC
['Quote ]

Quoting arubajack: Hey....I appreciate the input.....I know I'm way over my head but how do you learn if you don't branch out!
Jack :lol:


Sure, you're absolutely right.. i just didn't want you to be shocked an discouraged in your first attempt! ;)
Posted by:
arubajack
on: 11 Jan 2009
Re: R-2R based DAC
['Quote ]
Hey....I appreciate the input.....I know I'm way over my head but how do you learn if you don't branch out!
Jack :lol:
Posted by:
User avatar
ikalogic

on: 11 Jan 2009
Re: R-2R based DAC
['Quote ]

Quoting arubajack: I have a question for each of you.
I am in America and they are converting from a tv analog signal to a digital signal for television as of Feb. 2009.
Rather than buy a digital to analog converter (atsc to ntsc) I decided I would like to build one.
With the article that is written here I think it would be easy enough to do this even as a beginner.
I did have some electronic training in the military many years ago.
Anyway, My question would be: How many bit digital input would I have to have to cover the spectrum of what TV stations are putting out.
Secondly: Could I just hook up the TV to the analog end of the DAC and have the programs that I am looking for?
Jack


Not even close!

Sorry to disappoint you man, but TV signals, weather analog or digital is far more complicated than that.... I am not sure exactly how it works, but i am sure of one thing, this R/2R circuit is NOT what you need to convert analog TV to digital...
Posted by:
arubajack
on: 07 Jan 2009
R-2R based DAC
['Quote ]
I have a question for each of you.
I am in America and they are converting from a tv analog signal to a digital signal for television as of Feb. 2009.
Rather than buy a digital to analog converter (atsc to ntsc) I decided I would like to build one.
With the article that is written here I think it would be easy enough to do this even as a beginner.
I did have some electronic training in the military many years ago.
Anyway, My question would be: How many bit digital input would I have to have to cover the spectrum of what TV stations are putting out.
Secondly: Could I just hook up the TV to the analog end of the DAC and have the programs that I am looking for?
Jack
Posted by:
huayuliang
on: 07 Sep 2008
Re: R-2R based DAC
['Quote ]
for a DAC, it should be add a 74373 or the other chip as latch.. :D
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...
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.